Skip to content

Commit 8923a8d

Browse files
authored
fix(site): fix production colours and bring in the latest site fixes (#62285)
1 parent e803323 commit 8923a8d

19 files changed

Lines changed: 294 additions & 63 deletions

‎services/site/script/build.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ await Bun.$`vite build`.cwd(root).env(env)
3838
await Bun.$`bun ./src/docs/script/build.ts --mode ${mode}`.cwd(root).env(env)
3939
await Bun.$`bun ./script/check-server-bundle.ts`.cwd(root).env(env)
4040
await Bun.$`bun ./script/check-client-bundle.ts`.cwd(root).env(env)
41+
await Bun.$`bun ./script/check-css-output.ts`.cwd(root).env(env)
4142

4243
// @cloudflare/config's file loader refuses Bun; it resolves an imported config the same way.
4344
const parsed = await resolveAndParseConfig((await import("../cloudflare.config")).default, { isPreview: false, mode })
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Fails the build when the production CSS lowers light-dark(). The site's colour tokens are
2+
// light-dark() pairs defined once on the site root, and a card or band that forces the dark scheme
3+
// (color-scheme: dark) relies on them resolving there. The minifier's fallback for older browsers
4+
// (--lightningcss-light/--lightningcss-dark variables) freezes every token at the root's theme, so
5+
// the production page silently differs from the development server. vite.config.ts's cssTarget
6+
// keeps light-dark() native; this guards against that target being lowered again.
7+
// Run after `vite build`, optionally with the output directory: `bun script/check-css-output.ts .output`.
8+
import path from "node:path"
9+
import { Glob } from "bun"
10+
11+
const root = path.resolve(process.argv[2] ?? path.join(import.meta.dir, "..", ".output"), "public")
12+
const lowered: string[] = []
13+
for await (const file of new Glob("**/*.css").scan(root)) {
14+
if ((await Bun.file(path.join(root, file)).text()).includes("--lightningcss-")) lowered.push(file)
15+
}
16+
if (lowered.length > 0) {
17+
console.error(`light-dark() was lowered (--lightningcss-* variables) in:\n${lowered.join("\n")}`)
18+
process.exit(1)
19+
}
20+
console.log("Production CSS keeps light-dark() native.")

‎services/site/src/component/site/legal.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ function LegalHistory(props: { document: LegalDocumentContent; onBack?: () => vo
687687
</For>
688688
</ol>
689689
<p>
690-
Follow changes to every legal document in a feed reader: <a href={feed}>RSS feed</a>.
690+
Follow changes to every legal document with the <a href={feed}>RSS feed</a>.
691691
</p>
692692
</section>
693693
)

‎services/site/src/component/site/on-this-page.css‎

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,27 @@
180180
display: none;
181181
}
182182

183+
/* 16px, like the icons on the menu button's column. It points to the inline end while closed
184+
(right, or left in right-to-left pages) and turns to point down when open. */
183185
[data-slot="chevron"] {
184-
transition: scale 200ms var(--ease-out);
186+
width: 16px;
187+
height: 16px;
188+
rotate: -90deg;
189+
transition: rotate 180ms var(--ease-out);
190+
191+
html[dir="rtl"] & {
192+
rotate: 90deg;
193+
}
194+
195+
@media (prefers-reduced-motion: reduce) {
196+
transition: none;
197+
}
185198
}
186199
}
187200

