GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(site): simplify the docs header menu and move the V1 notice into… · drpr/opencode@1df721d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • services/site/src
    • component/site
      • css-variants.json
      • docs-lockup.css
      • docs-lockup.tsx
      • docs-version-notice.tsx
      • settings-defaults.json
      • settings.ts
    • docs
      • client.ts
      • layouts
        • DocsLayout.tsx
      • styles
        • docs.css
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎services/site/src/component/site/css-variants.json‎

Copy file name to clipboardExpand all lines: services/site/src/component/site/css-variants.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"data-menu-align": "edge",
1717
"data-wide-align": null,
1818
"data-nav-numbers": "1",
19-
"data-docs-nav": "split",
19+
"data-docs-nav": "combined",
2020
"data-section-menu": "list",
2121
"data-docs-variants": "typography-4 lists-3 blockquote-2 callout-3 tabs-6 code-6 codeTitle-6 codeLines-6 codeDiff-6 terminal-6 fileTree-6 steps-2 cards-3 tables-5 badges-4 details-2 media-2 api-7 config-6 cli-6 pagination-4 breadcrumbs-3 search-4 switchers-2 editLink-4 feedback-5 inlineCode-6",
2222
"data-status-bars": "4",
@@ -41,7 +41,7 @@
4141
["[data-component=\"hero-install\"][data-mode=\"row\"]", "data-style", "inline"],
4242
["[data-component=\"hero\"][data-design~=\"hero\"]", "data-title-size", "fitted"],
4343
["[data-component=\"page-title\"]", "data-sticky", null],
44-
["[data-component=\"docs-version-notice\"]", "data-variant", "frosted top"],
44+
["[data-component=\"docs-version-notice\"]", "data-variant", "inverted"],
4545
["[data-component=\"products\"]", "data-tone", "color"],
4646
["[data-component=\"badges\"]", "data-style", "sans"],
4747
["[data-component=\"badges\"]", "data-layout", "tabs"],
Collapse file

‎services/site/src/component/site/docs-lockup.css‎

Copy file name to clipboardExpand all lines: services/site/src/component/site/docs-lockup.css
+2-17Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
position: relative;
5757
display: inline-flex;
5858
align-items: center;
59-
gap: 6px;
59+
/* Label and chevron are one button, so the chevron sits close, as in the product navs. */
60+
gap: 4px;
6061

6162
/* OpenTUI Mono's caps sit 0.325px below its line box's centre; this puts them on the logo's centre. */
6263
padding: 0 6px 0.65px;
@@ -439,22 +440,6 @@
439440
}
440441
}
441442

442-
/* The section word also opens the OpenCode product menu on hover (packages/nav-menus), so hovered, open and pressed it
443-
takes the one name fill every OpenCode nav shares (--nav-name-hover), never a darker one; the chevron keeps its own
444-
states for the sections menu. */
445-
[data-site] [data-component="docs-lockup"] [data-slot="word"][data-nav-product] {
446-
@media (hover: hover) and (pointer: fine) {
447-
&:hover {
448-
background: var(--nav-name-hover);
449-
}
450-
}
451-
452-
&:active,
453-
&[aria-expanded="true"] {
454-
background: var(--nav-name-hover);
455-
}
456-
}
457-
458443
/* The logo before the lockup stays a plain link (no fill); its keyboard ring, drawn around the mark
459444
(site.css), is 2px like the segments'. */
460445
[data-site]
Collapse file

‎services/site/src/component/site/docs-lockup.tsx‎

