From 8923a8d70841ccc9f75a79cea920f7a7ada73b59 Mon Sep 17 00:00:00 2001 From: David Hill <1879069+iamdavidhill@users.noreply.github.com> Date: Fri, 6 Nov 2026 10:26:54 -0600 Subject: [PATCH] fix(site): fix production colours and bring in the latest site fixes (#62285) --- services/site/script/build.ts | 1 + services/site/script/check-css-output.ts | 20 ++++++++ services/site/src/component/site/legal.tsx | 2 +- .../site/src/component/site/on-this-page.css | 41 ++++++++++++++--- .../site/src/component/site/on-this-page.tsx | 18 ++++++++ .../src/component/site/phone-features.css | 10 +++- .../site/src/component/site/phone-menu.css | 12 ++++- .../site/src/component/site/product-page.css | 46 ++++++++++++------- services/site/src/component/site/products.css | 13 +++--- services/site/src/component/site/site.css | 45 ++++++++++++++---- services/site/src/component/site/site.tsx | 36 +++++++++++++-- .../site/src/component/site/tap-targets.css | 11 ----- .../src/component/site/voice/voice-mode.css | 7 +++ services/site/src/docs/script/build.ts | 2 + services/site/src/routes/brand/index.css | 21 +++++++++ services/site/src/routes/index.tsx | 7 +++ services/site/src/routes/legal/legal.css | 23 ++++++++-- services/site/src/routes/press/index.css | 36 ++++++++++++++- services/site/vite.config.ts | 6 +++ 19 files changed, 294 insertions(+), 63 deletions(-) create mode 100644 services/site/script/check-css-output.ts diff --git a/services/site/script/build.ts b/services/site/script/build.ts index eb859588c33..f4cac6607f3 100644 --- a/services/site/script/build.ts +++ b/services/site/script/build.ts @@ -38,6 +38,7 @@ await Bun.$`vite build`.cwd(root).env(env) await Bun.$`bun ./src/docs/script/build.ts --mode ${mode}`.cwd(root).env(env) await Bun.$`bun ./script/check-server-bundle.ts`.cwd(root).env(env) await Bun.$`bun ./script/check-client-bundle.ts`.cwd(root).env(env) +await Bun.$`bun ./script/check-css-output.ts`.cwd(root).env(env) // @cloudflare/config's file loader refuses Bun; it resolves an imported config the same way. const parsed = await resolveAndParseConfig((await import("../cloudflare.config")).default, { isPreview: false, mode }) diff --git a/services/site/script/check-css-output.ts b/services/site/script/check-css-output.ts new file mode 100644 index 00000000000..d7b39b27aa8 --- /dev/null +++ b/services/site/script/check-css-output.ts @@ -0,0 +1,20 @@ +// Fails the build when the production CSS lowers light-dark(). The site's colour tokens are +// light-dark() pairs defined once on the site root, and a card or band that forces the dark scheme +// (color-scheme: dark) relies on them resolving there. The minifier's fallback for older browsers +// (--lightningcss-light/--lightningcss-dark variables) freezes every token at the root's theme, so +// the production page silently differs from the development server. vite.config.ts's cssTarget +// keeps light-dark() native; this guards against that target being lowered again. +// Run after `vite build`, optionally with the output directory: `bun script/check-css-output.ts .output`. +import path from "node:path" +import { Glob } from "bun" + +const root = path.resolve(process.argv[2] ?? path.join(import.meta.dir, "..", ".output"), "public") +const lowered: string[] = [] +for await (const file of new Glob("**/*.css").scan(root)) { + if ((await Bun.file(path.join(root, file)).text()).includes("--lightningcss-")) lowered.push(file) +} +if (lowered.length > 0) { + console.error(`light-dark() was lowered (--lightningcss-* variables) in:\n${lowered.join("\n")}`) + process.exit(1) +} +console.log("Production CSS keeps light-dark() native.") diff --git a/services/site/src/component/site/legal.tsx b/services/site/src/component/site/legal.tsx index 2601913dbaa..8935568525d 100644 --- a/services/site/src/component/site/legal.tsx +++ b/services/site/src/component/site/legal.tsx @@ -687,7 +687,7 @@ function LegalHistory(props: { document: LegalDocumentContent; onBack?: () => vo
- Follow changes to every legal document in a feed reader: RSS feed. + Follow changes to every legal document with the RSS feed.
) diff --git a/services/site/src/component/site/on-this-page.css b/services/site/src/component/site/on-this-page.css index d75eecb40a1..fe38b08a4b8 100644 --- a/services/site/src/component/site/on-this-page.css +++ b/services/site/src/component/site/on-this-page.css @@ -180,13 +180,27 @@ display: none; } + /* 16px, like the icons on the menu button's column. It points to the inline end while closed + (right, or left in right-to-left pages) and turns to point down when open. */ [data-slot="chevron"] { - transition: scale 200ms var(--ease-out); + width: 16px; + height: 16px; + rotate: -90deg; + transition: rotate 180ms var(--ease-out); + + html[dir="rtl"] & { + rotate: 90deg; + } + + @media (prefers-reduced-motion: reduce) { + transition: none; + } } } - &[open] summary [data-slot="chevron"] { - scale: 1 -1; + &[open] summary [data-slot="chevron"], + html[dir="rtl"] &[open] summary [data-slot="chevron"] { + rotate: 0deg; } summary [data-slot="label"] { @@ -221,9 +235,11 @@ display: block; background: var(--bg); - /* One line above the bar and one below, each across the whole screen. The top line sits on the - row above the bar: stuck, that row is the top bar's own bottom hairline, which paints over it, - so there's only ever one line there and nothing moves when the bar sticks. */ + /* At rest the bar has no lines. Pinned (data-stuck, from ContentsMenu), a line fades in above + and below it, each across the whole screen. The top line sits on the row above the bar, where + the bar above (the top bar's hairline, or the legal tabs' divider) already draws its own and + paints over it, so there's only ever one line there. Nothing moves when they show; the bar's + background stays a hard cut. */ summary::before, summary::after { content: ""; @@ -232,6 +248,17 @@ height: 1px; background: var(--border); pointer-events: none; + opacity: 0; + transition: opacity 150ms ease; + + @media (prefers-reduced-motion: reduce) { + transition: none; + } + } + + &[data-stuck] summary::before, + &[data-stuck] summary::after { + opacity: 1; } summary::before { @@ -252,7 +279,7 @@ edge), like the accordions' plus. */ @media (max-width: 40rem) { summary [data-slot="chevron"] { - margin-inline-end: calc(34px - var(--edge) - 6px); + margin-inline-end: calc(34px - var(--edge) - 8px); } } diff --git a/services/site/src/component/site/on-this-page.tsx b/services/site/src/component/site/on-this-page.tsx index 74bc2db3f5c..8e933e14553 100644 --- a/services/site/src/component/site/on-this-page.tsx +++ b/services/site/src/component/site/on-this-page.tsx @@ -120,11 +120,29 @@ export function ContentsMenu(props: { items: ContentsItem[] }) { menu.open = false menu.querySelector("summary")?.focus() } + // Pinned (its top at its sticky offset, once the page has scrolled), the bar shows its lines + // (data-stuck, on-this-page.css). Measured on scroll, so it works where CSS scroll-state queries + // don't (WebKit). + let frame = 0 + const stuck = () => { + cancelAnimationFrame(frame) + frame = requestAnimationFrame(() => { + if (!menu) return + const top = parseFloat(getComputedStyle(menu).top) + menu.toggleAttribute("data-stuck", window.scrollY > 0 && menu.getBoundingClientRect().top <= top + 0.5) + }) + } document.addEventListener("pointerdown", outside) document.addEventListener("keydown", escape) + window.addEventListener("scroll", stuck, { passive: true }) + window.addEventListener("resize", stuck) + stuck() onCleanup(() => { + cancelAnimationFrame(frame) document.removeEventListener("pointerdown", outside) document.removeEventListener("keydown", escape) + window.removeEventListener("scroll", stuck) + window.removeEventListener("resize", stuck) }) }) diff --git a/services/site/src/component/site/phone-features.css b/services/site/src/component/site/phone-features.css index 51ba93f800f..fea6dca79d8 100644 --- a/services/site/src/component/site/phone-features.css +++ b/services/site/src/component/site/phone-features.css @@ -76,7 +76,8 @@ /* Divided like /press's boilerplate accordion (press/index.css): a 1px line between rows and one under the last, each title evenly spaced between its lines. */ - > li + li { + > li + li, + > li:first-child { border-top: 1px solid var(--border); } @@ -84,6 +85,13 @@ border-bottom: 1px solid var(--border); } + /* With a line above the first row too, it is padded like the others. */ + && > li:first-child [data-slot="faq-question"] { + --padding-top: 1rem; + min-height: var(--row-height); + margin-top: 0; + } + && [data-slot="faq-question"] { --padding-top: 1rem; padding-bottom: 1rem; diff --git a/services/site/src/component/site/phone-menu.css b/services/site/src/component/site/phone-menu.css index 6ad8ca25801..593b3f7635a 100644 --- a/services/site/src/component/site/phone-menu.css +++ b/services/site/src/component/site/phone-menu.css @@ -71,12 +71,22 @@ max-height: 100%; overflow-y: auto; overscroll-behavior: contain; + /* The "[n]" column centres on the top bar's logo mark above it: the mark's box starts at + --edge and is --phone-logo-height × 4/5 wide, and "[n]" is three mono characters (3ch) + wide, so the list starts half of each before the mark's centre. The labels keep their + gap after the numbers, so they share one column too. Mirrored right to left. */ + --menu-start: calc(var(--edge) + var(--phone-logo-height, 30px) * 2 / 5 - 1.5ch); padding: 0.5rem calc(var(--edge) + env(safe-area-inset-right, 0px)) - calc(1.5rem + env(safe-area-inset-bottom, 0px)) calc(var(--edge) + env(safe-area-inset-left, 0px)); + calc(1.5rem + env(safe-area-inset-bottom, 0px)) calc(var(--menu-start) + env(safe-area-inset-left, 0px)); font-family: var(--font-mono); /* The sheet's one job is this list: a step above the body copy, like a native menu. */ font-size: var(--fs-large); line-height: 24px; + + &:dir(rtl) { + padding-left: calc(var(--edge) + env(safe-area-inset-left, 0px)); + padding-right: calc(var(--menu-start) + env(safe-area-inset-right, 0px)); + } } [data-slot="panel"] > ul > li { diff --git a/services/site/src/component/site/product-page.css b/services/site/src/component/site/product-page.css index 6334624cc26..29dd1c51f78 100644 --- a/services/site/src/component/site/product-page.css +++ b/services/site/src/component/site/product-page.css @@ -3,6 +3,9 @@ between them. */ --feature-row-gap: 2rem; --feature-step: 1.75rem; + /* On phones, the room the previous and next chevrons take at the breadcrumb row's end: two 2.75rem + targets, less the 0.75rem pulled into the page edge, and a 0.5rem gap before them. */ + --cycle-room: calc(2 * 2.75rem - 0.75rem + 0.5rem); /* Sits in the logo row so the hero video starts at the top of the content column. */ [data-component="breadcrumb"] { @@ -19,18 +22,32 @@ line-height: 1.2; /* Small screens: the header holds the logo and menu, so the breadcrumb is the first row of - the page. The chevrons get 44px targets; the last one still ends on the page edge. */ + the page. Its end leaves room for the previous and next chevrons (below), and a long name + shortens with an ellipsis rather than run under them. */ @media (max-width: 60rem) { position: static; height: 2.75rem; /* 0.5rem under the top bar, wherever the content line sits. */ margin: calc(var(--topbar-height) + 0.5rem - var(--content-top)) 0 0.5rem; + padding-inline-end: var(--cycle-room); > a { display: flex; align-items: center; height: 100%; } + + > * { + flex-shrink: 0; + } + + [aria-current="page"] { + flex-shrink: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } } } @@ -72,25 +89,20 @@ } } - /* Small screens: in the top bar, left of its GitHub mark. The bar's right padding, the menu - button (2.75rem, pulled 0.75rem into the padding) and the mark's 0.5rem gap and 2.5rem width - put the mark's left edge 5rem in from the padding; the targets grow to 36px for touch. */ + /* Small screens: at the end of the breadcrumb row, not in the top bar, which holds just the + logo, the GitHub mark and the menu as on other pages. In the flow right after the breadcrumb, + pulled up over its row (its 2.75rem and 0.5rem gap) and taking the gap back below, so the page + below doesn't move. Two 44px targets; the next chevron is pulled 0.75rem into the page edge, + like the menu button, so its centre is on the menu button's centre. They scroll with the row. */ @media (max-width: 60rem) { - top: calc(var(--banner-offset, 0px) + env(safe-area-inset-top, 0px) + var(--topbar-height) / 2 - 1.125rem); - inset-inline-end: calc(var(--edge) + env(safe-area-inset-right, 0px) + 5.5rem); - z-index: 11; + position: static; + width: fit-content; + margin-block: calc(-2.75rem - 0.5rem) 0.5rem; + margin-inline: auto -0.75rem; a { - position: relative; - width: 2.25rem; - height: 2.25rem; - - /* An invisible band above and below makes each target 44px tall. */ - &::after { - content: ""; - position: absolute; - inset: -0.25rem 0; - } + width: 2.75rem; + height: 2.75rem; } } } diff --git a/services/site/src/component/site/products.css b/services/site/src/component/site/products.css index dcadb8cc2f4..ed2a52aa956 100644 --- a/services/site/src/component/site/products.css +++ b/services/site/src/component/site/products.css @@ -57,16 +57,17 @@ grid-auto-columns: calc((100% + var(--edge) - var(--gaps) * var(--gutter)) / var(--visible)); } - /* The carousel's cards stop short of the small viewport's bottom (100svh, with the browser's - toolbars showing) at first load: below the home hero (24 to 28rem down, longer in German) with room under the - button. The media keeps its full width (a set width, so the cap shortens it rather than - narrowing it) and crops a little more of its height, never under 18rem, - so short phones see the whole card once it scrolls into place. */ + /* The carousel's cards are 4:5, or shorter where that would run past the small viewport + (100svh, the browser's toolbars showing): then they end 16px above its bottom at first load, + measured from where the cards start (--card-top, set before first paint by the home page; + 28rem until then). The media keeps its full width (a set width, so the cap shortens it + rather than narrowing it) and crops a little more of its height, never under 18rem, so short + phones see the whole card once it scrolls into place. */ :is([data-component="products"]:not([data-layout="grid"]), [data-component="products-skeleton"]) [data-component="product-card"] [data-slot="media"] { width: 100%; - max-height: max(18rem, calc(100svh - 28rem)); + max-height: max(18rem, calc(100svh - var(--card-top, 28rem) - 1rem)); } /* The carousel card's buttons sit over its dark media in both themes, so they are the light diff --git a/services/site/src/component/site/site.css b/services/site/src/component/site/site.css index 71fcf7f4cf2..6c8ba5016de 100644 --- a/services/site/src/component/site/site.css +++ b/services/site/src/component/site/site.css @@ -2375,9 +2375,9 @@ html:has([data-site][data-theme="dark"]) { } } + /* The docs section menu: like the Contents row, no lines (it doesn't pin), and a 16px chevron on + the menu button's column that points to the inline end closed and down open. */ [data-component="section-nav"] { - border-block: 1px solid var(--border); - [data-slot="section-toggle"] { display: flex; align-items: center; @@ -2389,11 +2389,24 @@ html:has([data-site][data-theme="dark"]) { color: var(--text-strong); [data-slot="chevron"] { - /* The chevron flips instantly when the menu opens. */ + width: 16px; + height: 16px; + margin-inline-end: calc(34px - var(--edge) - 8px); + rotate: -90deg; + transition: rotate 180ms var(--ease-out); + + html[dir="rtl"] & { + rotate: 90deg; + } + + @media (prefers-reduced-motion: reduce) { + transition: none; + } } - &[aria-expanded="true"] [data-slot="chevron"] { - scale: 1 -1; + &[aria-expanded="true"] [data-slot="chevron"], + html[dir="rtl"] &[aria-expanded="true"] [data-slot="chevron"] { + rotate: 0deg; } } @@ -3304,6 +3317,23 @@ html:has([data-site][data-theme="dark"]) { which grows open and pushes the page up while the wordmark's letters are out of order. */ [data-site] { --letters-bar-height: 3.25rem; + /* The blue bars' shared look (site-banner.css): the link blue, the same as the blue buttons and + the announcement banner (dark mode keeps the deeper light-mode blue, so white keeps 4.5:1). */ + --bar-blue: light-dark(var(--link), #3b5cf6); +} + +/* While the open bar fills the bottom of the screen, a fixed strip of its blue covers the home + indicator's area under it, touching the screen's bottom edge, which iOS Safari tints its bottom + toolbar from (the page behind the site takes the blue too: site.tsx). It is as tall as the inset, + and a pixel, over the bar's own blue, so it never covers anything else. */ +[data-site][data-letters-end]::after { + content: ""; + position: fixed; + inset: auto 0 0; + z-index: 1; + height: calc(env(safe-area-inset-bottom, 0px) + 1px); + background: var(--bar-blue); + pointer-events: none; } @media (max-width: 40rem) { @@ -3345,10 +3375,7 @@ html:has([data-site][data-theme="dark"]) { gap: 0.25rem; height: calc(var(--letters-bar-height) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); - /* The blue bars' shared look (site-banner.css): the link blue, the same as the blue buttons and - the announcement banner (dark mode keeps the deeper light-mode blue, so white keeps 4.5:1), a - highlight and a 92% body. */ - --bar-blue: light-dark(var(--link), #3b5cf6); + /* The blue bars' shared look (--bar-blue above, site-banner.css): a highlight and a 92% body. */ background: var(--bar-blue); font-family: var(--font-sans); font-size: var(--fs-ui); diff --git a/services/site/src/component/site/site.tsx b/services/site/src/component/site/site.tsx index adc7317cfdf..e885f743c8d 100644 --- a/services/site/src/component/site/site.tsx +++ b/services/site/src/component/site/site.tsx @@ -230,10 +230,12 @@ export function Site(props: { const [theme, setTheme] = createSignal<(typeof themes)[number]>( isServer ? "system" : (themes.find((item) => item === localStorage.getItem("opencode-theme")) ?? "system"), ) - // The colour at the top of the screen: the open banner's blue while it covers it, else the page's - // background in the scheme the tag's media query stands for (or the chosen theme's). + // The browser bar colour: the open banner's blue while it covers the top of the screen, the letters + // bar's while it fills the bottom, else the page's background in the scheme the tag's media query + // stands for (or the chosen theme's). const themeColor = (scheme: "light" | "dark") => bannerTopColor() ?? + lettersBlue() ?? ((theme() === "system" ? scheme : theme()) === "dark" ? "#0c0c0c" : siteSettings.lightBackground) const colorScheme = () => (theme() === "system" ? "light dark" : theme()) const [dark, setDark] = createSignal(false) @@ -274,11 +276,38 @@ export function Site(props: { const highlight = i18n.t("footer.wordmark.font") return label.startsWith(highlight) ? label.slice(highlight.length).trim() : label } + // Whether the whole open bar is on screen (the page is scrolled to its end), so it fills the bottom + // of the screen. + const [lettersBarAtEnd, setLettersBarAtEnd] = createSignal(false) const watchLettersBar = (element: HTMLDivElement) => { - const observer = new IntersectionObserver(([entry]) => setLettersBarInView(entry.isIntersecting)) + const observer = new IntersectionObserver( + ([entry]) => { + setLettersBarInView(entry.isIntersecting) + setLettersBarAtEnd(entry.intersectionRatio >= 0.98) + }, + { threshold: [0, 0.98] }, + ) observer.observe(element) onCleanup(() => observer.disconnect()) } + // While the open bar fills the bottom of the screen, its blue runs on to the screen's bottom edge: + // the page behind the site (what shows past the end, and what iOS Safari tints its bottom toolbar + // area from) and the browser bar colour take the bar's blue as painted, and a fixed strip under the + // home indicator (site.css) gives Safari a blue element touching the bottom edge. + const lettersBottom = () => lettersBarShown() && lettersBarAtEnd() + const [lettersBlue, setLettersBlue] = createSignal