188-
&[open] summary [data-slot="chevron"] {
189-
scale: 1 -1;
201+
&[open] summary [data-slot="chevron"],
202+
html[dir="rtl"] &[open] summary [data-slot="chevron"] {
203+
rotate: 0deg;
190204
}
191205

192206
summary [data-slot="label"] {
@@ -221,9 +235,11 @@
221235
display: block;
222236
background: var(--bg);
223237

224-
/* One line above the bar and one below, each across the whole screen. The top line sits on the
225-
row above the bar: stuck, that row is the top bar's own bottom hairline, which paints over it,
226-
so there's only ever one line there and nothing moves when the bar sticks. */
238+
/* At rest the bar has no lines. Pinned (data-stuck, from ContentsMenu), a line fades in above
239+
and below it, each across the whole screen. The top line sits on the row above the bar, where
240+
the bar above (the top bar's hairline, or the legal tabs' divider) already draws its own and
241+
paints over it, so there's only ever one line there. Nothing moves when they show; the bar's
242+
background stays a hard cut. */
227243
summary::before,
228244
summary::after {
229245
content: "";
@@ -232,6 +248,17 @@
232248
height: 1px;
233249
background: var(--border);
234250
pointer-events: none;
251+
opacity: 0;
252+
transition: opacity 150ms ease;
253+
254+
@media (prefers-reduced-motion: reduce) {
255+
transition: none;
256+
}
257+
}
258+
259+
&[data-stuck] summary::before,
260+
&[data-stuck] summary::after {
261+
opacity: 1;
235262
}
236263

237264
summary::before {
@@ -252,7 +279,7 @@
252279
edge), like the accordions' plus. */
253280
@media (max-width: 40rem) {
254281
summary [data-slot="chevron"] {
255-
margin-inline-end: calc(34px - var(--edge) - 6px);
282+
margin-inline-end: calc(34px - var(--edge) - 8px);
256283
}
257284
}
258285

‎services/site/src/component/site/on-this-page.tsx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,29 @@ export function ContentsMenu(props: { items: ContentsItem[] }) {
120120
menu.open = false
121121
menu.querySelector("summary")?.focus()
122122
}
123+
// Pinned (its top at its sticky offset, once the page has scrolled), the bar shows its lines
124+
// (data-stuck, on-this-page.css). Measured on scroll, so it works where CSS scroll-state queries
125+
// don't (WebKit).
126+
let frame = 0
127+
const stuck = () => {
128+
cancelAnimationFrame(frame)
129+
frame = requestAnimationFrame(() => {
130+
if (!menu) return
131+
const top = parseFloat(getComputedStyle(menu).top)
132+
menu.toggleAttribute("data-stuck", window.scrollY > 0 && menu.getBoundingClientRect().top <= top + 0.5)
133+
})
134+
}
123135
document.addEventListener("pointerdown", outside)
124136
document.addEventListener("keydown", escape)
137+
window.addEventListener("scroll", stuck, { passive: true })
138+
window.addEventListener("resize", stuck)
139+
stuck()
125140
onCleanup(() => {
141+
cancelAnimationFrame(frame)
126142
document.removeEventListener("pointerdown", outside)
127143
document.removeEventListener("keydown", escape)
144+
window.removeEventListener("scroll", stuck)
145+
window.removeEventListener("resize", stuck)
128146
})
129147
})
130148

‎services/site/src/component/site/phone-features.css‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,22 @@
7676

7777
/* Divided like /press's boilerplate accordion (press/index.css): a 1px line between rows and
7878
one under the last, each title evenly spaced between its lines. */
79-
> li + li {
79+
> li + li,
80+
> li:first-child {
8081
border-top: 1px solid var(--border);
8182
}
8283

8384
> li:last-child {
8485
border-bottom: 1px solid var(--border);
8586
}
8687

88+
/* With a line above the first row too, it is padded like the others. */
89+
&& > li:first-child [data-slot="faq-question"] {
90+
--padding-top: 1rem;
91+
min-height: var(--row-height);
92+
margin-top: 0;
93+
}
94+
8795
&& [data-slot="faq-question"] {
8896
--padding-top: 1rem;
8997
padding-bottom: 1rem;

‎services/site/src/component/site/phone-menu.css‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,22 @@
7171
max-height: 100%;
7272
overflow-y: auto;
7373
overscroll-behavior: contain;
74+
/* The "[n]" column centres on the top bar's logo mark above it: the mark's box starts at
75+
--edge and is --phone-logo-height × 4/5 wide, and "[n]" is three mono characters (3ch)
76+
wide, so the list starts half of each before the mark's centre. The labels keep their
77+
gap after the numbers, so they share one column too. Mirrored right to left. */
78+
--menu-start: calc(var(--edge) + var(--phone-logo-height, 30px) * 2 / 5 - 1.5ch);
7479
padding: 0.5rem calc(var(--edge) + env(safe-area-inset-right, 0px))
75-
calc(1.5rem + env(safe-area-inset-bottom, 0px)) calc(var(--edge) + env(safe-area-inset-left, 0px));
80+
calc(1.5rem + env(safe-area-inset-bottom, 0px)) calc(var(--menu-start) + env(safe-area-inset-left, 0px));
7681
font-family: var(--font-mono);
7782
/* The sheet's one job is this list: a step above the body copy, like a native menu. */
7883
font-size: var(--fs-large);
7984
line-height: 24px;
85+
86+
&:dir(rtl) {
87+
padding-left: calc(var(--edge) + env(safe-area-inset-left, 0px));
88+
padding-right: calc(var(--menu-start) + env(safe-area-inset-right, 0px));
89+
}
8090
}
8191

8292
[data-slot="panel"] > ul > li {

‎services/site/src/component/site/product-page.css‎

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
between them. */
44
--feature-row-gap: 2rem;
55
--feature-step: 1.75rem;
6+
/* On phones, the room the previous and next chevrons take at the breadcrumb row's end: two 2.75rem
7+
targets, less the 0.75rem pulled into the page edge, and a 0.5rem gap before them. */
8+
--cycle-room: calc(2 * 2.75rem - 0.75rem + 0.5rem);
69

710
/* Sits in the logo row so the hero video starts at the top of the content column. */
811
[data-component="breadcrumb"] {
@@ -19,18 +22,32 @@
1922
line-height: 1.2;
2023

2124
/* Small screens: the header holds the logo and menu, so the breadcrumb is the first row of
22-
the page. The chevrons get 44px targets; the last one still ends on the page edge. */
25+
the page. Its end leaves room for the previous and next chevrons (below), and a long name
26+
shortens with an ellipsis rather than run under them. */
2327
@media (max-width: 60rem) {
2428
position: static;
2529
height: 2.75rem;
2630
/* 0.5rem under the top bar, wherever the content line sits. */
2731
margin: calc(var(--topbar-height) + 0.5rem - var(--content-top)) 0 0.5rem;
32+
padding-inline-end: var(--cycle-room);
2833

2934
> a {
3035
display: flex;
3136
align-items: center;
3237
height: 100%;
3338
}
39+
40+
> * {
41+
flex-shrink: 0;
42+
}
43+
44+
[aria-current="page"] {
45+
flex-shrink: 1;
46+
min-width: 0;
47+
overflow: hidden;
48+
text-overflow: ellipsis;
49+
white-space: nowrap;
50+
}
3451
}
3552
}
3653

@@ -72,25 +89,20 @@
7289
}
7390
}
7491

