diff --git a/services/site/script/css-variants-plugin.ts b/services/site/script/css-variants-plugin.ts new file mode 100644 index 000000000000..8696b26e78cc --- /dev/null +++ b/services/site/script/css-variants-plugin.ts @@ -0,0 +1,86 @@ +// Production CSS plugins shared by the site's build (vite.config.ts) and the docs' own build +// (src/docs/script/build.ts), so both ship the same stylesheets for the same settings. +import type { PluginOption } from "vite" +import variants from "../src/component/site/css-variants.json" + +/** + * Production only: a stylesheet named *.dev.css is for development tools (Settings, Design mode) and + * builds empty, so its rules never reach a page's render-blocking CSS. + */ +export function devOnlyCss(): PluginOption { + return { + name: "dev-only-css", + apply: "build", + enforce: "pre", + load: (id) => (/\.dev\.css(\?|$)/.test(id) ? "" : undefined), + } +} + +/** + * Production only: Settings and Design mode are development tools, so the site root's settings + * attributes always carry the default settings' values (src/component/site/css-variants.json). This + * drops, from the production CSS, each selector that needs another value of one of them, and each + * rule left with none; the development server keeps every variant for Design mode. Only attributes + * outside parentheses count (an attribute inside :not(), :is() or :has() keeps its selector). + */ +export function cssVariantsForProduction(): PluginOption { + const fixed = variants as Record + const impossible = (selector: string) => { + let depth = 0 + let top = "" + for (const char of selector) { + if (char === "(") depth++ + if (depth === 0) top += char + if (char === ")") depth-- + } + return [...top.matchAll(/\[(data-[\w-]+)(~?=)["']?([^"'\]]*)["']?\]/g)].some((match) => { + if (!(match[1] in fixed)) return false + const value = fixed[match[1]] + if (value === null) return true + return match[2] === "~=" ? !value.split(" ").includes(match[3]) : value !== match[3] + }) + } + const split = (selector: string) => { + const parts: string[] = [] + let depth = 0 + let quote = "" + let start = 0 + for (let i = 0; i < selector.length; i++) { + const char = selector[i] + if (quote) { + if (char === quote) quote = "" + continue + } + if (char === '"' || char === "'") quote = char + else if (char === "(" || char === "[") depth++ + else if (char === ")" || char === "]") depth-- + else if (char === "," && depth === 0) { + parts.push(selector.slice(start, i)) + start = i + 1 + } + } + return [...parts, selector.slice(start)] + } + return { + name: "css-variants-for-production", + apply: "build", + config: () => ({ + css: { + postcss: { + plugins: [ + { + postcssPlugin: "css-variants-for-production", + Rule(rule: { selector: string; remove(): void }) { + const selectors = split(rule.selector) + const kept = selectors.filter((selector) => !impossible(selector)) + if (kept.length === selectors.length) return + if (!kept.length) return rule.remove() + rule.selector = kept.join(",") + }, + }, + ], + }, + }, + }), + } +} diff --git a/services/site/script/css-variants.ts b/services/site/script/css-variants.ts index 8e8b3842cf3d..bb9188d75638 100644 --- a/services/site/script/css-variants.ts +++ b/services/site/script/css-variants.ts @@ -1,5 +1,5 @@ // Writes src/component/site/css-variants.json: each settings attribute and the one value production -// renders for it (the default settings; null when it is left off). vite.config.ts drops, from the +// renders for it (the default settings; null when it is left off). script/css-variants-plugin.ts drops, from the // production CSS only, every rule that needs another value. Run after changing a setting's default // or adding a settings attribute; test/css-variants.test.ts fails while the file is out of date. import path from "node:path" diff --git a/services/site/script/docs-file-icons.ts b/services/site/script/docs-file-icons.ts index 297eb0e67609..14c27e697f80 100644 --- a/services/site/script/docs-file-icons.ts +++ b/services/site/script/docs-file-icons.ts @@ -1,7 +1,8 @@ // Writes src/component/site/docs-file-icons.ts: the file-type icons the docs use, cut from the // desktop app's sprite (@opencode/ui), so the site bundles a dozen icons instead of 1,089. -// The names come from the shared mapping (chooseIconName) applied to every code block title in -// the docs content and the filenames on /dev/docs-components, plus each icon's _light variant. +// The names come from the shared mapping (chooseIconName) applied to every code block title and +// every file and folder in a file tree ("├── name" lines) in the docs content, and the filenames on +// /dev/docs-components, plus each icon's _light variant. // Run after adding a new kind of file to the docs: bun script/docs-file-icons.ts import { chooseIconName } from "@opencode/ui/icons/file-type-name" import { readdirSync } from "node:fs" @@ -9,7 +10,7 @@ import path from "node:path" const app = path.resolve(import.meta.dir, "..") const content = path.resolve(app, "src/docs/content") -const sprite = await Bun.file(path.resolve(app, "../../ui/src/components/file-icons/sprite.svg")).text() +const sprite = await Bun.file(path.resolve(app, "../../packages/ui/src/components/file-icons/sprite.svg")).text() const walk = (dir: string): string[] => readdirSync(dir, { withFileTypes: true }).flatMap((entry) => @@ -19,13 +20,26 @@ const walk = (dir: string): string[] => ? [path.join(dir, entry.name)] : [], ) -const titles = ( - await Promise.all( - walk(content).map(async (file) => [...(await Bun.file(file).text()).matchAll(/```\w*\s+title="([^"]+)"/g)]), - ) +const sources = await Promise.all(walk(content).map((file) => Bun.file(file).text())) +const titles = sources.flatMap((text) => + [...text.matchAll(/```\w*\s+title="([^"]+)"/g)].map((match) => match[1].replace(/ \(excerpt\)$/, "")), ) - .flat() - .map((match) => match[1]) +// File trees: the name after the "├── " prefix, without the note after it (two spaces or "←"). +const tree = sources + .flatMap((text) => [...text.matchAll(/```text\n([\s\S]*?)```/g)].map((match) => match[1])) + .filter((block) => /[├└]──/.test(block)) + .flatMap((block) => block.split("\n")) + .map((line) => line.replace(/^[│├└─\s]+/, "").replace(/(\s{2,}|\s+←).*$/, "")) + .filter(Boolean) + .flatMap((name) => + name + .replace(/\/$/, "") + .split("/") + .map((part, index, parts) => ({ + name: part, + directory: index < parts.length - 1 || name.endsWith("/"), + })), + ) // Filenames and folders shown on the site that aren't titles in the docs content. const site = [".env", ".github/workflows/opencode.yml", "mise.toml", "install.sh", "count-lines.ts", "release.md"] const folders = [".opencode", "agents", "commands", "plugins", "tools", ".github", "workflows"] @@ -33,6 +47,7 @@ const folders = [".opencode", "agents", "commands", "plugins", "tools", ".github const names = new Set([ ...[...titles, ...site].map((name) => chooseIconName(name, "file", false)), ...folders.map((name) => chooseIconName(name, "directory", false)), + ...tree.map((entry) => chooseIconName(entry.name, entry.directory ? "directory" : "file", false)), // The fallbacks. chooseIconName("unknown", "file", false), chooseIconName("unknown", "directory", false), diff --git a/services/site/script/fold-settings.ts b/services/site/script/fold-settings.ts index 07d5b30ef928..353e75133525 100644 --- a/services/site/script/fold-settings.ts +++ b/services/site/script/fold-settings.ts @@ -1,6 +1,6 @@ // Production only: Settings and Design mode are development tools, so a production page always // renders the default settings (settings-defaults.json) with Design mode off. This is the JavaScript -// counterpart of cssVariantsForProduction() in vite.config.ts: before Solid compiles a module, it +// counterpart of cssVariantsForProduction() (script/css-variants-plugin.ts): before Solid compiles a module, it // reads every `siteSettings.` as the default's literal, `designMode()` as false and // `import.meta.env.DEV` as false, then folds what that decides (``, ``/``, // ternaries, `&&`/`||`, `if`), so the branches production never takes, and everything only they diff --git a/services/site/src/component/site/code-frame.tsx b/services/site/src/component/site/code-frame.tsx index ee54dde67089..2dbfcb043b06 100644 --- a/services/site/src/component/site/code-frame.tsx +++ b/services/site/src/component/site/code-frame.tsx @@ -17,6 +17,8 @@ export function CodeFrame(props: { copy?: string /** A different terminal mark, for the icon options in the code gallery. */ icon?: "window" | "prompt" | "titlebar" + /** The block's language, which the funnel reports with a copy (data-funnel-method). */ + method?: string children: JSX.Element }) { return ( @@ -26,7 +28,7 @@ export function CodeFrame(props: { {(label) => } {props.label} - {(text) => } + {(text) => } {props.children} @@ -37,9 +39,10 @@ export function CodeFrame(props: { * Copy with visible feedback, text only: "Copy" turns to "Copied" for 1.5s (or "Failed" when the * clipboard refuses), and a polite live region says what happened. The three labels share one * right-aligned grid cell, so the button keeps the longest label's width and the text's right edge - * never moves. + * never moves. Pages that never hydrate (the docs) copy `data-code` from a delegated listener and + * set `data-state` themselves (src/docs/client.ts). */ -export function CopyButton(props: { text: string; slot?: "code-copy" | "copy" }) { +export function CopyButton(props: { text: string; slot?: "code-copy" | "copy"; method?: string }) { const i18n = useI18n() const [state, setState] = createSignal<"idle" | "copied" | "failed">("idle") let timer: ReturnType | undefined @@ -49,8 +52,9 @@ export function CopyButton(props: { text: string; slot?: "code-copy" | "copy" }) clearTimeout(timer) timer = setTimeout(() => setState("idle"), 1500) } + const text = () => props.text.replace(/^\$ /gm, "") const copy = () => { - const write = navigator.clipboard?.writeText(props.text.replace(/^\$ /gm, "")) + const write = navigator.clipboard?.writeText(text()) if (!write) return show("failed") write.then( () => show("copied"), @@ -64,6 +68,8 @@ export function CopyButton(props: { text: string; slot?: "code-copy" | "copy" }) data-slot={props.slot ?? "code-copy"} data-state={state()} data-funnel-copy="snippet" + data-funnel-method={props.method} + data-code={text()} aria-label={i18n.t("site.code.copy")} onClick={copy} > diff --git a/services/site/src/component/site/docs-file-icons.ts b/services/site/src/component/site/docs-file-icons.ts index f9122afa9a0c..9bda0c7310d9 100644 --- a/services/site/src/component/site/docs-file-icons.ts +++ b/services/site/src/component/site/docs-file-icons.ts @@ -7,15 +7,18 @@ export const docsFileIcons: Partial> = { Json: '', Document: '', - Typescript: - '', + React_ts: + '', Nodejs: '', + Typescript: + '', + Vite: '', Readme: '', - Tune: '', - Yaml: '', Toml: '', + Yaml: '', + Tune: '', Console: '', Folder: @@ -26,6 +29,16 @@ export const docsFileIcons: Partial> = { '', FolderGhWorkflows: '', + FolderPackages: + '', + FolderSrc: + '', + Javascript: + '', + FolderScripts: + '', + FolderI18n: + '', Toml_light: '', } diff --git a/services/site/src/component/site/docs-lockup.css b/services/site/src/component/site/docs-lockup.css index 7565489447e1..7b8ddf38f82a 100644 --- a/services/site/src/component/site/docs-lockup.css +++ b/services/site/src/component/site/docs-lockup.css @@ -221,6 +221,11 @@ --lockup-face: 30px; } + /* A page that renders a copy in each host (DocsLockup inline) shows the top bar's here. */ + [data-site] [data-component="docs-lockup"][data-host="sidebar"] { + display: none; + } + [data-site]:not([data-logo="icon"]) [data-component="docs-lockup"] { --lockup-text: calc(var(--edge) + env(safe-area-inset-left, 0px) + 30px * 234 / 42 + 12px); } @@ -453,7 +458,9 @@ after another (docs-lockup.tsx). The rows keep the shared hover tint and active bar. Beside the sidebar only; the phone sheet keeps the list. */ @media (min-width: 60.0625rem) { - [data-site][data-section-menu="fan"] [data-component="docs-lockup"] :is([data-slot="menu"], [data-slot="submenu"]) { + [data-site][data-section-menu="fan"] + [data-component="docs-lockup"] + :is([data-slot="menu"], [data-slot="submenu"]):not([hidden]) { display: flex; flex-direction: column; gap: 0.375rem; @@ -476,7 +483,7 @@ /* As under the logo fan (logo-fan.css), the docs nav under the cards fades out while they're open, so it doesn't show through the gaps and the see-through cards. */ [data-site][data-section-menu="fan"] - [data-component="sidebar"]:has([data-component="docs-lockup"] [data-slot="menu"]) + [data-component="sidebar"]:has([data-component="docs-lockup"] [data-slot="menu"]:not([hidden])) > [data-component="section-nav"] { opacity: 0; pointer-events: none; diff --git a/services/site/src/component/site/docs-lockup.tsx b/services/site/src/component/site/docs-lockup.tsx index bfd2981884f2..e8949e66fe9f 100644 --- a/services/site/src/component/site/docs-lockup.tsx +++ b/services/site/src/component/site/docs-lockup.tsx @@ -32,10 +32,17 @@ type Item = { * Settings › Docs switcher › lockup: the docs section word after the site's logo, like the Data and * Console headers (public/nav-demo/switcher.js). One button opens a menu of the docs sections, where * "Docs" has a submenu of versions. On an older version, "/ V1" after the word shows it and switches - * back. + * back. The menus are always in the page, hidden while closed, so pages that never hydrate (the docs) + * can open them from a delegated listener (src/docs/client.ts). */ export function DocsLockup(props: { current: string + /** + * Renders in place, in the host passed (the sidebar or the top bar, each with its own copy), instead + * of moving itself there after mount: for pages that render the lockup on the server and never + * hydrate (the docs). + */ + inline?: "sidebar" | "topbar" /** Demo only: link the sections elsewhere and switch them in place instead of navigating. */ href?: (label: string) => string onSelect?: (label: string) => void @@ -66,6 +73,7 @@ export function DocsLockup(props: { // page, or on phones in the top bar, so it stays above the page like the bar. const [host, setHost] = createSignal() onMount(() => { + if (props.inline) return const phone = window.matchMedia("(max-width: 60rem)") const place = () => setHost( @@ -78,6 +86,58 @@ export function DocsLockup(props: { onCleanup(() => phone.removeEventListener("change", place)) }) + const suffix = props.inline ? `-${props.inline}` : "" + const lockup = () => ( +
+ name(label)} + triggerLabel={(label) => `${name(label)}, switch docs`} + items={sections().map((product) => ({ + id: product.label, + label: product.label, + ariaLabel: name(product.label), + href: props.href?.(product.label) ?? product.href, + sub: + product.label !== "Docs" + ? undefined + : props.version + ? { + label: "Docs version", + items: versionItems(props.version), + current: props.version.current, + onSelect: (id: string) => props.version?.onSelect(id as DocsVersion), + } + : { label: "Docs version", items: defaultVersions, current: "latest" }, + }))} + current={props.current} + onSelect={props.onSelect} + split={{ label: "Switch docs", onSelect: props.onSelect }} + /> + {/* Only the main docs have versions, and only an older one shows here. */} + + {(version) => ( + <> + + docsVersions.find((item) => item.id === id)!.label} + triggerLabel={(id) => `${docsVersions.find((item) => item.id === id)!.label}, switch docs version`} + items={versionItems(version())} + current={version().current} + onSelect={(id) => version().onSelect(id as DocsVersion)} + /> + + )} + +
+ ) + if (props.inline) return lockup() return ( {(mount) => ( @@ -89,54 +149,7 @@ export function DocsLockup(props: { queueMicrotask(() => mount.prepend(element)) }} > -
- name(label)} - triggerLabel={(label) => `${name(label)}, switch docs`} - items={sections().map((product) => ({ - id: product.label, - label: product.label, - ariaLabel: name(product.label), - href: props.href?.(product.label) ?? product.href, - sub: - product.label !== "Docs" - ? undefined - : props.version - ? { - label: "Docs version", - items: versionItems(props.version), - current: props.version.current, - onSelect: (id: string) => props.version?.onSelect(id as DocsVersion), - } - : { label: "Docs version", items: defaultVersions, current: "latest" }, - }))} - current={props.current} - onSelect={props.onSelect} - split={{ label: "Switch docs", onSelect: props.onSelect }} - /> - {/* Only the main docs have versions, and only an older one shows here. */} - - {(version) => ( - <> - - docsVersions.find((item) => item.id === id)!.label} - triggerLabel={(id) => `${docsVersions.find((item) => item.id === id)!.label}, switch docs version`} - items={versionItems(version())} - current={version().current} - onSelect={(id) => version().onSelect(id as DocsVersion)} - /> - - )} - -
+ {lockup()} )}
@@ -307,145 +320,138 @@ function Dropdown(props: { )}
- - + )} + + )} + + ) } diff --git a/services/site/src/component/site/docs-variants.css b/services/site/src/component/site/docs-variants.css index f652acf3e613..2d2aed503e2c 100644 --- a/services/site/src/component/site/docs-variants.css +++ b/services/site/src/component/site/docs-variants.css @@ -233,7 +233,7 @@ li { position: relative; margin-bottom: 0.375rem; - padding-left: 1.75rem; + padding-inline-start: 1.75rem; counter-increment: item; } @@ -248,7 +248,7 @@ input { accent-color: var(--text-strong); - margin-right: 0.5rem; + margin-inline-end: 0.5rem; } } } @@ -304,16 +304,16 @@ :is(:is(ul, ol):not([data-component], [data-slot]), ul[data-slot="tasks"], [data-component="downloads"]) > li { --marker-line: 1lh; position: relative; - padding-left: var(--marker-column); + padding-inline-start: var(--marker-column); } :is(ul:not([data-component], [data-slot]), [data-component="downloads"]) > li::before, ol:not([data-component], [data-slot]) > li::before, ul[data-slot="tasks"] > li > input { position: absolute; - left: calc(var(--marker-column) / 2); + inset-inline-start: calc(var(--marker-column) / 2); top: calc(var(--marker-line) / 2); - translate: -50% -50%; + translate: calc(-50% * var(--x-dir, 1)) -50%; margin: 0; } @@ -424,8 +424,8 @@ [data-page="docs"][data-docs-variants~="blockquote-2"] [data-component="docs-article"] blockquote { margin: 0 0 1.5rem; - padding-left: 1rem; - border-left: 2px solid var(--text-muted); + padding-inline-start: 1rem; + border-inline-start: 2px solid var(--text-muted); font-weight: 500; color: var(--text-weak); @@ -561,7 +561,7 @@ [data-page="docs"][data-docs-variants~="callout-3"] [data-component="docs-article"] [data-component="callout"] { padding: 1rem; - border-left: 3px solid var(--callout-rule); + border-inline-start: 3px solid var(--callout-rule); background: color-mix(in srgb, var(--callout-rule) 7%, transparent); /* The text is body copy (Typography 4's body size, line height and colour), never the lead. */ @@ -634,7 +634,8 @@ [data-docs-variants~="tabs-2"], [data-docs-variants~="tabs-3"], [data-docs-variants~="tabs-4"], - [data-docs-variants~="tabs-5"] + [data-docs-variants~="tabs-5"], + [data-docs-variants~="tabs-6"] ) [data-component="docs-article"] [data-component="plan-tabs"] { @@ -764,6 +765,38 @@ } } +/* With the Vercel square code tabs, plan tabs (which switch prose, not code) take the code tabs' + label: OpenTUI Mono, muted until selected, with the 2px ink underline and an inside focus ring. */ +[data-page="docs"][data-docs-variants~="tabs-6"] [data-component="docs-article"] [data-component="plan-tabs"] { + [role="tablist"] { + overflow-x: auto; + scrollbar-width: none; + font-family: var(--font-mono); + } + + [role="tab"] { + flex-shrink: 0; + color: var(--text-weak); + transition: color 150ms ease; + + @media (hover: hover) and (pointer: fine) { + &:hover { + color: var(--text-strong); + } + } + + &[aria-selected="true"] { + color: var(--text-strong); + -webkit-text-stroke: var(--title-stroke); + } + + &:focus-visible { + outline: 2px solid var(--link); + outline-offset: -2px; + } + } +} + /* ───────────── Code block (plain pre) ───────────── From v2's pre (1px border, 0.875rem 1rem, 13px). 2 · v2 · 3 · v2 on a tinted surface 4 · rules above and below only · 5 · a 2px left rule, no box */ @@ -1270,7 +1303,8 @@ [data-component="docs-article"] [data-component="steps"] > li { - padding: 0 0 1.25rem 2.75rem; + padding-block: 0 1.25rem; + padding-inline: 2.75rem 0; &:last-child { padding-bottom: 0; @@ -1279,7 +1313,7 @@ &::before { content: counter(step); position: absolute; - left: 0; + inset-inline-start: 0; top: 0; width: 1.75rem; height: 1.75rem; @@ -1296,7 +1330,7 @@ &:not(:last-child)::after { content: ""; position: absolute; - left: calc(0.875rem - 0.5px); + inset-inline-start: calc(0.875rem - 0.5px); top: 2.25rem; bottom: 0.5rem; width: 1px; @@ -1372,15 +1406,31 @@ [data-docs-variants~="cards-4"], [data-docs-variants~="cards-5"] ) - [data-component="docs-article"] + [data-component="docs-article"] { [data-component="card-group"] { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); - gap: 0.75rem; - margin: 0 0 1.5rem; + display: grid; + grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); + gap: 0.75rem; + margin: 0 0 1.5rem; + + /* CardGroup cols={n} sets the column count; phones stack. */ + &[style*="--card-columns"] { + grid-template-columns: repeat(var(--card-columns), minmax(0, 1fr)); + + @media (max-width: 40rem) { + grid-template-columns: minmax(0, 1fr); + } + } + > [data-component="docs-card"] { + margin: 0; + } + } + + /* A card on its own, outside a group, is spaced like any block. */ [data-component="docs-card"] { display: block; + margin: 0 0 1.5rem; padding: 1rem; border: 1px solid var(--border); color: var(--text-strong); @@ -1408,11 +1458,7 @@ } } -[data-page="docs"][data-docs-variants~="cards-3"] - [data-component="docs-article"] - [data-component="card-group"] - [data-component="docs-card"] - strong { +[data-page="docs"][data-docs-variants~="cards-3"] [data-component="docs-article"] [data-component="docs-card"] strong { font-family: var(--font-mono); font-size: var(--anno-size); letter-spacing: var(--anno-track); @@ -1474,9 +1520,10 @@ font-size: var(--fs-meta); :is(th, td) { - padding: 0.5rem 1rem 0.5rem 0; + padding-block: 0.5rem; + padding-inline: 0 1rem; border-bottom: 1px solid var(--border); - text-align: left; + text-align: start; vertical-align: top; } @@ -1677,13 +1724,14 @@ summary { --padding-top: 0.875rem; - padding: var(--padding-top) 3rem 0.875rem 1rem; + padding-block: var(--padding-top) 0.875rem; + padding-inline: 1rem 3rem; &::before, &::after { content: ""; position: absolute; - right: 1rem; + inset-inline-end: 1rem; top: calc(var(--padding-top) + 0.5lh - 0.5px); width: 12px; height: 1px; @@ -2070,9 +2118,10 @@ } :is(th, td) { - padding: 0.5rem 1rem 0.5rem 0; + padding-block: 0.5rem; + padding-inline: 0 1rem; border-bottom: 1px solid var(--border); - text-align: left; + text-align: start; vertical-align: top; } @@ -2148,7 +2197,7 @@ a[rel="next"] { grid-column: 2; - text-align: right; + text-align: end; } small { @@ -2758,7 +2807,8 @@ justify-content: space-between; gap: 1rem; height: 2.5rem; - padding: 0 0.375rem 0 1rem; + padding-block: 0; + padding-inline: 1rem 0.375rem; border-bottom: 1px solid var(--code-border); background: var(--code-head); font: 400 var(--fs-micro, 12px) / 1 var(--font-mono); @@ -2808,7 +2858,7 @@ [data-slot="code-copy"] { flex-shrink: 0; height: 2.5rem; - margin-right: -0.375rem; + margin-inline-end: -0.375rem; padding: 0 0.75rem; } @@ -3131,7 +3181,8 @@ [data-slot="tabs"] { gap: 0; height: 2.5rem; - padding: 0 6.5rem 0 0; + padding-block: 0; + padding-inline: 0 6.5rem; align-items: stretch; border-bottom: 1px solid var(--code-border); background: var(--code-head); @@ -3150,7 +3201,7 @@ /* The first tab starts at the block's edge, so its underline does too; its 1rem of padding puts the label over the code's first column. */ &:first-child { - padding-left: 1rem; + padding-inline-start: 1rem; } &[aria-selected="true"] { @@ -3203,10 +3254,10 @@ [data-slot="copy"] { position: absolute; top: 0; - right: 0; + inset-inline-end: 0; height: calc(2.5rem - 1px); background: var(--code-head); - box-shadow: -1.25rem 0 1rem -0.5rem var(--code-head); + box-shadow: calc(-1.25rem * var(--x-dir, 1)) 0 1rem -0.5rem var(--code-head); min-width: 0; margin: 0; padding: 0 0.75rem; @@ -3326,7 +3377,12 @@ } [data-page="docs"] [data-slot="tree-row"] [data-slot="file-icon"] { - margin-right: 0.375rem; + margin-inline-end: 0.375rem; +} + +/* A note after a name in a file tree ("loaded initially"), in the label grey. */ +[data-page="docs"] [data-slot="tree-note"] { + color: var(--code-label); } [data-site][data-theme="dark"] [data-slot="file-icon"] { @@ -3419,6 +3475,10 @@ &[data-method="delete"] { color: light-dark(hsl(0, 65%, 42%), #e67c7c); } + + &:is([data-method="put"], [data-method="patch"]) { + color: light-dark(hsl(35, 80%, 30%), #e0af68); + } } > [data-slot="api-body"] { @@ -3474,9 +3534,10 @@ line-height: 1.55; th { - padding: 0 1rem 0.5rem 0; + padding-block: 0 0.5rem; + padding-inline: 0 1rem; border-bottom: 1px solid var(--code-border); - text-align: left; + text-align: start; font: 400 var(--fs-micro, 12px) / 1.4 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; @@ -3486,9 +3547,10 @@ } td { - padding: 0.75rem 1rem 0.75rem 0; + padding-block: 0.75rem; + padding-inline: 0 1rem; border-bottom: 1px solid var(--code-border); - text-align: left; + text-align: start; vertical-align: baseline; color: var(--text); } @@ -3498,7 +3560,7 @@ } :is(th, td):last-child { - padding-right: 0; + padding-inline-end: 0; } td > code { @@ -3895,6 +3957,49 @@ } } +/* Code tabs blend the same way: the border and the tab row's fill on blended layers, the tabs and + Copy above them, and Copy loses its solid header fill (the row behind it is the blend). */ +[data-page="docs"] + [data-component="callout"]:not(:is([data-blend="fixed"], [data-blend="a"], [data-blend="b"], [data-blend="d"]) *) + [data-component="code-tabs"] { + border-color: transparent; + background: transparent; + + &::before { + content: ""; + position: absolute; + inset: -1px; + border: 1px solid var(--code-border); + mix-blend-mode: var(--blend); + pointer-events: none; + } + + [data-slot="tabs"] { + position: relative; + border-bottom-color: transparent; + background: transparent; + + &::before { + content: ""; + position: absolute; + inset: 0 0 -1px; + border-bottom: 1px solid var(--code-border); + background: var(--code-head); + mix-blend-mode: var(--blend); + pointer-events: none; + } + + > button { + position: relative; + } + } + + [data-slot="copy"] { + background: transparent; + box-shadow: none; + } +} + [data-page="docs"] [data-blend="d"] :is([data-component="callout"], [data-slot="blend-plain"]) { --blend-surface: color-mix(in srgb, var(--callout-rule) 7%, var(--bg)); --blend-rule: light-dark( diff --git a/services/site/src/component/site/file-type-icon.tsx b/services/site/src/component/site/file-type-icon.tsx index 73ca4d684b4c..8d6963b32de6 100644 --- a/services/site/src/component/site/file-type-icon.tsx +++ b/services/site/src/component/site/file-type-icon.tsx @@ -24,14 +24,15 @@ export function FileTypeIcon(props: { path: string; directory?: boolean }) { /** * A file tree from "├── name" lines, each file and folder with its icon; folders end in "/". Each * row carries its depth (--depth, one per four prefix characters) and whether it's a folder, so the - * minimal File tree options can drop the box-drawing prefix and indent or draw guides instead. + * minimal File tree options can drop the box-drawing prefix and indent or draw guides instead. A note + * after a name (two spaces or "←" on) shows after it, muted. */ export function FileTree(props: { tree: string }) { const rows = () => props.tree.split("\n").map((line) => { const at = line.search(/[^│├└─\s]/) - const name = line.slice(at) - return { prefix: line.slice(0, at), name, directory: name.endsWith("/"), depth: Math.round(at / 4) } + const [, name, note] = line.slice(at).match(/^(.*?)((?:\s{2,}|\s+←).*)?$/) ?? ["", line, undefined] + return { prefix: line.slice(0, at), name, note, directory: name.endsWith("/"), depth: Math.round(at / 4) } }) return (
@@ -41,6 +42,7 @@ export function FileTree(props: { tree: string }) {
             {row.prefix}
             
             {row.name}
+            {(note) => {note()}}
             {index() < rows().length - 1 ? "\n" : ""}
           
         )}
diff --git a/services/site/src/component/site/github-link.tsx b/services/site/src/component/site/github-link.tsx
index 9c09d9b4d920..1df9ee1a4622 100644
--- a/services/site/src/component/site/github-link.tsx
+++ b/services/site/src/component/site/github-link.tsx
@@ -1,19 +1,18 @@
 import "./github-link.css"
+import { config } from "~/config"
 import { useI18n } from "~/context/i18n"
-import { useLanguage } from "~/context/language"
 import { GitHubMark } from "./icons"
-import { siteLinks } from "./links"
 
 /**
  * The repo, as a GitHub mark: fixed in the top-right corner beside the sidebar (and at every width on
- * bare pages), in the top bar on small screens (site.tsx), and in the 404 arcade's phone bar.
+ * bare pages), in the top bar on small screens (site.tsx), and in the 404 arcade's phone bar. It needs
+ * no router, so the docs render it too.
  */
 export function GitHubLink(props: { owner: "corner" | "topbar" }) {
   const i18n = useI18n()
-  const language = useLanguage()
   return (
     
+      `@font-face { font-family: "Inter"; src: local("Inter"), local("Inter Variable"), url(${url}) format("woff2"); font-weight: 100 900; font-display: optional; unicode-range: ${range}; }`,
+  )
+  .join("\n")
diff --git a/services/site/src/component/site/on-this-page.tsx b/services/site/src/component/site/on-this-page.tsx
index 8e933e14553c..0df55903728d 100644
--- a/services/site/src/component/site/on-this-page.tsx
+++ b/services/site/src/component/site/on-this-page.tsx
@@ -190,7 +190,8 @@ export function SectionHeading(props: { level?: 2 | 3; id: string; title: string
 /**
  * The inside of a heading: a button with the title that copies the section's address and puts it in
  * the address bar, then says "Link copied" for a moment (also to screen readers). `children` replaces
- * the plain title for headings with markup of their own.
+ * the plain title for headings with markup of their own. Pages that never hydrate (the docs) do the
+ * same from a delegated listener keyed on `data-heading-id` (src/docs/client.ts).
  */
 export function HeadingLink(props: { id: string; title: string; children?: JSX.Element }) {
   const i18n = useI18n()
@@ -202,6 +203,7 @@ export function HeadingLink(props: { id: string; title: string; children?: JSX.E
       
-      
+      
         {copied() ? i18n.t("changelog.share.copied") : ""}
       
     
diff --git a/services/site/src/component/site/preload-settings.ts b/services/site/src/component/site/preload-settings.ts
index 0cb9e4eb464e..9b5900839583 100644
--- a/services/site/src/component/site/preload-settings.ts
+++ b/services/site/src/component/site/preload-settings.ts
@@ -235,7 +235,7 @@ export const themeScript = (settings: boolean) =>
  * The site root's settings attributes with the default settings, the only values production
  * renders (Settings and Design mode are development tools): `null` for an attribute it leaves off.
  * script/css-variants.ts writes them to css-variants.json, from which the production build drops the
- * CSS for every other value (vite.config.ts); test/css-variants.test.ts keeps the file current.
+ * CSS for every other value (script/css-variants-plugin.ts); test/css-variants.test.ts keeps the file current.
  */
 export function defaultRootAttributes() {
   // The root as production renders it: every settings attribute present, docs variants not fixed.
diff --git a/services/site/src/component/site/search-index.ts b/services/site/src/component/site/search-index.ts
index 8b3a485d918f..2cd552a7c914 100644
--- a/services/site/src/component/site/search-index.ts
+++ b/services/site/src/component/site/search-index.ts
@@ -10,7 +10,9 @@ import { brandContent, brandMarkdown } from "~/lib/brand-content"
 import { brandAssets } from "~/lib/media"
 import type { ChangelogRelease } from "~/lib/changelog"
 import { changelogTimeline } from "~/lib/changelog-notes"
-import { docsConfigure, docsIntro, docsPages, docsProducts, docsToc } from "~/lib/docs-content"
+import { docsHref, docsSections } from "~/docs/lib/navigation"
+import { v1DocsUrl } from "~/lib/docs"
+import { docsIntro, docsToc } from "~/lib/docs-content"
 import { downloadContent } from "~/lib/download-content"
 import { fontContent } from "~/lib/font-content"
 import { homeContent } from "~/lib/home-content"
@@ -229,11 +231,8 @@ export function buildSearchIndex(
       }),
     )
 
-  const docsPath = (href: string) => new URL(href, "https://opencode.ai").pathname
-  // Only the docs Intro is a page of this site (routes/docs); the other docs pages are the live
-  // v2 docs, served at the same paths on opencode.ai. Linking them absolutely makes them a full
-  // page load there and a new tab from a preview or local build, where those paths don't exist.
-  const liveDocs = (href: string) => (href === docsPages[0].href ? route(href) : `${config.baseUrl}${href}`)
+  // Every docs page (src/docs/lib/navigation.ts), served by this Worker at /docs, so they open in
+  // place on any deployment. The docs are English, so their links never take a locale prefix.
   const docs: SearchItem[] = [
     ...docsToc.map((entry) => ({
       id: `docs:intro#${entry.id}`,
@@ -241,27 +240,30 @@ export function buildSearchIndex(
       title: entry.label,
       context: "Docs › Intro",
       body: docsBody(entry.id),
-      href: `${route(docsPages[0].href)}#${entry.id}`,
+      href: `${docsHref("index")}#${entry.id}`,
       target: { id: entry.id },
     })),
-    ...[...docsPages, ...docsConfigure].map((page) => ({
-      id: `docs:${page.href}`,
+    ...docsSections.flatMap((section) =>
+      section.groups.flatMap((group) =>
+        group.items.map((item) => ({
+          id: `docs:${item.slug}`,
+          group: "Docs" as const,
+          // A section's first page is its intro: "CLI docs" rather than a second "Intro".
+          title: item.slug === section.landingSlug && section.key !== "docs" ? `${section.title} docs` : item.title,
+          context: docsHref(item.slug),
+          body: item.slug === "index" ? docsIntro.lead : undefined,
+          href: docsHref(item.slug),
+        })),
+      ),
+    ),
+    {
+      id: "docs:v1",
       group: "Docs" as const,
-      title: page.label,
-      context: docsPath(page.href),
-      body: page.label === "Intro" ? docsIntro.lead : undefined,
-      href: liveDocs(page.href),
-    })),
-    ...docsProducts
-      .filter((product) => product.label !== "Docs")
-      .map((product) => ({
-        id: `docs:${product.href}`,
-        group: "Docs" as const,
-        title: product.label === "V1" ? "V1 docs" : `${product.label} docs`,
-        context: docsPath(product.href),
-        keywords: product.label === "V1" ? "v1 legacy old docs" : undefined,
-        href: product.href.startsWith("/") ? liveDocs(product.href) : product.href,
-      })),
+      title: "V1 docs",
+      context: v1DocsUrl(),
+      keywords: "v1 legacy old docs",
+      href: v1DocsUrl(),
+    },
   ]
 
   const actions: SearchItem[] = [
diff --git a/services/site/src/component/site/search-palette.tsx b/services/site/src/component/site/search-palette.tsx
index 85bcf94b887b..b975e1571f88 100644
--- a/services/site/src/component/site/search-palette.tsx
+++ b/services/site/src/component/site/search-palette.tsx
@@ -557,7 +557,7 @@ export function SearchPalette(props: SiteSearchProps & { openOnMount?: SearchVia
  * panel also tones the page behind it into a narrow band next to the panel colour, so the panel stays
  * at least 97% white (dark: at most 12%) over any page, which keeps its text at 4.5:1 or more.
  */
-function searchLook(s: SiteSettings) {
+export function searchLook(s: SiteSettings) {
   const alpha = s.searchPanelOpacity / 100
   const blur = alpha < 1 && s.searchPanelBlur > 0 ? `blur(${s.searchPanelBlur}px)` : ""
   // Light: map the page's 0–1 onto lo–1 with contrast(c) then brightness(b), in sRGB like compositing.
diff --git a/services/site/src/component/site/site-controls.tsx b/services/site/src/component/site/site-controls.tsx
new file mode 100644
index 000000000000..a4a80e24307c
--- /dev/null
+++ b/services/site/src/component/site/site-controls.tsx
@@ -0,0 +1,85 @@
+import { For } from "solid-js"
+import { useI18n } from "~/context/i18n"
+import { ThemeIcon, themes } from "./icons"
+
+// Small pieces of the site's chrome that need no router or settings, so pages that render on the
+// server and never hydrate (the docs) use them too.
+
+/** "[ ]" with a dash that appears on hover or for the current item, as in the footer list. */
+export function Bracket() {
+  return (
+