Skip to content

Commit fe1e3e3

Browse files
authored
feat(site): bring services/site up to date with the latest site work (#62219)
1 parent 42fceba commit fe1e3e3

87 files changed

Lines changed: 1581 additions & 793 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎services/site/DESIGN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ To add a rule, add one line under its group. Mark a rule that is still being dec
9393
- Make tap targets at least 44px on coarse pointers (`tap-targets.css`).
9494
- Close menus on Escape, an outside click and a choice, and return focus to the trigger. → [Language picker](/dev/components#language-picker)
9595
- Test platform UI with the device preview's `_device` parameter, not a narrow window. → [ProductAction](/dev/components#product-action)
96+
- On phones the 404 arcade centres the cabinet and has no Insert coin or Back button: a tap on the coin inserts it, and the site's own GitHub mark, menu button and sheet (`phone-menu.tsx`) sit in the top bar beside the logo.
9697

9798
## Motion
9899

‎services/site/src/component/font/cover-title.tsx‎

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const HEIGHT = 7 + TOP + BOTTOM
1313

1414
// Phase budgets in milliseconds; each phase's moves share its budget in proportion to length.
1515
const PHASES = { metrics: 420, grids: 620, outlines: 820, fill: 760, shade: 380 }
16-
const SETTLE = 220
16+
// After the last move the plot settles: the pen, readout and counter fade out and the guides dim.
17+
const SETTLE = 360
1718
// The shade: the ink at the page's paper shade opacity.
1819
const SHADE_ALPHA = 0.22
1920

@@ -170,7 +171,9 @@ export function CoverTitle() {
170171
let md = 16
171172
let dpr = 1
172173
let palette: Palette = { ink: "#141414", blue: "#3b5cf6", faint: "#bbb" }
173-
let started: number | undefined
174+
let elapsed = reduced ? END : 0
175+
let last: number | undefined
176+
let played = false
174177
let frame = 0
175178

176179
const layout = () => {
@@ -226,14 +229,14 @@ export function CoverTitle() {
226229
for (const [col, row] of buildOrder(WORD[letter] as Letter)) context.fillRect(X(letter * 5 + col), Y(row), md, md)
227230
}
228231

229-
const ticks = (letter: number) => {
232+
const ticks = (letter: number, label: boolean) => {
230233
const y = Y(7) + Math.round(md * 0.55)
231234
context.fillRect(X(letter * 5), y, X(letter * 5 + 4) - X(letter * 5), 1)
232235
for (let col = 0; col <= 4; col++) {
233236
const x = Math.min(X(letter * 5 + col), X(letter * 5 + 4) - 1)
234237
context.fillRect(x, y - Math.round(md * 0.18), 1, Math.round(md * 0.36) + 1)
235238
}
236-
context.fillText("4 × 120u", X(letter * 5), y + Math.round(md * 0.25) + 10 * dpr)
239+
if (label) context.fillText("4 × 120u", X(letter * 5), y + Math.round(md * 0.25) + 10 * dpr)
237240
}
238241

239242
const registration = () => {
@@ -255,13 +258,17 @@ export function CoverTitle() {
255258
}
256259

257260
const draw = (t: number) => {
258-
const done = t >= END
261+
// 0 while plotting, easing to 1 over the settle (an ease-out quint), so nothing snaps at the end.
262+
const settle = 1 - (1 - Math.min(1, Math.max(0, (t - program.end) / SETTLE))) ** 5
263+
const fade = (to: number) => 1 + (to - 1) * settle
259264
context.clearRect(0, 0, canvas.width, canvas.height)
260265
context.font = `${10 * dpr}px "OpenTUI Mono", "OpenTUI Mono Menlo", ui-monospace, monospace`
261266
context.textBaseline = "alphabetic"
267+
// On a narrow canvas the module label is wider than a letter, so only the first letter carries it.
268+
const everyLabel = context.measureText("4 × 120u").width + 4 * dpr <= 5 * md
262269

263270
// Registration marks: always there, faint once the plot is done.
264-
context.globalAlpha = done ? 0.5 : 1
271+
context.globalAlpha = fade(0.5)
265272
context.fillStyle = palette.blue
266273
registration()
267274
context.globalAlpha = 1
@@ -282,18 +289,18 @@ export function CoverTitle() {
282289
]
283290
if (move.kind === "metric" || move.kind === "grid" || move.kind === "outline") {
284291
context.fillStyle = move.kind === "outline" ? palette.blue : palette.faint
285-
context.globalAlpha = done && move.kind !== "outline" ? 0.55 : 1
286-
// Outlines vanish under the ink once a letter is filled; the grid and metrics stay faint.
287-
if (!(done && move.kind === "outline")) hairline(move.from, move.to, progress)
292+
// Outlines fade under the ink once the plot is done; the grid and metrics stay faint.
293+
context.globalAlpha = fade(move.kind === "outline" ? 0 : 0.55)
294+
hairline(move.from, move.to, progress)
288295
context.globalAlpha = 1
289296
segments += progress === 1 ? 1 : 0
290297
travelled += length(move) * progress
291298
pen = { at, down: true }
292299
}
293300
if (move.kind === "travel") {
294-
if (!done && move.phase === phase) {
301+
if (move.phase === phase && settle < 1) {
295302
context.fillStyle = palette.blue
296-
context.globalAlpha = 0.45
303+
context.globalAlpha = 0.45 * fade(0)
297304
hairline(move.from, move.to, progress, true)
298305
context.globalAlpha = 1
299306
}
@@ -308,8 +315,8 @@ export function CoverTitle() {
308315
if (progress === 1) {
309316
filled.add(move.letter)
310317
context.fillStyle = palette.blue
311-
context.globalAlpha = done ? 0.6 : 1
312-
ticks(move.letter)
318+
context.globalAlpha = fade(0.6)
319+
ticks(move.letter, everyLabel || move.letter === 0)
313320
context.globalAlpha = 1
314321
} else if (shown > 0) {
315322
const [col, row] = order[shown - 1]
@@ -334,7 +341,8 @@ export function CoverTitle() {
334341
context.fillStyle = palette.ink
335342
for (const letter of filled) fillLetter(letter)
336343

337-
if (done || !pen) return
344+
if (settle === 1 || !pen) return
345+
context.globalAlpha = fade(0)
338346
// The pen: a filled square when down, an open one when up; its position in font units beside it.
339347
const px = X(pen.at[0])
340348
const py = Y(pen.at[1])
@@ -361,32 +369,50 @@ export function CoverTitle() {
361369
canvas.height - Math.round(md * 0.35),
362370
)
363371
context.textAlign = "left"
372+
context.globalAlpha = 1
364373
}
365374

375+
// The plot's own clock: it advances only while frames run, so pausing off screen resumes in place.
366376
const tick = (now: number) => {
367-
started ??= now
368-
const t = now - started
369-
draw(t)
370-
frame = t < END ? requestAnimationFrame(tick) : 0
377+
// A long gap (a background tab) resumes where it left off instead of skipping ahead.
378+
elapsed += last === undefined ? 0 : Math.min(now - last, 100)
379+
last = now
380+
draw(elapsed)
381+
frame = elapsed < END ? requestAnimationFrame(tick) : 0
382+
}
383+
const resume = () => {
384+
if (reduced || frame || elapsed >= END) return
385+
last = undefined
386+
frame = requestAnimationFrame(tick)
371387
}
372388
const play = () => {
373389
if (reduced) return
374390
cancelAnimationFrame(frame)
375-
started = undefined
376-
frame = requestAnimationFrame(tick)
391+
frame = 0
392+
played = true
393+
elapsed = 0
394+
resume()
377395
}
378396

379397
layout()
380-
draw(reduced ? END : 0)
398+
draw(elapsed)
399+
// The readout and labels are canvas text: start once the mono font is in, so they don't swap faces mid-plot.
400+
const fontReady = document.fonts.load(`${10 * dpr}px "OpenTUI Mono"`).catch(() => undefined)
381401

402+
// Starts once most of the title is in view, and pauses whenever it leaves the screen.
382403
const observer = new IntersectionObserver(
383404
([entry]) => {
384-
if (!entry.isIntersecting) return
385-
observer.disconnect()
386-
if (reduced) return draw(END)
387-
play()
405+
if (!entry.isIntersecting) {
406+
cancelAnimationFrame(frame)
407+
frame = 0
408+
return
409+
}
410+
if (played) return resume()
411+
if (entry.intersectionRatio < 0.6) return
412+
played = true
413+
void fontReady.then(play)
388414
},
389-
{ threshold: 0.6 },
415+
{ threshold: [0, 0.6] },
390416
)
391417
observer.observe(root)
392418
root.addEventListener("click", play)
@@ -396,13 +422,13 @@ export function CoverTitle() {
396422
if (root.clientWidth === width) return
397423
width = root.clientWidth
398424
layout()
399-
if (!frame) draw(END)
425+
if (!frame) draw(elapsed)
400426
})
401427
resize.observe(root)
402428

403429
const repaint = () => {
404430
layout()
405-
if (!frame) draw(END)
431+
if (!frame) draw(elapsed)
406432
}
407433
const site = root.closest("[data-site]")
408434
const themeObserver = new MutationObserver(repaint)

‎services/site/src/component/font/typewriter.tsx‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,17 @@ export function Typewriter() {
493493
})
494494
})
495495

496+
const claim = () => (
497+
<>
498+
A TYPEFACE WITH{" "}
499+
<span data-slot="count">
500+
{fontContent.combinations.base}
501+
<sup>{fontContent.combinations.exponent}</sup>
502+
</span>{" "}
503+
POSSIBLE COMBINATIONS
504+
</>
505+
)
506+
496507
return (
497508
<section data-component="font-hero" aria-label="Logo typewriter">
498509
<h1 data-slot="sr-only">{fontContent.title}</h1>
@@ -514,16 +525,11 @@ export function Typewriter() {
514525
</textarea>
515526
{/* The server renders the starting wordmark, so the hero is never empty before hydration. */}
516527
<div ref={output} class="letter-output" aria-hidden="true" innerHTML={initialLetters} />
528+
{/* Phones show the claim under the wordmark instead of in the bar; CSS shows one of the two. */}
529+
<p data-slot="phone-copy">{claim()}</p>
517530
</div>
518531
<div data-slot="top-bar">
519-
<p data-slot="top-copy">
520-
A TYPEFACE WITH{" "}
521-
<span data-slot="count">
522-
{fontContent.combinations.base}
523-
<sup>{fontContent.combinations.exponent}</sup>
524-
</span>{" "}
525-
POSSIBLE COMBINATIONS
526-
</p>
532+
<p data-slot="top-copy">{claim()}</p>
527533
<div data-slot="tools" role="group" aria-label="Canvas controls">
528534
<div ref={gifControl} class="gif-control" aria-hidden="true" inert>
529535
<button

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,11 @@
657657
}
658658
}
659659

660+
/* A phone shows the logo and ARCADE only: its message follows, not the game menu. */
661+
&[data-phone] [data-slot="start"] .arcade-press {
662+
display: none;
663+
}
664+
660665
[data-slot="menu"] {
661666
position: absolute;
662667
inset: 0;

0 commit comments

Comments
 (0)