75-
/* Small screens: in the top bar, left of its GitHub mark. The bar's right padding, the menu
76-
button (2.75rem, pulled 0.75rem into the padding) and the mark's 0.5rem gap and 2.5rem width
77-
put the mark's left edge 5rem in from the padding; the targets grow to 36px for touch. */
92+
/* Small screens: at the end of the breadcrumb row, not in the top bar, which holds just the
93+
logo, the GitHub mark and the menu as on other pages. In the flow right after the breadcrumb,
94+
pulled up over its row (its 2.75rem and 0.5rem gap) and taking the gap back below, so the page
95+
below doesn't move. Two 44px targets; the next chevron is pulled 0.75rem into the page edge,
96+
like the menu button, so its centre is on the menu button's centre. They scroll with the row. */
7897
@media (max-width: 60rem) {
79-
top: calc(var(--banner-offset, 0px) + env(safe-area-inset-top, 0px) + var(--topbar-height) / 2 - 1.125rem);
80-
inset-inline-end: calc(var(--edge) + env(safe-area-inset-right, 0px) + 5.5rem);
81-
z-index: 11;
98+
position: static;
99+
width: fit-content;
100+
margin-block: calc(-2.75rem - 0.5rem) 0.5rem;
101+
margin-inline: auto -0.75rem;
82102

83103
a {
84-
position: relative;
85-
width: 2.25rem;
86-
height: 2.25rem;
87-
88-
/* An invisible band above and below makes each target 44px tall. */
89-
&::after {
90-
content: "";
91-
position: absolute;
92-
inset: -0.25rem 0;
93-
}
104+
width: 2.75rem;
105+
height: 2.75rem;
94106
}
95107
}
96108
}

‎services/site/src/component/site/products.css‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@
5757
grid-auto-columns: calc((100% + var(--edge) - var(--gaps) * var(--gutter)) / var(--visible));
5858
}
5959

60-
/* The carousel's cards stop short of the small viewport's bottom (100svh, with the browser's
61-
toolbars showing) at first load: below the home hero (24 to 28rem down, longer in German) with room under the
62-
button. The media keeps its full width (a set width, so the cap shortens it rather than
63-
narrowing it) and crops a little more of its height, never under 18rem,
64-
so short phones see the whole card once it scrolls into place. */
60+
/* The carousel's cards are 4:5, or shorter where that would run past the small viewport
61+
(100svh, the browser's toolbars showing): then they end 16px above its bottom at first load,
62+
measured from where the cards start (--card-top, set before first paint by the home page;
63+
28rem until then). The media keeps its full width (a set width, so the cap shortens it
64+
rather than narrowing it) and crops a little more of its height, never under 18rem, so short
65+
phones see the whole card once it scrolls into place. */
6566
:is([data-component="products"]:not([data-layout="grid"]), [data-component="products-skeleton"])
6667
[data-component="product-card"]
6768
[data-slot="media"] {
6869
width: 100%;
69-
max-height: max(18rem, calc(100svh - 28rem));
70+
max-height: max(18rem, calc(100svh - var(--card-top, 28rem) - 1rem));
7071
}
7172

