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): replace header product dropdown with flat docs sub-links … · erickwill/opencode@2b296ca

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • data/app/src/component
      • product-lockup.tsx
    • nav-menus
      • src
        • index.ts
        • nav-menus.css
      • test
        • nav-menus.test.ts
  • services/site/src
    • component/site
      • docs-lockup.css
      • docs-lockup.tsx
      • nav-intent.ts
      • rtl.css
      • site.css
      • tap-targets.css
    • docs
      • client.ts
      • layouts
        • DocsLayout.tsx
      • styles
        • docs.css
    • i18n
      • ar.ts
      • br.ts
      • bs.ts
      • da.ts
      • de.ts
      • en.ts
      • es.ts
      • fr.ts
      • it.ts
      • ja.ts
      • ko.ts
      • no.ts
      • pl.ts
      • ru.ts
      • stamps
        • ar.json
        • br.json
        • da.json
        • de.json
        • es.json
        • fr.json
        • it.json
        • ja.json
        • ko.json
        • no.json
        • pl.json
        • ru.json
        • th.json
        • tr.json
        • uk.json
        • zh.json
        • zht.json
      • th.ts
      • tr.ts
      • uk.ts
      • zh.ts
      • zht.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/data/app/src/component/product-lockup.tsx‎

Copy file name to clipboardExpand all lines: packages/data/app/src/component/product-lockup.tsx
+2-9Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { onCleanup, onMount } from "solid-js"
55

