@use "/shell" as *; @use "quark:list" as list; #release-notice { /* opens once: sheet re-runs restart a delay, so gate it on the fact it writes */ &:not([data-did-open]) { @delay 7000 { is-open: ""; data-did-open: ""; } } /* prevent clicks from bubbling to the sheet */ @on mouseup, click (stop-propagation); } provider-fetch[api-url*="package-metas/index.json"][is-success] { $package-indices: prop("provision").body; /* `excom.navGroup` moves a package out of its type's list, into that group */ $ungrouped: list.reject($package-indices.packages, "navGroup"); .package-links { [bind-elements] ul:not(ul ul) { content: iterate(getPackagesByType($ungrouped, "kit-element")); } [bind-element-bases] ul:not(ul ul) { content: iterate(getPackagesByType($ungrouped, "element-base")); } [bind-tools] ul:not(ul ul) { content: iterate(getPackagesByType($ungrouped, "tool")); } /* the standalone libraries: same rows, rendered flat (shell.css) */ [bind-libraries] ul:not(ul ul) { content: iterate(getPackagesByType($ungrouped, "library")); } [bind-library-group] ul:not(ul ul) { content: iterate(list.filter($package-indices.packages, "navGroup", "libraries")); } ul:not(ul ul) > li { $pkg: item.shortName; > spa-a { route-href: "/packages/#{item.shortName}"; } } /* one `content` rule per link: a second one would rewrite the first's text on every pass */ ul:not(ul ul, [bind-libraries] ul) > li > spa-a { content: item.shortName; } [bind-libraries] ul:not(ul ul) > li > spa-a { content: displayName(item.shortName); } /* packages whose docs span several pages: one collapsible group per section */ [bind-sections] { content: iterate(item.docSections); summary { content: item.title; } details > ul { content: iterate(item.docs); spa-a { route-href: "/packages/#{$pkg}/#{item.name}"; content: item.title; } } details:not(:has(spa-a[is-active])) { open: none; } } } /* page titles: the page, then the site. The docs home keeps the title in the document head; the other routes carry theirs in markup */ spa-route[is-active] { /* a site guide */ &[route-href$=":name"] { $title-guide: list.find($package-indices.docs, "name", $route.params.name); document-title: "#{$title-guide.title or $route.params.name} · Nucleus · docs"; } /* a package README */ &[route-href$=":packageName"] { document-title: "#{displayName($route.params.packageName)} · Nucleus · docs"; } /* one page of a package's docs */ &[route-href$=":docName"] { $title-package: list.find($package-indices.packages, "shortName", $route.params.packageName); document-title: "#{docTitle($title-package, $route.params.docName)} · #{displayName($route.params.packageName)} · Nucleus · docs"; } } /* the page's markdown file, for the footer link: the docs home and each guide the index lists, and a package's page whose index entry says `markdown` (build-docs-index sets it; the dev server's index has none, so no link there). siteDocHref and the path check say which URL is the page's own: the 404 and a package's doc pages have none */ > spa-manager[active-url] { $page-path: attr("active-url").split("#").at(0).split("?").at(0); $page-name: if($page-path == SITE_HOME: SITE_HOME_DOC; else: $page-path.split("/").at(-1)); $page-guide: list.find($package-indices.docs, "name", $page-name); $page-package: list.find($package-indices.packages, "shortName", $page-name); $page-markdown: if($page-guide and siteDocHref($page-guide.name) == $page-path: "/docs/#{$page-guide.name}.md"; $page-package.markdown and "#{SITE_BASE}/packages/#{$page-package.shortName}" == $page-path: "/#{$page-package.shortName}.md"); footer [bind-page-markdown] { href: $page-markdown; content: ternary($page-markdown, "Markdown version of this page"); } } } spa-route { $route: prop("provision"); /* paramless routes name their guide in markup (the docs home, `/`); /docs/:name gets it from params */ $route-doc-name: attr("data-doc-name"); } /* the desktop aside and the mobile sheet stamp the same nav template */ [data-site-nav] { details:has(spa-a[is-active]) { /* not kosher */ open: ""; } spa-a[is-active] { aria-current: ""; } spa-a:not([is-active]) { aria-current: none; } } /* mobile sheet: Escape / back gesture while open; a tapped link closes it */ #site-menu { &[is-open] dismiss-watcher { is-active: ""; } &:not([is-open]) dismiss-watcher { is-active: none; } @on click (target: "spa-a") { is-open: none; } } #site-menu-gesture { &:has(> #site-menu[is-open]) { progress-offset: 1; } &:not(:has(> #site-menu[is-open])) { progress-offset: 0; } @on gesture-handler-start { #site-menu { is-scrubbing: ""; } } @on gesture-handler-end { #site-menu { is-open: event.detail.snap == 1; is-scrubbing: none; } } } main { @on copy-source (handle: copySource); } #search-dialog[open] { > include-content { is-active: ""; /* for some reason this is necessary on first render */ @on include-content-did-render (handle: focusInput); } input[type="search"] { /* works on all subsequent opens */ autofocus: ""; } } #search-dialog:not([open]) input[type="search"] { autofocus: none; }