Copy file name to clipboardExpand all lines: services/site/src/component/site/docs-lockup.tsx
+22-37Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ type Item = {
4040
/**
4141
* Settings › Docs switcher › lockup: the docs section word after the site's logo, like the Data and
4242
* Console headers (public/nav-demo/switcher.js). One button opens a menu of the docs sections, where
43-
* "Docs" has a submenu of versions. On an older version, "/ V1" after the word shows it and switches
44-
* back. The menus are always in the page, hidden while closed, so pages that never hydrate (the docs)
43+
* "Docs" has a submenu of versions. On the V1 docs the word reads "V1 docs" and the same menu marks V1
44+
* under "Docs". The menus are always in the page, hidden while closed, so pages that never hydrate (the docs)
4545
* can open them from a delegated listener (src/docs/client.ts).
4646
*/
4747
export function DocsLockup(props: {
@@ -63,10 +63,18 @@ export function DocsLockup(props: {
6363
}
6464
}) {
6565
const i18n = useI18n()
66+
// On the V1 docs the product name says so: "V1 docs", with the same chevron and menu as the latest docs.
67+
const v1 = () => props.version?.current === "v1"
6668
const name = (label: string) =>
67-
label === "Docs"
68-
? docsSectionName(i18n, label)
69-
: i18n.t("docs.lockup.sectionDocs", { section: docsSectionName(i18n, label) })
69+
v1()
70+
? i18n.t("docs.lockup.sectionDocs", { section: "V1" })
71+
: label === "Docs"
72+
? docsSectionName(i18n, label)
73+
: i18n.t("docs.lockup.sectionDocs", { section: docsSectionName(i18n, label) })
74+
// The sections menu names each section's docs: "CLI docs", "API docs". The main docs are about OpenCode
75+
// itself, so they're "OpenCode docs" rather than "Docs docs".
76+
const menuName = (label: string) =>
77+
i18n.t("docs.lockup.sectionDocs", { section: label === "Docs" ? "OpenCode" : docsSectionName(i18n, label) })
7078
// V1 is a version, not a section: "Docs" has a submenu of versions, V2 (these docs) and V1 (the old
7179
// docs site). The /docs demo can pass its own (?version= switches in place).
7280
const sections = () => docsProducts.filter((product) => product.label !== "V1")
@@ -115,8 +123,8 @@ export function DocsLockup(props: {
115123
triggerLabel={(label) => i18n.t("docs.lockup.switchLabel", { name: name(label) })}
116124
items={sections().map((product) => ({
117125
id: product.label,
118-
label: docsSectionName(i18n, product.label),
119-
ariaLabel: name(product.label),
126+
label: menuName(product.label),
127+
ariaLabel: menuName(product.label),
120128
href: props.href?.(product.label) ?? product.href,
121129
sub:
122130
product.label !== "Docs"
@@ -132,30 +140,8 @@ export function DocsLockup(props: {
132140
}))}
133141
current={props.current}
134142
onSelect={props.onSelect}
135-
split={{ label: i18n.t("docs.lockup.switch"), onSelect: props.onSelect }}
143+
split={{ label: i18n.t("docs.lockup.switch"), onSelect: props.onSelect, href: v1() ? v1DocsUrl() : undefined }}
136144
/>
137-
{/* Only the main docs have versions, and only an older one shows here. */}
138-
<Show when={props.current === "Docs" && props.version?.current !== "latest" && props.version}>
139-
{(version) => (
140-
<>
141-
<span data-slot="separator" aria-hidden="true">
142-
|
143-
</span>
144-
<Dropdown
145-
id={`docs-version-menu${suffix}`}
146-
variant="version"
147-
menuLabel={i18n.t("docs.version.label")}
148-
trigger={(id) => docsVersions.find((item) => item.id === id)!.label}
149-
triggerLabel={(id) =>
150-
i18n.t("docs.version.switch", { version: docsVersions.find((item) => item.id === id)!.label })
151-
}
152-
items={versionItems(version())}
153-
current={version().current}
154-
onSelect={(id) => version().onSelect(id as DocsVersion)}
155-
/>
156-
</>
157-
)}
158-
</Show>
159145
</div>
160146
)
161147
if (props.inline) return lockup()
@@ -186,8 +172,11 @@ function Dropdown(props: {
186172
items: Item[]
187173
current: string
188174
onSelect?: (id: string) => void
189-
/** Settings › Docs nav › split: the word links to the section's home; `label` names the chevron. */
190-
split?: { label: string; onSelect?: (id: string) => void }
175+
/**
176+
* Settings › Docs nav › split: the word links to the section's home (or `href`, the V1 docs' home);
177+
* `label` names the chevron.
178+
*/
179+
split?: { label: string; onSelect?: (id: string) => void; href?: string }
191180
}) {
192181
const i18n = useI18n()
193182
const [open, setOpen] = createSignal(false)
@@ -323,11 +312,7 @@ function Dropdown(props: {
323312
<a
324313
data-slot="word"
325314
data-design="docsNav sectionMenuStyle menuActive menuColor menuAlign docsSubmenu"
326-
href={props.items[currentIndex()].href}
327-
data-nav-product="docs"
328-
data-nav-product-chevron="none"
329-
aria-haspopup="menu"
330-
aria-expanded="false"
315+
href={split().href ?? props.items[currentIndex()].href}
331316
aria-label={i18n.t("docs.lockup.home", { name: props.trigger(props.items[currentIndex()].id) })}
332317
onClick={(event) => {
333318
close()
Collapse file

‎services/site/src/component/site/docs-version-notice.tsx‎

Copy file name to clipboard
+24-3Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
import "./docs-version-notice.css"
22
import { useI18n } from "~/context/i18n"
3+
import { Show } from "solid-js"
34
import { siteSettings } from "./settings"
45

5-
/** On the V1 docs: a bar at the top of the content column, with a way back to the latest docs. */
6-
export function DocsVersionNotice(props: { latest: string; onLatest?: () => void }) {
6+
/**
7+
* On the V1 docs: a bar with a way back to the latest docs, at the top of the content column, or in the
8+
* logo row (`placement="header"`, the docs), where the sentence shortens with "…" before the link does.
9+
* On phones the header placement is a bar on the screen's bottom edge saying only "V1 docs" (docs.css).
10+
*/
11+
export function DocsVersionNotice(props: { latest: string; onLatest?: () => void; placement?: "header" }) {
712
const i18n = useI18n()
813
return (
914
<aside
1015
data-component="docs-version-notice"
1116
data-variant={siteSettings.docsVersionNotice}
1217
data-design="docsVersionNotice"
18+
data-placement={props.placement}
1319
aria-label={i18n.t("docs.version.label")}
1420
>
1521
<span data-slot="badge">V1</span>
22+
<Show when={props.placement}>
23+
<span data-slot="short">{i18n.t("docs.version.v1Docs")}</span>
24+
</Show>
1625
<p>
17-
{i18n.t("docs.version.notice")}{" "}
26+
<span data-slot="sentence">{i18n.t("docs.version.notice")}</span>{" "}
1827
<a
1928
href={props.latest}
2029
onClick={(event) => {
@@ -24,8 +33,20 @@ export function DocsVersionNotice(props: { latest: string; onLatest?: () => void
2433
}}
2534
>
2635
{i18n.t("docs.version.switchToLatest")}
36+
<Show when={props.placement}>
37+
<LinkChevron />
38+
</Show>
2739
</a>
2840
</p>
2941
</aside>
3042
)
3143
}
44+
45+
/** The 16px chevron after the logo row's links, toward the reading direction (mirrored in RTL by CSS). */
46+
export function LinkChevron() {
47+
return (
48+
<svg data-slot="link-chevron" width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
49+
<path d="M6 4L10 8L6 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="square" />
50+
</svg>
51+
)
52+
}
Collapse file

‎services/site/src/component/site/settings-defaults.json‎

Copy file name to clipboardExpand all lines: services/site/src/component/site/settings-defaults.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@
352352
"consoleCopyColumns": "2 columns",
353353
"docsSwitcher": "lockup",
354354
"docsSubmenu": "flyout",
355-
"docsNav": "split",
356-
"docsVersionNotice": "frosted top",
355+
"docsNav": "combined",
356+
"docsVersionNotice": "inverted",
357357
"terminalInstall": "button",
358358
"carouselPreset": "four across",
359359
"carousel": {
Collapse file

‎services/site/src/component/site/settings.ts‎

Copy file name to clipboardExpand all lines: services/site/src/component/site/settings.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,8 @@ function createSchema() {
10511051
consoleCopyColumns: z.enum(sectionColumns).catch("2 columns"),
10521052
docsSwitcher: z.enum(docsSwitchers).catch("lockup"),
10531053
docsSubmenu: z.enum(docsSubmenus).catch("flyout"),
1054-
docsNav: z.enum(docsNavs).catch("split"),
1055-
docsVersionNotice: z.enum(docsVersionNotices).catch("frosted top"),
1054+
docsNav: z.enum(docsNavs).catch("combined"),
1055+
docsVersionNotice: z.enum(docsVersionNotices).catch("inverted"),
10561056
terminalInstall: z.enum(terminalInstalls).catch("button"),
10571057
carouselPreset: z.enum(carouselPresetNames).catch("four across"),
10581058
carousel: z
Collapse file

‎services/site/src/docs/client.ts‎

Copy file name to clipboardExpand all lines: services/site/src/docs/client.ts
+30-2Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ function enter(menu: HTMLElement) {
128128
menu.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 140, easing: "ease-out" })
129129
}
130130

131+
// The versions flyout appears softly beside "Docs": a 140ms fade with a 3px nudge from the row it opens
132+
// from, on the strong ease-out, transform and opacity only. Only its first showing in an open menu
133+
// animates; coming back to "Docs" shows it at once, and it hides at once. Reduced motion shows it at once.
134+
let flown = false
135+
function flyIn(submenu: HTMLElement) {
136+
if (flown || matchMedia("(prefers-reduced-motion: reduce)").matches) return
137+
flown = true
138+
const from = `translateX(${html.dir === "rtl" ? 3 : -3}px)`
139+
submenu.animate(
140+
[
141+
{ opacity: 0, transform: from },
142+
{ opacity: 1, transform: "translateX(0)" },
143+
],
144+
{ duration: 140, easing: "cubic-bezier(0.23, 1, 0.32, 1)" },
145+
)
146+
}
147+
131148
// The docs lockup (component/site/docs-lockup.tsx): the chevron opens the sections menu, where "Docs"
132149
// has its versions in a flyout beside it, or nested under it on phones and touch screens. An older
133150
// version adds a second menu, of the versions, so each dropdown in it opens on its own.
@@ -177,6 +194,7 @@ function openLockup(root: HTMLElement, focus?: "first" | "last" | "current") {
177194
}
178195

179196
function closeLockup(refocus?: boolean) {
197+
flown = false
180198
if (!lockup) return
181199
const root = lockup
182200
lockup = undefined
@@ -185,7 +203,10 @@ function closeLockup(refocus?: boolean) {
185203
$$("[aria-haspopup=menu]:not([role=menuitem], [data-nav-product])", root).forEach((button) =>
186204
button.setAttribute("aria-expanded", "false"),
187205
)
188-
if (refocus) ($("[data-slot=toggle]", root) ?? $("[data-slot=trigger]", root))?.focus()
206+
if (refocus)
207+
$$("[data-slot=toggle], [data-slot=trigger]", root)
208+
.find((button) => button.offsetParent)
209+
?.focus()
189210
}
190211

191212
function toggleSub(root: HTMLElement, open: boolean, focus?: boolean) {
@@ -196,7 +217,7 @@ function toggleSub(root: HTMLElement, open: boolean, focus?: boolean) {
196217
parent.toggleAttribute("data-open", open)
197218
const submenu = $("[data-slot=submenu]", parent)!
198219
submenu.hidden = !open
199-
if (opening && menuOf(root).dataset.submenu === "flyout") enter(submenu)
220+
if (opening && menuOf(root).dataset.submenu === "flyout") flyIn(submenu)
200221
$$("[aria-expanded]", parent).forEach((item) => item.setAttribute("aria-expanded", String(open)))
201222
if (open && focus)
202223
($('[aria-current="page"]', $("[data-slot=submenu]", parent)!) ?? $("[data-slot=submenu] a", parent))?.focus()
@@ -210,6 +231,13 @@ on("click", (event) => {
210231
return lockup === root ? closeLockup() : openLockup(root)
211232
const expand = target.closest("[data-slot=expand]")
212233
if (expand) return toggleSub(root, expand.getAttribute("aria-expanded") !== "true")
234+
// Nested (phones, touch and narrow windows): tapping "Docs" opens and closes its versions in place,
235+
// like its "›", instead of leaving for the docs home, which V2 still links. The flyout keeps the link.
236+
const parent = target.closest("[data-slot=parent] > [role=menuitem]")
237+
if (parent && menuOf(root).dataset.submenu === "nested") {
238+
event.preventDefault()
239+
return toggleSub(root, parent.getAttribute("aria-expanded") !== "true")
240+
}
213241
if (target.closest("a")) closeLockup()
214242
})
215243

Collapse file

‎services/site/src/docs/layouts/DocsLayout.tsx‎

Copy file name to clipboardExpand all lines: services/site/src/docs/layouts/DocsLayout.tsx
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function DocsLayout(props: {
8383
const contents = props.headings
8484
.filter((heading) => heading.depth === 2 || heading.depth === 3)
8585
.map((heading) => ({ id: heading.slug, title: heading.text, level: heading.depth as 2 | 3 }))
86-
// The lockup's versions: this page in each (the versions menu, and "| V1" on V1 pages).
86+
// The lockup's versions: this page in each (the versions menu under "Docs"; V1 pages read "V1 docs").
8787
const version = () =>
8888
props.versions && {
8989
current: props.set.id,
@@ -187,6 +187,11 @@ export function DocsLayout(props: {
187187
</div>
188188
</div>
189189
</aside>
190+
{/* V1: the notice sits in the logo row, after the sidebar's label so it can start past a long one
191+
(docs.css); phones show it as a bar on the screen's bottom edge. */}
192+
<Show when={props.set.id === "v1" && props.versions}>
193+
{(versions) => <DocsVersionNotice latest={versions().latest} placement="header" />}
194+
</Show>
190195
{/* Mobile layout: the Contents rail folded into a bar stuck under the
191196
section row from load. It names the section being read (client.ts swaps the label as you scroll)
192197
and keeps "Contents" in its accessible name. Hidden beside the rail on wide screens. */}
@@ -213,9 +218,6 @@ export function DocsLayout(props: {
213218

214219
<main data-component="content" id="content" tabindex={-1}>
215220
<div data-slot="page">
216-
<Show when={props.set.id === "v1" && props.versions}>
217-
{(versions) => <DocsVersionNotice latest={versions().latest} />}
218-
</Show>
219221
<article
220222
data-component="docs-article"
221223
data-section="article"

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.