diff --git a/web/DESIGN.md b/web/DESIGN.md index d6c39de..8a27cfb 100644 --- a/web/DESIGN.md +++ b/web/DESIGN.md @@ -17,6 +17,11 @@ colors: text-primary: "#f4f4f5" text-secondary: "#a1a1aa" text-tertiary: "#8a8a93" + accent-text: "#4aa6ff" + success-text: "#34c759" + warning-text: "#ff9f0a" + liquid-glass-tint: "rgba(10, 132, 255, 0.18)" + liquid-glass-border: "rgba(10, 132, 255, 0.5)" light: background: "#ffffff" surface: "#fafafa" @@ -26,17 +31,28 @@ colors: border-focus: "#0071e3" text-primary: "#09090b" text-secondary: "#52525b" - text-tertiary: "#8a8a93" + text-tertiary: "#5c5c66" + accent-text: "#0057b8" + success-text: "#146c2e" + warning-text: "#8a5a00" + liquid-glass-tint: "rgba(0, 113, 227, 0.12)" + liquid-glass-border: "rgba(0, 113, 227, 0.4)" brand: apple-blue: "#0071e3" apple-blue-vibrant: "#0a84ff" - swift-orange: "#FA7343" - liquid-glass-tint: "rgba(10, 132, 255, 0.15)" - liquid-glass-border: "rgba(10, 132, 255, 0.4)" + swift-orange: "#fa7343" semantic: + success: "#34c759" + warning: "#ff9f0a" + chrome: + note: "Literal greens kept inside surfaces that stay dark in either page + theme (the installer console, the simulated macOS chrome, the mock + terminal illustrations). They are not theme tokens." success: "#30d158" - warning: "#ffd60a" - danger: "#ff453a" + status-dot: "#10b981" + traffic-red: "#ff5f56" + traffic-yellow: "#ffbd2e" + traffic-green: "#27c93f" typography: display: fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif' @@ -112,6 +128,7 @@ FlowSnap's landing page embodies the craftsmanship of native macOS applications: 5. **Hairline Precision**: Card borders, dividers, and modal frames must strictly be `1px solid` with low opacity (`rgba(255,255,255,0.08)` on dark mode). 6. **Type Floor Is 11px**: `meta` (11px) and `label` (13px) are the documented steps under `xs`/`sm`. Nothing may render below 11px, including `rem` values that compute smaller. 7. **Mono Means Code or Data**: metadata that is a sentence (`.license-tag`, `.spec-chip`, `.pillar-badge`, `.hint-label`, `.toggle-label`, `.audit-link`) uses the body stack at the `meta` size. Mono stays on keycaps, prompts, digests and counts. +8. **Brand and status colours need a text shade**: the raw brand values (`#0a84ff`, `#34c759`, `#ff9f0a`) are tuned for dark and fail AA when used as 11-13px text on light surfaces. Text uses `var(--brand-apple-blue-vibrant)` (= `accent-text` above), `var(--color-success-text)` and `var(--color-warning-text)`; the raw tokens stay for dots, fills, glows and icons. Anything that renders its own dark chrome (`.static-preview-frame`, `.mac-desktop-frame`) pins those tokens locally instead of inheriting the page theme. ### DON'T: diff --git a/web/package.json b/web/package.json index 895924c..efd528d 100644 --- a/web/package.json +++ b/web/package.json @@ -10,7 +10,7 @@ "build": "astro build", "preview": "astro preview", "pretest": "astro build", - "test": "node tests/desktop-simulator.test.mjs && node tests/mobile-nav.test.mjs && node tests/bento-shortcuts.test.mjs && node tests/distribution-hub.test.mjs && node tests/seo-cicd.test.mjs", + "test": "node tests/desktop-simulator.test.mjs && node tests/mobile-nav.test.mjs && node tests/bento-shortcuts.test.mjs && node tests/distribution-hub.test.mjs && node tests/design-tokens.test.mjs && node tests/seo-cicd.test.mjs", "astro": "astro" }, "dependencies": { diff --git a/web/src/components/Footer.astro b/web/src/components/Footer.astro index 974d1ad..bed1097 100644 --- a/web/src/components/Footer.astro +++ b/web/src/components/Footer.astro @@ -162,7 +162,7 @@ const currentYear = new Date().getFullYear(); } .dot { - color: var(--accent-blue); + color: var(--text-tertiary); } .footer-heading { diff --git a/web/src/components/GatekeeperGuide.astro b/web/src/components/GatekeeperGuide.astro index f62bc4b..f9d2f7c 100644 --- a/web/src/components/GatekeeperGuide.astro +++ b/web/src/components/GatekeeperGuide.astro @@ -249,7 +249,7 @@ const t = getI18n(lang); .gatekeeper-badge { font-size: var(--font-size-meta); font-family: var(--font-body); - color: var(--color-warning); + color: var(--color-warning-text); background: rgba(255, 214, 10, 0.1); border: 1px solid rgba(255, 214, 10, 0.25); padding: 1px 6px; diff --git a/web/src/components/Header.astro b/web/src/components/Header.astro index 54fe4c9..bdb0ec0 100644 --- a/web/src/components/Header.astro +++ b/web/src/components/Header.astro @@ -193,13 +193,18 @@ const viUrl = `${basePath || ''}/vi`; top: 0; z-index: 50; width: 100%; - backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); background-color: rgba(255, 255, 255, 0.85); border-bottom: 1px solid var(--border-color); transition: background-color var(--duration-normal) ease, border-color var(--duration-normal) ease; } + /* Firefox has never accepted -webkit-backdrop-filter, and the CSS + minifier deletes the unprefixed twin of a prefixed declaration. */ + @supports (backdrop-filter: blur(1px)) { + .site-header { backdrop-filter: blur(20px); } + } + :global([data-theme="dark"]) .site-header, :global(:root:not([data-theme="light"])) .site-header { background-color: rgba(9, 9, 11, 0.82); diff --git a/web/src/components/UnifiedInstaller.astro b/web/src/components/UnifiedInstaller.astro index 5f170ef..efe92d2 100644 --- a/web/src/components/UnifiedInstaller.astro +++ b/web/src/components/UnifiedInstaller.astro @@ -56,6 +56,7 @@ const curlTab = TERMINAL_TABS.find((tab) => tab.id === 'curl') || TERMINAL_TABS[ class="installer-tab active" role="tab" aria-selected="true" + tabindex="0" aria-controls="panel-dmg" id="tab-dmg" data-install-tab="dmg" @@ -71,6 +72,7 @@ const curlTab = TERMINAL_TABS.find((tab) => tab.id === 'curl') || TERMINAL_TABS[ class="installer-tab" role="tab" aria-selected="false" + tabindex="-1" aria-controls="panel-terminal" id="tab-curl" data-install-tab="curl" @@ -245,6 +247,22 @@ const curlTab = TERMINAL_TABS.find((tab) => tab.id === 'curl') || TERMINAL_TABS[ let currentCommand = commandCode?.textContent?.trim() || ''; + root.querySelector('[role="tablist"]')?.addEventListener('keydown', (event) => { + const key = (event as KeyboardEvent).key; + if (!['ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(key)) return; + event.preventDefault(); + const list = Array.from(tabs) as HTMLButtonElement[]; + const current = list.indexOf(document.activeElement as HTMLButtonElement); + if (current === -1) return; + const next = + key === 'ArrowRight' ? (current + 1) % list.length + : key === 'ArrowLeft' ? (current - 1 + list.length) % list.length + : key === 'Home' ? 0 + : list.length - 1; + list[next].focus(); + list[next].click(); + }); + tabs.forEach((tab) => { tab.addEventListener('click', () => { const tabId = tab.getAttribute('data-install-tab'); @@ -256,6 +274,8 @@ const curlTab = TERMINAL_TABS.find((tab) => tab.id === 'curl') || TERMINAL_TABS[ tab.classList.add('active'); tab.setAttribute('aria-selected', 'true'); + // One Tab stop for the whole strip; the arrows carry the rest. + tabs.forEach((t) => t.setAttribute('tabindex', t === tab ? '0' : '-1')); const newDesc = tab.getAttribute('data-description') || ''; if (tabDesc && newDesc) tabDesc.textContent = newDesc; diff --git a/web/src/pages/index.astro b/web/src/pages/index.astro index 3a680dd..f0bdad5 100644 --- a/web/src/pages/index.astro +++ b/web/src/pages/index.astro @@ -140,7 +140,7 @@ const t = getI18n(lang); } .badge-separator { - color: var(--accent-blue); + color: var(--text-tertiary); margin: 0 4px; } @@ -191,7 +191,7 @@ const t = getI18n(lang); .hint-divider { margin: 0 4px; - color: var(--border-color); + color: var(--text-tertiary); } /* Sections Container */ diff --git a/web/src/pages/vi/index.astro b/web/src/pages/vi/index.astro index 532e220..9257aec 100644 --- a/web/src/pages/vi/index.astro +++ b/web/src/pages/vi/index.astro @@ -140,7 +140,7 @@ const t = getI18n(lang); } .badge-separator { - color: var(--accent-blue); + color: var(--text-tertiary); margin: 0 4px; } @@ -191,7 +191,7 @@ const t = getI18n(lang); .hint-divider { margin: 0 4px; - color: var(--border-color); + color: var(--text-tertiary); } /* Sections Container */ diff --git a/web/src/styles/design-tokens.css b/web/src/styles/design-tokens.css index 30e5ff0..60f8daa 100644 --- a/web/src/styles/design-tokens.css +++ b/web/src/styles/design-tokens.css @@ -33,7 +33,9 @@ --accent-blue-vibrant: #0a84ff; --accent-swift: #fa7343; --brand-apple-blue: var(--accent-blue); - --brand-apple-blue-vibrant: var(--accent-blue-vibrant); + /* -vibrant is only ever used as 11-12px text on page surfaces, so light + uses the AA-passing shade (#0a84ff measures 3.1:1 on the chip tints). */ + --brand-apple-blue-vibrant: #0057b8; /* Liquid Glass HUD */ --liquid-glass-bg: rgba(0, 113, 227, 0.12); @@ -83,6 +85,10 @@ /* Status */ --color-success: #34c759; --color-warning: #ff9f0a; + /* Status colours used as TEXT on light surfaces need the dark shade: + #34c759 is 2.0:1 and #ff9f0a is 1.9:1 on their own tinted chips. */ + --color-success-text: #146c2e; + --color-warning-text: #8a5a00; /* Radii */ --radius-sm: 6px; @@ -126,7 +132,9 @@ --accent-blue: #0a84ff; --accent-blue-vibrant: #0a84ff; --brand-apple-blue: var(--accent-blue); - --brand-apple-blue-vibrant: var(--accent-blue-vibrant); + --brand-apple-blue-vibrant: #4aa6ff; + --color-success-text: #34c759; + --color-warning-text: #ff9f0a; --liquid-glass-bg: rgba(10, 132, 255, 0.18); --liquid-glass-border: rgba(10, 132, 255, 0.5); } @@ -158,7 +166,9 @@ --accent-blue: #0a84ff; --accent-blue-vibrant: #0a84ff; --brand-apple-blue: var(--accent-blue); - --brand-apple-blue-vibrant: var(--accent-blue-vibrant); + --brand-apple-blue-vibrant: #4aa6ff; + --color-success-text: #34c759; + --color-warning-text: #ff9f0a; --liquid-glass-bg: rgba(10, 132, 255, 0.18); --liquid-glass-border: rgba(10, 132, 255, 0.5); } diff --git a/web/src/styles/desktop-simulator.css b/web/src/styles/desktop-simulator.css index 56298c3..eab9241 100644 --- a/web/src/styles/desktop-simulator.css +++ b/web/src/styles/desktop-simulator.css @@ -1,3 +1,9 @@ +/* The simulated macOS chrome stays dark in either page theme, so its accent + tokens are pinned here instead of inheriting the page theme (#0a84ff and + #0071e3 both land under 4.5:1 on the chrome surfaces). */ +.static-preview-frame, +.mac-desktop-frame { --accent-blue-vibrant: #4aa6ff; } + .simulator-wrapper { display: flex; flex-direction: column; gap: 14px; width: 100%; user-select: none; } .sandbox-toolbar { @@ -92,7 +98,6 @@ justify-content: space-between; padding: 0 12px; background: rgba(18, 18, 22, 0.86); - backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-size: 0.75rem; @@ -129,7 +134,6 @@ right: 48px; width: 250px; background: rgba(24, 24, 30, 0.96); - backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 12px; @@ -200,7 +204,6 @@ left: 50%; transform: translate(-50%, -120%) scale(0.95); background: rgba(22, 22, 28, 0.94); - backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 0 0 14px 14px; @@ -237,7 +240,6 @@ .template-label { font-size: 0.6875rem; color: rgba(255, 255, 255, 0.6); font-weight: 500; } /* Liquid Glass HUD Snap Preview */ .hud-snap-preview { position: absolute; background: var(--liquid-glass-bg); - backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1.5px solid var(--accent-blue); border-radius: 12px; @@ -252,7 +254,6 @@ .hud-snap-preview.is-active { opacity: 1; transform: scale(1); } .hud-preview-content { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; } .hud-preview-badge { padding: 4px 12px; background: rgba(0, 88, 208, 0.92); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 20px; font-size: 0.75rem; font-weight: 600; color: #ffffff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); } /* Mock Windows (Shared Window Styling) */ .mock-window { position: absolute; background: rgba(22, 22, 28, 0.94); - backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px; @@ -261,19 +262,28 @@ flex-direction: column; overflow: hidden; z-index: 30; - transition: left 0.22s var(--ease-spring), top 0.22s var(--ease-spring), width 0.22s var(--ease-spring), height 0.22s var(--ease-spring), box-shadow 0.2s ease, opacity 0.2s ease; + transition: left 0.22s var(--ease-spring), top 0.22s var(--ease-spring), width 0.22s var(--ease-spring), height 0.22s var(--ease-spring), box-shadow 0.2s ease, opacity 0.2s ease, visibility 0s; } .mock-window.active-window { z-index: 35; box-shadow: 0 25px 50px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.15); } .mock-window.is-dragging { transition: none !important; cursor: grabbing; z-index: 40 !important; box-shadow: 0 35px 70px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(10, 132, 255, 0.5); } -.mock-window.is-hidden { opacity: 0; pointer-events: none; transform: scale(0.9); } +.mock-window.is-hidden { opacity: 0; pointer-events: none; transform: scale(0.9); + /* opacity alone keeps the three traffic-light buttons in the tab ring, so a + closed window still eats Tab presses. visibility flips after the 0.2s fade + and snaps back to visible the moment the class is removed. */ + visibility: hidden; + transition-delay: 0s, 0s, 0s, 0s, 0s, 0s, 0.2s; +} /* Specific Window Positions */ #mock-window-code { left: 8%; top: 10%; width: 54%; height: 70%; } -#mock-window-terminal { left: 48%; top: 22%; width: 46%; height: 62%; } +/* The terminal used to start at 48%, inside the code window's 8-62% span, so + its five output lines sat covered at rest. 66% clears the overlap at every + stage width without moving the code window. */ +#mock-window-terminal { left: 66%; top: 22%; width: 30%; height: 62%; } .mock-titlebar { height: 36px; @@ -288,9 +298,13 @@ touch-action: none; } -.traffic-lights { display: flex; align-items: center; gap: 7px; } .traffic-light { width: 11px; height: 11px; border-radius: 50%; border: none; padding: 0; cursor: pointer; transition: opacity 0.15s ease; } .traffic-light:hover { opacity: 0.8; } .traffic-light.red { background: #ff5f56; } .traffic-light.yellow { background: #ffbd2e; } .traffic-light.green { background: #27c93f; } .titlebar-info { display: flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, 0.85); font-size: 0.75rem; font-weight: 500; } .file-icon { color: var(--accent-swift); } .terminal-mini-icon { color: #10b981; } .snap-status-badge { +.traffic-lights { display: flex; align-items: center; gap: 7px; } .traffic-light { width: 11px; height: 11px; border-radius: 50%; border: none; padding: 0; cursor: pointer; transition: opacity 0.15s ease; } .traffic-light:hover { opacity: 0.8; } .traffic-light.red { background: #ff5f56; } .traffic-light.yellow { background: #ffbd2e; } .traffic-light.green { background: #27c93f; } .titlebar-info { display: flex; align-items: center; gap: 6px; min-width: 0; color: rgba(255, 255, 255, 0.85); font-size: 0.75rem; font-weight: 500; } .file-icon { color: var(--accent-swift); } .terminal-mini-icon { color: #10b981; } /* The narrower terminal window has to give up its title before the + 36px titlebar breaks onto two lines. */ +.titlebar-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .snap-status-badge { display: flex; align-items: center; + flex-shrink: 0; + white-space: nowrap; gap: 5px; background: rgba(255, 255, 255, 0.08); padding: 2px 8px; @@ -319,7 +333,15 @@ text-align: right; } -.code-content { flex: 1; padding-left: 12px; margin: 0; color: #e4e4e7; overflow-x: auto; } .token-comment { color: #6b7280; } .token-keyword { color: #f472b6; font-weight: 600; } .token-type { color: #38bdf8; } .token-attr { color: #fbbf24; } .token-func { color: #a78bfa; } .mock-terminal-body { flex-direction: column; background: #0b0c10; gap: 4px; color: #e5e7eb; } +.code-content { flex: 1; padding-left: 12px; margin: 0; color: #e4e4e7; overflow-x: auto; } +/* The Swift mock needs 449px and the window gives 335px at 768px, which cut + lines mid-token behind an overlay scrollbar that never shows a track. The + gutter goes with it: ten numbers beside twelve wrapped rows would line up + with nothing. */ +@media (max-width: 1023px) { + .code-content { white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: visible; padding-left: 0; } + .code-line-numbers { display: none; } +} .token-comment { color: #a1a1aa; } .token-keyword { color: #f472b6; font-weight: 600; } .token-type { color: #38bdf8; } .token-attr { color: #fbbf24; } .token-func { color: #a78bfa; } .mock-terminal-body { flex-direction: column; background: #0b0c10; gap: 4px; color: #e5e7eb; } .terminal-line { display: flex; align-items: center; gap: 6px; } .t-prompt { color: #10b981; font-weight: 700; } .t-dir { color: #38bdf8; } .t-cmd { color: #f3f4f6; } .t-output { font-size: 0.6875rem; color: #9ca3af; margin-left: 12px; } .t-green { color: #10b981; } .t-blue { color: #60a5fa; } .t-cursor { animation: blink 1s infinite; color: #10b981; } @keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } } .mock-window-footer { height: 22px; @@ -350,7 +372,6 @@ gap: 10px; padding: 6px 12px; background: rgba(24, 24, 30, 0.75); - backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 18px; @@ -413,7 +434,7 @@ background: rgba(24, 24, 27, 0.88); border: 1px solid rgba(255, 255, 255, 0.28); color: rgba(255, 255, 255, 0.7); - backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); transition: background var(--duration-fast) var(--ease-spring), border-color var(--duration-fast) var(--ease-spring), box-shadow var(--duration-fast) var(--ease-spring), transform var(--duration-fast) var(--ease-spring), opacity var(--duration-fast) var(--ease-spring); } @@ -495,7 +516,7 @@ .static-badge { font-size: 0.6875rem; font-family: var(--font-mono); - color: var(--accent-blue); + color: var(--accent-blue-vibrant); background: rgba(10, 132, 255, 0.16); padding: 1px 4px; border-radius: 3px; @@ -539,3 +560,16 @@ @media (min-width: 768px) and (hover: hover) { .mobile-fallback-card { display: none !important; } } + +/* Firefox has never accepted -webkit-backdrop-filter, and the CSS minifier + deletes the unprefixed twin of a prefixed declaration, so the standard + property lives in its own block instead of next to the pairs above. */ +@supports (backdrop-filter: blur(1px)) { + .mac-menubar { backdrop-filter: blur(16px); } + .fs-menubar-popover { backdrop-filter: blur(24px); } + .snap-picker { backdrop-filter: blur(24px); } + .template-label { backdrop-filter: blur(14px); } + .hud-snap-preview.is-active { backdrop-filter: blur(20px); } + .mac-dock { backdrop-filter: blur(20px); } + .divider-handle { backdrop-filter: blur(10px); } +} diff --git a/web/src/styles/shortcut-matrix.css b/web/src/styles/shortcut-matrix.css index 075e859..b99d7b5 100644 --- a/web/src/styles/shortcut-matrix.css +++ b/web/src/styles/shortcut-matrix.css @@ -37,6 +37,22 @@ display: none; } +/* Six filter chips measure 538px (EN) / 578px (VI), so at phone width the + hidden scrollbar was cutting off Display/Workspace/Utility with no hint that + more existed. Wrapping puts every filter on screen; the scroll rule above + stays as the safety for longer locales at tablet width. */ +@media (max-width: 768px) { + .category-tabs { + flex-wrap: wrap; + border-radius: var(--radius-xl, 18px); + overflow-x: visible; + } + + .cat-tab-btn { + flex-shrink: 1; + } +} + .cat-tab-btn { flex-shrink: 0; display: inline-flex; @@ -288,7 +304,7 @@ } .copy-shortcut-btn.copied { - color: #30d158; + color: var(--color-success-text); border-color: rgba(48, 209, 88, 0.4); background: rgba(48, 209, 88, 0.1); } diff --git a/web/src/styles/unified-installer.css b/web/src/styles/unified-installer.css index 6468c00..c6ced26 100644 --- a/web/src/styles/unified-installer.css +++ b/web/src/styles/unified-installer.css @@ -77,7 +77,9 @@ min-width: 0; } -.version-badge { +/* Scoped to the installer: an unscoped .version-badge here overrode the + shared neutral badge in design-tokens.css for Header and both hero badges. */ +.badge-row .version-badge { display: inline-flex; align-items: center; gap: 5px; @@ -85,7 +87,7 @@ border-radius: var(--radius-full); background: rgba(48, 209, 88, 0.12); border: 1px solid rgba(48, 209, 88, 0.3); - color: var(--color-success); + color: var(--color-success-text); font-size: var(--font-size-meta); font-weight: 600; font-family: var(--font-mono); @@ -135,6 +137,17 @@ display: none; } +/* At 320px the two method segments measured 243px against 180px, hiding + "cURL Script" behind a scrollbar with no track. Equal flex basis keeps both + labels on screen instead of scrolling one out of sight. */ +@media (max-width: 360px) { + .installer-tab { + flex: 1 1 0; + justify-content: center; + padding-inline: 8px; + } +} + .installer-tab { display: inline-flex; align-items: center; @@ -330,9 +343,10 @@ .command-row { display: flex; - align-items: center; + align-items: baseline; gap: 10px; flex: 1; + min-width: 0; overflow: hidden; } @@ -360,8 +374,11 @@ font-family: var(--font-mono); font-size: 12px; color: #f4f4f5; - white-space: nowrap; - line-height: 1.4; + /* nowrap + a hidden scrollbar left 77% of the command invisible at 390px, + including the URL this command pipes straight into /bin/bash. */ + white-space: normal; + overflow-wrap: anywhere; + line-height: 1.5; } .terminal-copy-btn { @@ -513,13 +530,9 @@ display: inline-flex; align-items: center; min-height: 44px; - color: var(--brand-apple-blue); + color: var(--brand-apple-blue-vibrant); text-decoration: underline; text-underline-offset: 3px; - text-decoration-color: rgba(10, 132, 255, 0.4); -} - -.script-check-link:hover { text-decoration-color: currentColor; } @@ -549,11 +562,31 @@ border-width: 0; } +@media (max-width: 640px) { + /* With the copy button inline, only 85px of a 320px screen was left for the + command, so the URL shattered into ten lines. The row takes the full width + and the button drops onto its own line. */ + .console-box { + flex-wrap: wrap; + } + + .command-row { + flex: 1 0 100%; + } +} + @media (max-width: 768px) { .unified-installer-box { padding: 20px; } + /* A wrapped command would stretch the stadium pill, so the console becomes a + terminal card once the command needs more than one line. */ + .console-box { + border-radius: var(--radius-lg); + padding: 12px 16px; + } + .card-header { flex-direction: column; align-items: stretch; diff --git a/web/tests/design-tokens.test.mjs b/web/tests/design-tokens.test.mjs new file mode 100644 index 0000000..7147e7e --- /dev/null +++ b/web/tests/design-tokens.test.mjs @@ -0,0 +1,164 @@ +/** + * design-tokens.test.mjs: guard that web/DESIGN.md describes the tokens that + * actually ship, and that status colours only reach raw hex inside surfaces + * that stay dark in either page theme. + * + * The drift this catches is real: DESIGN.md once carried a light + * `text-tertiary` that no stylesheet defined, listed `danger: #ff453a` and + * `warning: #ffd60a` which appear nowhere in the build, and a single + * liquid-glass value for two different per-theme values. + */ +import { readFileSync, readdirSync } from 'node:fs'; +import { resolve, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import assert from 'node:assert/strict'; + +const root = resolve(fileURLToPath(new URL('.', import.meta.url)), '..'); +const doc = readFileSync(join(root, 'DESIGN.md'), 'utf8'); +const tokensCss = readFileSync(join(root, 'src/styles/design-tokens.css'), 'utf8'); + +const norm = (v) => + v + .trim() + .replace(/^["']|["']$/g, '') + .replace(/,\s*/g, ',') + .toLowerCase(); + +/** Parse the `colors:` block of the frontmatter into { group: { key: value } }. */ +function parseDocColors(text) { + const fm = text.split(/^---$/m)[1]; + const lines = fm.split('\n'); + const out = {}; + let group = null; + for (const line of lines) { + if (/^colors:/.test(line)) { group = null; continue; } + if (/^[a-z]+:/.test(line)) { group = null; continue; } + const g = line.match(/^ ([a-z-]+):$/); + if (g) { group = g[1]; out[group] = {}; continue; } + const kv = line.match(/^ ([a-z-]+): (.+)$/); + if (kv && group && kv[1] !== 'note') out[group][kv[1]] = norm(kv[2]); + } + return out; +} + +/** Return the declarations of one CSS block, keyed by custom property name. */ +function cssBlock(text, selector) { + const at = text.indexOf(selector); + assert.notEqual(at, -1, `block ${selector} not found in design-tokens.css`); + const open = text.indexOf('{', at); + let depth = 0; + for (let i = open; i < text.length; i++) { + if (text[i] === '{') depth++; + else if (text[i] === '}') { + depth--; + if (depth === 0) { + const body = text.slice(open + 1, i); + const decls = {}; + for (const m of body.matchAll(/(--[\w-]+):\s*([^;]+);/g)) decls[m[1]] = norm(m[2]); + return decls; + } + } + } + throw new Error(`unbalanced braces after ${selector}`); +} + +const docColors = parseDocColors(doc); +const lightBlock = cssBlock(tokensCss, ':root {'); +const darkAttr = cssBlock(tokensCss, '[data-theme="dark"] {'); +const darkMedia = cssBlock(tokensCss, ':root:not([data-theme="light"]) {'); + +// doc key -> css custom property +const ROLE_VAR = { + background: '--bg-color', + surface: '--surface-color', + 'surface-elevated': '--surface-elevated', + border: '--border-color', + 'border-subtle': '--border-subtle', + 'border-focus': '--border-focus', + 'text-primary': '--text-primary', + 'text-secondary': '--text-secondary', + 'text-tertiary': '--text-tertiary', + 'accent-text': '--brand-apple-blue-vibrant', + 'success-text': '--color-success-text', + 'warning-text': '--color-warning-text', + 'liquid-glass-tint': '--liquid-glass-bg', + 'liquid-glass-border': '--liquid-glass-border', +}; + +console.log('Checking TC-TOKEN-001: every documented theme colour equals the shipped token...'); +for (const [theme, block] of [['dark', darkAttr], ['light', lightBlock]]) { + const entries = docColors[theme]; + assert.ok(entries && Object.keys(entries).length > 6, `colors.${theme} missing from DESIGN.md`); + for (const [key, value] of Object.entries(entries)) { + const varName = ROLE_VAR[key]; + assert.ok(varName, `DESIGN.md lists colors.${theme}.${key} with no known token role`); + assert.ok(block[varName] !== undefined, `${varName} is not declared in the ${theme} block`); + assert.equal(block[varName], value, `colors.${theme}.${key}: DESIGN.md says ${value}, ${varName} ships ${block[varName]}`); + } +} +console.log('✅ TC-TOKEN-001 Passed!\n'); + +console.log('Checking TC-TOKEN-002: the dark palette is declared in both dark blocks...'); +for (const [key, value] of Object.entries(docColors.dark)) { + assert.equal(darkMedia[ROLE_VAR[key]], value, `colors.dark.${key} matches [data-theme="dark"] but not the prefers-color-scheme block`); +} +console.log('✅ TC-TOKEN-002 Passed!\n'); + +console.log('Checking TC-TOKEN-003: brand and semantic values exist, and nothing documented is fictional...'); +const brandVars = { 'apple-blue': '--accent-blue', 'apple-blue-vibrant': '--accent-blue-vibrant', 'swift-orange': '--accent-swift' }; +for (const [key, value] of Object.entries(docColors.brand)) { + const varName = brandVars[key]; + assert.ok(varName, `colors.brand.${key} has no known token`); + assert.equal(lightBlock[varName], value, `colors.brand.${key}: DESIGN.md ${value} vs ${varName} ${lightBlock[varName]}`); +} +const semanticVars = { success: '--color-success', warning: '--color-warning' }; +for (const [key, value] of Object.entries(docColors.semantic)) { + const varName = semanticVars[key]; + assert.ok(varName, `colors.semantic.${key} is documented but no token role exists for it`); + assert.ok(lightBlock[varName] !== undefined, `colors.semantic.${key} claims ${varName}, which design-tokens.css never declares`); + assert.equal(lightBlock[varName], value, `colors.semantic.${key}: DESIGN.md ${value} vs ${varName} ${lightBlock[varName]}`); +} +console.log('✅ TC-TOKEN-003 Passed!\n'); + +console.log('Checking TC-TOKEN-004: raw status hexes stay inside the always-dark chrome...'); +const CHROME = new Set([ + 'desktop-simulator.css|.terminal-mini-icon', + 'desktop-simulator.css|.t-prompt', + 'desktop-simulator.css|.t-green', + 'desktop-simulator.css|.t-cursor', + 'unified-installer.css|.terminal-prompt', + 'unified-installer.css|.terminal-copy-btn.copied', +]); +const STATUS_HEX = /#(?:30d158|34c759|ff9f0a|ffd60a|ff453a|10b981)\b/i; +const cssFiles = readdirSync(join(root, 'src/styles')).filter((f) => f.endsWith('.css')); +const offenders = []; +for (const file of cssFiles) { + const text = readFileSync(join(root, 'src/styles', file), 'utf8'); + for (const m of text.matchAll(/([^{}]+)\{([^{}]*)\}/g)) { + const selector = m[1].split('\n').pop().trim().replace(/\s+/g, ' '); + if (/color:\s*[^;]*#/.test(m[2]) === false) continue; + for (const decl of m[2].match(/color:\s*[^;]+/g) || []) { + if (STATUS_HEX.test(decl)) offenders.push(`${file}|${selector}`); + } + } +} +for (const o of offenders) { + assert.ok(CHROME.has(o), `${o} paints a status colour straight onto a theme-aware surface; use var(--color-success-text) or var(--color-warning-text)`); +} +assert.ok(offenders.length >= 4, `the chrome allow-list matched only ${offenders.length} rules; the scan itself broke`); +console.log(` ${offenders.length} raw status colours, all inside the always-dark chrome`); +console.log('✅ TC-TOKEN-004 Passed!\n'); + +console.log('Checking TC-TOKEN-005: every documented chrome literal really renders somewhere...'); +const src = [ + ...cssFiles.map((f) => readFileSync(join(root, 'src/styles', f), 'utf8')), + ...readdirSync(join(root, 'src/components')) + .filter((f) => f.endsWith('.astro')) + .map((f) => readFileSync(join(root, 'src/components', f), 'utf8')), +].join('\n'); +for (const [key, value] of Object.entries(docColors.chrome)) { + assert.ok(src.toLowerCase().includes(value), `colors.chrome.${key} documents ${value}, which no source file uses`); +} +console.log('✅ TC-TOKEN-005 Passed!\n'); + +console.log('🎉 All design-token consistency tests passed! (5/5 Test Cases)');