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() + createEffect( + on(lettersBottom, (bottom) => { + const link = document.querySelector('[data-component="letters-bar"] a') + const blue = bottom && link ? getComputedStyle(link).backgroundColor : undefined + setLettersBlue(blue) + if (blue) document.documentElement.style.backgroundColor = blue + else document.documentElement.style.removeProperty("background-color") + }), + ) + onCleanup(() => { + if (!isServer) document.documentElement.style.removeProperty("background-color") + }) // The bar grows at the very end of the page. Someone at the bottom stays at the bottom while it // grows, so the page visibly moves up with it. createEffect( @@ -1094,6 +1123,7 @@ export function Site(props: { data-theme={theme()} data-popover={popoverTheme()} data-letters-bar={lettersBarShown() && lettersBarInView() ? "" : undefined} + data-letters-end={lettersBottom() ? "" : undefined} data-spacer={props.page === "home" || props.page === "product" ? siteSettings.spacer : undefined} data-logo={logoVariant()} data-hero-install={props.page === "home" ? siteSettings.heroInstall : undefined} diff --git a/services/site/src/component/site/tap-targets.css b/services/site/src/component/site/tap-targets.css index 7bd80af2449..f0a80b8cb97 100644 --- a/services/site/src/component/site/tap-targets.css +++ b/services/site/src/component/site/tap-targets.css @@ -54,17 +54,6 @@ } @media (max-width: 60rem) { - /* The product pages' previous and next chevrons: 44px wide (their band above and below - already makes them 44px tall), 8px clear of the GitHub mark's target. [data-page] and a[href] - outrank product-page.css, which loads later. */ - &[data-page] nav[data-component="product-cycle"] { - inset-inline-end: calc(var(--edge) + env(safe-area-inset-right, 0px) + 5.75rem); - } - - [data-component="product-cycle"] a[href] { - width: 2.75rem; - } - &:not([data-bare]) > [data-component="announcement-banner"] button[data-slot="dismiss"] { --dismiss-centre: calc(var(--edge) + env(safe-area-inset-right, 0px) + 3.875rem); } diff --git a/services/site/src/component/site/voice/voice-mode.css b/services/site/src/component/site/voice/voice-mode.css index ff65a2f17c5..fc0ea2f7e61 100644 --- a/services/site/src/component/site/voice/voice-mode.css +++ b/services/site/src/component/site/voice/voice-mode.css @@ -773,9 +773,16 @@ padding: 0.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px)); font-size: var(--fs-body); + /* The square's top on the title's cap height, not its line box: Inter's cap top sits 0.2646 of + the 19px title below the line's top at this line height (measured), Arabic's ink top 0.2778. */ [data-slot="hex-tile"] { width: 2.75rem; height: 2.75rem; + margin-top: calc(1.1875rem * 0.2646); + + &:lang(ar) { + margin-top: calc(1.1875rem * 0.2778); + } svg { width: 1.5rem; diff --git a/services/site/src/docs/script/build.ts b/services/site/src/docs/script/build.ts index c4669cf64d6..e4c9fae7db2 100644 --- a/services/site/src/docs/script/build.ts +++ b/services/site/src/docs/script/build.ts @@ -41,6 +41,8 @@ await build({ outDir: path.join(cache, "client"), assetsDir: "_build", manifest: true, + // The site's target (vite.config.ts): keeps light-dark() native; script/check-css-output.ts fails otherwise. + cssTarget: ["chrome123", "edge123", "firefox120", "safari17.5"], rolldownOptions: { input: ["src/docs/client.ts", "src/docs/styles/global.css"] }, }, }) diff --git a/services/site/src/routes/brand/index.css b/services/site/src/routes/brand/index.css index 372b9cf7004..f41e2e70377 100644 --- a/services/site/src/routes/brand/index.css +++ b/services/site/src/routes/brand/index.css @@ -66,15 +66,24 @@ /* Each tile keeps the background its files are made for, whatever the page's theme: fixed colours, and "only" so a browser's automatic dark mode (Chrome's forced dark, which some device previews turn on) can't darken the light tile or invert its artwork. */ + /* Inline artwork (the partner lockups) takes the tile's own logo colours as plain values, not + the page's light-dark() tokens, which some browsers (older iOS Safari) resolve against the page + theme instead of the tile's. */ &[data-tone="light"] { color-scheme: only light; background: #f5f5f5; + --logo-code: #1f1f1f; + --logo-open: #626262; + --logo-inner: #d2d2d2; } &[data-tone="dark"] { color-scheme: only dark; background: #0a0a0a; box-shadow: inset 0 0 0 1px var(--border); + --logo-code: #eeeeee; + --logo-open: #aeaeae; + --logo-inner: #4b4b4b; } img { @@ -533,6 +542,18 @@ } } + /* Phones: the copy icon 4px larger (18px) and each value row a 44px tall target. */ + @media (max-width: 40rem) { + [data-slot="format"] { + min-height: 44px; + } + + [data-slot="value"] svg { + width: 18px; + height: 18px; + } + } + /* Where a column would be narrower than about 240px: one colour per row. In the three columns the big swatch stays on top, as a swatch beside the values would leave them too little room. */ @container (max-width: 46rem) { diff --git a/services/site/src/routes/index.tsx b/services/site/src/routes/index.tsx index 5d83c2fafde..61eed62c359 100644 --- a/services/site/src/routes/index.tsx +++ b/services/site/src/routes/index.tsx @@ -267,6 +267,9 @@ export default function Home() { {/* The carousel's frame until the carousel itself has streamed in (products.tsx). */} + {/* Before first paint: where the carousel's cards start on the page, so on phones a card runs + down to the bottom of the small viewport (products.css) and never past it. Again on resize. */} +