66
/**
77
* The OpenCode lockup, as on opencode.ai and the Console: the OpenCode mark, linking to the site's home (right-click
8-
* for the logo menu), then DATA, linking to the Data home (hover, or its chevron on touch screens, for the product
9-
* menu). The menus are the shared ones in packages/nav-menus.
8+
* for the logo menu), then DATA, linking to the Data home. The logo menu and lockup styles come from packages/nav-menus.
109
*/
1110
export function ProductLockup(props: {
1211
href: string
@@ -31,13 +30,7 @@ export function ProductLockup(props: {
3130
<path data-part="code" d="M180 60H60V240H180V60ZM240 300H0V0H240V300Z" />
3231
</svg>
3332
</a>
34-
<a
35-
data-nav-product="data"
36-
href={props.href}
37-
aria-label={props.nameLabel}
38-
aria-haspopup="menu"
39-
aria-expanded="false"
40-
>
33+
<a data-nav-name href={props.href} aria-label={props.nameLabel}>
4134
Data
4235
</a>
4336
</div>
Collapse file

‎packages/nav-menus/src/index.ts‎

Copy file name to clipboardExpand all lines: packages/nav-menus/src/index.ts
+55-162Lines changed: 55 additions & 162 deletions
Large diffs are not rendered by default.
Collapse file

‎packages/nav-menus/src/nav-menus.css‎

Copy file name to clipboardExpand all lines: packages/nav-menus/src/nav-menus.css
+14-142Lines changed: 14 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/* The OpenCode nav menus (index.ts): the logo menu and the product menu, one card style, as opencode.ai's logo menu
2-
(cards, blue hover). No panel; each item is a card on the see-through pop-up surface, its thumbnail, a divider, then
3-
its label. The menus sit in the page's body (or the top layer), so only these rules style them. A host recolours
4-
them by setting these on an ancestor of its triggers (the menu copies them when it opens):
1+
/* The OpenCode nav logo menu (index.ts) and shared header lockup: cards with blue hover, as on opencode.ai.
2+
No panel; each item is a card on the see-through pop-up surface, its thumbnail, a divider, then its label. The menu
3+
sits in the page's body (or the top layer), so only these rules style it. A host recolours it by setting these on an
4+
ancestor of its triggers (the menu copies them when it opens):
55
--nav-menu-ink strong text
66
--nav-menu-weak the labels' resting grey
77
--nav-menu-popover the pop-up surface
88
--nav-menu-link the link blue: hover and focus
9-
--nav-menu-bar the current product's bar
9+
--nav-menu-bar the active bar
1010
--nav-menu-icon the Brand, ZIP and Press drawings
1111
--nav-menu-mono OpenTUI Mono (the host loads it) */
1212
[data-nav-menu] {
@@ -49,9 +49,6 @@
4949
letter-spacing: 0;
5050
text-align: start;
5151
-webkit-font-smoothing: antialiased;
52-
/* The whole box, its padding and the gaps between cards included, is the menu: the pointer can rest or cross
53-
anywhere in it without the menu closing (index.ts closes a hover-opened menu only once the pointer has left it and
54-
its trigger for 200ms). */
5552

5653
&[data-scroll] {
5754
overflow-y: auto;
@@ -65,16 +62,6 @@
6562
pointer-events: none;
6663
}
6764

68-
/* The 1px between the name and the menu's padding counts as the menu too, so the pointer crosses it while the menu
69-
is open on hover; it stops short of the name, which stays clickable. */
70-
&[data-nav-menu="product"]::before {
71-
content: "";
72-
position: absolute;
73-
bottom: 100%;
74-
inset-inline: 0;
75-
height: 1px;
76-
}
77-
7865
[role="menuitem"] {
7966
position: relative;
8067
display: flex;
@@ -130,11 +117,6 @@
130117
&:active {
131118
scale: 0.98;
132119
}
133-
134-
/* The current product: its label at full strength, where the others rest muted. */
135-
&[aria-current="page"] {
136-
color: var(--ink);
137-
}
138120
}
139121

140122
/* The thumbnail: 38 × 28; its inline-end edge is the divider. */
@@ -192,31 +174,6 @@
192174
box-shadow: 0 0 0 1px var(--link);
193175
}
194176

195-
/* The product cards: the label alone, in capitals like the names beside the logo (the accessible names keep their
196-
case), 12px in from both edges, so each card is as wide as its label. The current product's label is at full
197-
strength, with the site's active bar on the card's leading edge, the link blue while hovered, focused or pressed. */
198-
&[data-nav-menu="product"] {
199-
[role="menuitem"] {
200-
padding-inline: 12px;
201-
}
202-
203-
[data-slot="label"] {
204-
letter-spacing: 0;
205-
text-transform: uppercase;
206-
}
207-
208-
[role="menuitem"][aria-current="page"]::before {
209-
content: "";
210-
position: absolute;
211-
top: 0;
212-
bottom: 0;
213-
inset-inline-start: -1px;
214-
z-index: 1;
215-
width: 2px;
216-
background: var(--bar);
217-
}
218-
}
219-
220177
[data-slot="meta"] {
221178
color: var(--weak);
222179
}
@@ -233,70 +190,6 @@
233190
}
234191
}
235192

236-
/* The product menu's chevron after the name, for touch screens (no hover), the same as the docs' split chevron after
237-
DOCS (services/site docs-lockup.css reads these tokens too): --nav-chevron-width wide and --nav-chevron-gap after the
238-
name's highlight, a --nav-chevron-glyph chevron that flips at once while the menu is open, a 44px tall target that
239-
reaches --nav-chevron-reach further into the empty bar, the name fill on hover and the mark's inner grey pressed or
240-
open. Hidden where a pointer can hover, where the name opens the menu. */
241-
[data-nav-product-toggle] {
242-
all: unset;
243-
position: relative;
244-
display: none;
245-
flex-shrink: 0;
246-
align-items: center;
247-
justify-content: center;
248-
box-sizing: border-box;
249-
width: var(--nav-chevron-width);
250-
height: 100%;
251-
min-height: 25px;
252-
margin-inline-start: var(--nav-chevron-gap);
253-
color: var(--nav-chevron-ink);
254-
cursor: pointer;
255-
-webkit-tap-highlight-color: transparent;
256-
transition:
257-
background-color 120ms ease,
258-
color 120ms ease;
259-
260-
&::before {
261-
content: "";
262-
position: absolute;
263-
inset-block: calc(50% - 22px);
264-
inset-inline: 0 calc(-1 * var(--nav-chevron-reach));
265-
}
266-
267-
svg {
268-
display: block;
269-
width: var(--nav-chevron-glyph);
270-
height: var(--nav-chevron-glyph);
271-
}
272-
273-
@media (hover: hover) and (pointer: fine) {
274-
&:hover {
275-
background: var(--nav-chevron-hover);
276-
color: var(--nav-menu-ink, var(--nav-chevron-ink));
277-
}
278-
}
279-
280-
&:active,
281-
&[aria-expanded="true"] {
282-
background: var(--nav-chevron-press);
283-
color: var(--nav-menu-ink, var(--nav-chevron-ink));
284-
}
285-
286-
&[aria-expanded="true"] svg {
287-
scale: 1 -1;
288-
}
289-
290-
&:focus-visible {
291-
outline: 2px solid var(--nav-menu-link, light-dark(#3b5cf6, #6b8fff));
292-
outline-offset: 2px;
293-
}
294-
295-
@media (hover: none), (pointer: coarse) {
296-
display: inline-flex;
297-
}
298-
}
299-
300193
/* The OpenCode bar's metrics, opencode.ai's (site.css: the logo 25px from the top and the start edge, in the box of
301194
"[1]" at 15px; the 56px phone top bar with its 24 × 30 logo box), so a product's bar puts everything where
302195
opencode.ai does and moving between them never jumps:
@@ -309,30 +202,17 @@
309202
--nav-edge: 24px;
310203
--nav-end: 17.5px;
311204
--nav-rule: light-dark(hsl(0 0% 88%), hsl(0 0% 18%));
312-
/* The product name's one fill (hover, open and pressed), opencode.ai's lockup hover: the hover step of the shared
313-
grey scale. Fixed, so it is the same on every page background. */
205+
/* The product name's hover fill, opencode.ai's lockup hover: the hover step of the shared grey scale. Fixed, so it
206+
is the same on every page background. */
314207
--nav-name-hover: light-dark(#eeeeee, #242424);
315-
/* The chevron after a product name (and the docs' after DOCS): its box, the gap after the name's highlight, the glyph,
316-
how far its touch target reaches past it, and its colours. */
317-
--nav-chevron-width: 20px;
318-
--nav-chevron-gap: 2px;
319-
--nav-chevron-glyph: 10px;
320-
--nav-chevron-reach: 24px;
321-
--nav-chevron-ink: light-dark(#161616, #fafafa);
322-
--nav-chevron-hover: var(--nav-name-hover);
323-
--nav-chevron-press: light-dark(#d2d2d2, #4b4b4b);
324208
/* The product name after the mark (and the docs' DOCS): its size, and the padding under it that puts OpenTUI Mono's
325209
caps (0.69 of the size) where they belong in the 25px row. */
326210
--nav-name-size: 15px;
327211
--nav-name-pad: 0.65px;
328212

329-
/* Phones: the docs sticky rows' 16px chevron, in an 18px box close to the name, its target reaching 26px past it so
330-
it stays 44px wide. The name grows to 20px, its caps centred in the 25px row (5.5px above and below), within half
331-
a pixel of the mark's inner rectangle. */
213+
/* Phones: the name grows to 20px, its caps centred in the 25px row (5.5px above and below), within half a pixel of
214+
the mark's inner rectangle. */
332215
@media (max-width: 60rem) {
333-
--nav-chevron-width: 18px;
334-
--nav-chevron-glyph: 16px;
335-
--nav-chevron-reach: 26px;
336216
--nav-name-size: 20px;
337217
--nav-name-pad: 1px;
338218
}
@@ -348,9 +228,8 @@
348228
}
349229

350230
/* The lockup: the logo (`data-nav-logo`, a 20 × 25 mark at whole pixels in its box, as on opencode.ai), then the
351-
product's name (`data-nav-product`) 12px after the box: OpenTUI Mono Bold 15px caps whose 6px padding is the
352-
highlight, --nav-name-hover while hovered, pressed or open (hovering opens the product menu, so it never steps darker).
353-
Placed at --nav-edge, centred in the bar. */
231+
product's name (`data-nav-name`) 12px after the box: OpenTUI Mono Bold 15px caps whose 6px padding is the
232+
highlight, --nav-name-hover while hovered or pressed. Placed at --nav-edge, centred in the bar. */
354233
[data-nav-lockup] {
355234
--nav-lockup-ink: light-dark(#161616, #fafafa);
356235
--nav-logo-inner: light-dark(#d2d2d2, #4b4b4b);
@@ -390,8 +269,7 @@
390269
}
391270
}
392271

393-
/* `data-nav-name` is a name with no product menu (the status page's). */
394-
:is([data-nav-product], [data-nav-name]):is([data-nav-product], [data-nav-name]) {
272+
:is([data-nav-name], [data-nav-product]):is([data-nav-name], [data-nav-product]) {
395273
position: relative;
396274
display: inline-flex;
397275
align-items: center;
@@ -433,19 +311,13 @@
433311
}
434312
}
435313

436-
&:active,
437-
&[aria-expanded="true"] {
314+
&:active {
438315
background: var(--nav-name-hover);
439316
}
440317
}
441318

442-
:is([data-nav-logo], [data-nav-product], [data-nav-name]):focus-visible {
319+
:is([data-nav-logo], [data-nav-name], [data-nav-product]):focus-visible {
443320
outline: 2px solid var(--nav-menu-link, light-dark(#3b5cf6, #6b8fff));
444321
outline-offset: 2px;
445322
}
446-
447-
[data-nav-product-toggle] {
448-
height: 25px;
449-
margin-top: var(--nav-lockup-inset);
450-
}
451323
}
Collapse file

‎packages/nav-menus/test/nav-menus.test.ts‎

Copy file name to clipboardExpand all lines: packages/nav-menus/test/nav-menus.test.ts
+10-55Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ let stop: () => void
66
beforeEach(() => {
77
document.body.innerHTML = `
88
<header>
9-
<a href="/" data-nav-logo aria-label="OpenCode home"><svg width="20" height="25"></svg></a>
10-
<span><a href="/data" data-nav-product="data" aria-haspopup="menu" aria-expanded="false">Data</a></span>
9+
<a href="/" data-nav-logo aria-label="OpenCode home" aria-haspopup="menu" aria-expanded="false"><svg width="20" height="25"></svg></a>
10+
<a href="/data" data-nav-name>Data</a>
1111
</header>
1212
<main><a href="#elsewhere">Elsewhere</a></main>`
1313
stop = installNavMenus({ link: (path) => `https://example.test${path}` })
@@ -16,8 +16,7 @@ beforeEach(() => {
1616
afterEach(() => stop())
1717

1818
const logo = () => document.querySelector<HTMLElement>("[data-nav-logo]")!
19-
const name = () => document.querySelector<HTMLElement>("[data-nav-product]")!
20-
const chevron = () => document.querySelector<HTMLElement>("[data-nav-product-toggle]")!
19+
const name = () => document.querySelector<HTMLElement>("[data-nav-name]")!
2120
const menus = () => [...document.querySelectorAll<HTMLElement>("[data-nav-menu]:not([data-closing])")]
2221
const items = (menu: HTMLElement) => [...menu.querySelectorAll<HTMLAnchorElement>('[role="menuitem"]')]
2322
const press = (target: HTMLElement, key: string, shiftKey = false) =>
@@ -80,63 +79,19 @@ describe("logo menu", () => {
8079
})
8180
})
8281

83-
describe("product menu", () => {
84-
test("lists the products in order with this page's one current", () => {
85-
name().focus()
82+
describe("product name", () => {
83+
test("stays a plain link with no hover dropdown or touch toggle", async () => {
84+
expect(document.querySelector("[data-nav-product-toggle]")).toBeNull()
8685

86+
name().dispatchEvent(new PointerEvent("pointerover", { bubbles: true, pointerType: "mouse" }))
87+
await Bun.sleep(200)
8788
press(name(), "ArrowDown")
8889

89-
expect(items(menus()[0]!).map((item) => [item.textContent, item.getAttribute("aria-current")])).toEqual([
90-
["OpenCode", null],
91-
["Console", null],
92-
["Data", "page"],
93-
["Docs", null],
94-
])
95-
expect(name().getAttribute("aria-expanded")).toBe("true")
96-
})
97-
98-
test("each product card shows its label alone", () => {
99-
name().focus()
100-
101-
press(name(), "ArrowDown")
102-
103-
expect(items(menus()[0]!).map((item) => item.querySelectorAll("[data-slot]").length)).toEqual([1, 1, 1, 1])
104-
})
105-
106-
test("the chevron opens and closes it, showing the open state on the chevron and the name", () => {
107-
chevron().click()
108-
expect(chevron().getAttribute("aria-expanded")).toBe("true")
109-
expect(name().getAttribute("aria-expanded")).toBe("true")
110-
111-
chevron().click()
112-
11390
expect(menus()).toHaveLength(0)
114-
expect(chevron().getAttribute("aria-expanded")).toBe("false")
115-
})
116-
117-
test("Escape returns focus to the chevron that opened it", () => {
118-
chevron().focus()
119-
press(chevron(), "Enter")
120-
press(document.activeElement as HTMLElement, "Escape")
121-
122-
expect(document.activeElement).toBe(chevron())
12391
})
12492
})
12593

126-
describe("one menu at a time", () => {
127-
test("opening the logo menu closes the product menu at once", () => {
128-
name().focus()
129-
press(name(), "ArrowDown")
130-
131-
logo().dispatchEvent(
132-
new MouseEvent("contextmenu", { bubbles: true, cancelable: true, button: 2, clientX: 9, clientY: 9 }),
133-
)
134-
135-
expect(document.querySelectorAll("[data-nav-menu]")).toHaveLength(1)
136-
expect(menus()[0]!.getAttribute("data-nav-menu")).toBe("logo")
137-
expect(name().getAttribute("aria-expanded")).toBe("false")
138-
})
139-
94+
describe("closing", () => {
14095
test("a click elsewhere on the page closes it", () => {
14196
press(logo(), "ContextMenu")
14297

@@ -153,7 +108,7 @@ describe("one menu at a time", () => {
153108
expect(menus()).toHaveLength(0)
154109
})
155110

156-
test("tells the host when one opens, so it can close its own menus", () => {
111+
test("tells the host when it opens, so it can close its own menus", () => {
157112
const opened: string[] = []
158113
document.addEventListener("opencode-nav-menu-open", () => opened.push("open"), { once: true })
159114

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.