7273
/* The carousel card's buttons sit over its dark media in both themes, so they are the light

‎services/site/src/component/site/site.css‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,9 +2375,9 @@ html:has([data-site][data-theme="dark"]) {
23752375
}
23762376
}
23772377

2378+
/* The docs section menu: like the Contents row, no lines (it doesn't pin), and a 16px chevron on
2379+
the menu button's column that points to the inline end closed and down open. */
23782380
[data-component="section-nav"] {
2379-
border-block: 1px solid var(--border);
2380-
23812381
[data-slot="section-toggle"] {
23822382
display: flex;
23832383
align-items: center;
@@ -2389,11 +2389,24 @@ html:has([data-site][data-theme="dark"]) {
23892389
color: var(--text-strong);
23902390

23912391
[data-slot="chevron"] {
2392-
/* The chevron flips instantly when the menu opens. */
2392+
width: 16px;
2393+
height: 16px;
2394+
margin-inline-end: calc(34px - var(--edge) - 8px);
2395+
rotate: -90deg;
2396+
transition: rotate 180ms var(--ease-out);
2397+
2398+
html[dir="rtl"] & {
2399+
rotate: 90deg;
2400+
}
2401+
2402+
@media (prefers-reduced-motion: reduce) {
2403+
transition: none;
2404+
}
23932405
}
23942406

2395-
&[aria-expanded="true"] [data-slot="chevron"] {
2396-
scale: 1 -1;
2407+
&[aria-expanded="true"] [data-slot="chevron"],
2408+
html[dir="rtl"] &[aria-expanded="true"] [data-slot="chevron"] {
2409+
rotate: 0deg;
23972410
}
23982411
}
23992412

@@ -3304,6 +3317,23 @@ html:has([data-site][data-theme="dark"]) {
33043317
which grows open and pushes the page up while the wordmark's letters are out of order. */
33053318
[data-site] {
33063319
--letters-bar-height: 3.25rem;
3320+
/* The blue bars' shared look (site-banner.css): the link blue, the same as the blue buttons and
3321+
the announcement banner (dark mode keeps the deeper light-mode blue, so white keeps 4.5:1). */
3322+
--bar-blue: light-dark(var(--link), #3b5cf6);
3323+
}
3324+
3325+
/* While the open bar fills the bottom of the screen, a fixed strip of its blue covers the home
3326+
indicator's area under it, touching the screen's bottom edge, which iOS Safari tints its bottom
3327+
toolbar from (the page behind the site takes the blue too: site.tsx). It is as tall as the inset,
3328+
and a pixel, over the bar's own blue, so it never covers anything else. */
3329+
[data-site][data-letters-end]::after {
3330+
content: "";
3331+
position: fixed;
3332+
inset: auto 0 0;
3333+
z-index: 1;
3334+
height: calc(env(safe-area-inset-bottom, 0px) + 1px);
3335+
background: var(--bar-blue);
3336+
pointer-events: none;
33073337
}
33083338

33093339
@media (max-width: 40rem) {
@@ -3345,10 +3375,7 @@ html:has([data-site][data-theme="dark"]) {
33453375
gap: 0.25rem;
33463376
height: calc(var(--letters-bar-height) + env(safe-area-inset-bottom, 0px));
33473377
padding-bottom: env(safe-area-inset-bottom, 0px);
3348-
/* The blue bars' shared look (site-banner.css): the link blue, the same as the blue buttons and
3349-
the announcement banner (dark mode keeps the deeper light-mode blue, so white keeps 4.5:1), a
3350-
highlight and a 92% body. */
3351-
--bar-blue: light-dark(var(--link), #3b5cf6);
3378+
/* The blue bars' shared look (--bar-blue above, site-banner.css): a highlight and a 92% body. */
33523379
background: var(--bar-blue);
33533380
font-family: var(--font-sans);
33543381
font-size: var(--fs-ui);

0 commit comments

Comments
 (0)