Built-in functions

Available in every expression, after @use exports: element reads, loop context, rendering, listeners, utilities.

Reference

Generated.

Element reads

Name Description
attr("name") The matched element's attribute value (null when absent). attr("content") returns its innerHTML. A literal name is observed: the rule re-runs when that attribute changes, even if it is not in the selector. attr($name) reads but does not subscribe.
prop("name") The matched element's JS property (prop("provision") reads a Neutron provision). A literal name is observed: the rule re-runs when JS assigns element.name (coalesced per microtask). In-place mutation and browser-driven native state are not observed. prop($name) reads but does not subscribe.
closest("selector") element.closest(selector) from the matched element: the nearest ancestor-or-self matching the selector, else null. Not observed.
element The matched element itself — the node the rule is applied to (inside an @on … { } block the listening element; target is the delegate). It reaches a neighbour without a selector: @command toggle-popover (target: element.nextElementSibling). Reads through it are not observed — use attr() / prop() for reactive reads.

Loop context

Name Description
item Inside an iterate() row: the current collection item (the value for objects). undefined outside a row. While a prerendered page hydrates, a rule on a prerendered row keeps what is painted until iterate() adopts the row.
index Inside an iterate() row: the current position (the key for objects). undefined outside a row. Prerendered rows: as item.

Rendering (content)

Name Description
iterate(collection, "template-ref"?, "key-property"?) For content: renders one clone of the element's <template> child (or the template at template-ref, a selector / URL) per array item or object entry, keyed by key-property (else a content hash) so existing rows are reused. null / undefined wipes the rows; an empty collection or a non-collection clears them.
template("template-ref"?) For content: renders one clone of the referenced <template> (selector or URL; defaults to the element's own <template> child).
dangerous-html(html) For content: sets innerHTML to the string. No sanitizing: never pass user-controlled markup.

Event listeners

Name Description
event Inside an @on … { } block, its @dispatch / @command statements and its target / key / debounce / throttle options: the DOM event being handled (event.target, event.detail, …). undefined elsewhere, handle: included: its listener receives the event as its argument.
target Inside an @on … { } block and its target / key / debounce / throttle options: the element the target: option matched (the delegate), or event.target without that option. undefined elsewhere, handle: included.
prevent-default A listener that calls event.preventDefault(), for handle:. The (prevent-default) flag is the shorter form.
stop-propagation A listener that calls event.stopPropagation(), for handle:. The (stop-propagation) flag is the shorter form.

Utilities

Name Description
ternary(condition, whenTrue, whenFalse?) whenTrue if condition is truthy, else whenFalse (null when omitted). Prefer if() for multi-arm conditionals.

Debugging

Name Description
log(...values) Logs the values to the console and returns them as an array.
debug(...values) Hits a debugger statement and returns the values as an array.

Reading the matched element's JS properties and handing the node to module functions: Element properties. Methods callable on values: Allowed methods.

Beta. The Nucleus Stack is in beta for a few weeks until features are stabilized and optimized.

Thanks — we'll email you when it ships.

Something went wrong. Please try again.