Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ just verify

`npm run check:audit` runs `npm audit` and fails on any advisory at moderate or above. There are no accepted advisories in `scripts/audit.mjs`. The `miniflare` override in `package.json` pins the patched `undici` 7.30.1 while the Cloudflare development tools still pin an affected release; remove the override when their dependency is patched.

vinext 1.0.1 includes `@vercel/og` 1.0.3 with the Satori SVG-escaping fix and the framework's HarfBuzz runtime support. The `satori` override pins `fflate` 0.7.5 to fix its ZIP64 parsing advisory while Satori pins 0.7.3; remove that override once Satori uses a patched release. The lockfile also keeps `@hono/node-server` and `systeminformation` on patched versions within their existing dependency ranges.
vinext 1.0.1 includes `@vercel/og` 1.0.3 with the Satori SVG-escaping fix and the framework's HarfBuzz runtime support. The `satori` override pins `fflate` 0.7.5 to fix its ZIP64 parsing advisory while Satori pins 0.7.3; remove that override once Satori uses a patched release. The `@ts-morph/common` override moves `minimatch` to 11.0.3 for its globparts denial-of-service advisory; it is reached only through the `shadcn` CLI (via `ts-morph`), whose newest release still asks for `minimatch` 10, which has no patched version. Remove it once `@ts-morph/common` depends on `minimatch` 11. The lockfile also keeps `@hono/node-server` and `systeminformation` on patched versions within their existing dependency ranges.

The Website GitHub Actions workflow (`.github/workflows/website.yml`) runs the same checks, plus a deploy dry run, on every pull request and push to `website`, without deploying. Pull requests stacked on `fix/website-*` branches also run these checks. A second job warns when the recorded documentation is behind `main`. The production check visits every documentation page, validates asset responses and the security headers on pages, redirects and static files, checks raw-head metadata and share cards, checks that each labelled control's name contains its visible text, and verifies not-found responses and redirects. On Node 24, CI also runs the Playwright Chromium and Firefox suite (`npm run test:browser`) against the built Worker. It covers journey selection, game completion, search loading and recovery, route announcements, code copying, keyboard-operated comparison controls, catalogue toggles, mobile Escape handling, logo picking, sidebar search sizing and scrolling, narrow layouts, and the reported catalogue and retro contrast regressions. The main checks also run on the declared minimum Node 22.18.0. For local browser checks, run `npx playwright install chromium firefox`, `npm run build`, then `npm run test:browser`; Playwright starts and stops its own local Worker and blocks outside requests. These checks do not replace testing with screen readers or native browser zoom.
The Website GitHub Actions workflow (`.github/workflows/website.yml`) runs the same checks, plus a deploy dry run, on every pull request and push to `website`, without deploying. Pull requests stacked on `fix/website-*` branches also run these checks. A second job warns when the recorded documentation is behind `main`. The production check visits every documentation page, validates asset responses and the security headers on pages, redirects and static files, checks raw-head metadata and share cards, checks that each labelled control's name contains its visible text, and verifies not-found responses and redirects. On Node 24, CI also runs the Playwright Chromium and Firefox suite (`npm run test:browser`) against the built Worker. It covers journey selection, game completion, search loading and recovery, route announcements, code copying, keyboard-operated comparison controls, catalogue toggles, mobile Escape handling, logo picking and its report card, sidebar search sizing and scrolling, narrow layouts, and the reported catalogue and retro contrast regressions. The main checks also run on the declared minimum Node 22.18.0. For local browser checks, run `npx playwright install chromium firefox`, `npm run build`, then `npm run test:browser`; Playwright starts and stops its own local Worker and blocks outside requests. These checks do not replace testing with screen readers or native browser zoom.

To run only Firefox, use `npm run test:browser -- --project=firefox`. If the bundled Firefox fails to start on macOS 27 with “Could not find profile folder”, give the test browser separate application data directories ([upstream issue](https://github.com/microsoft/playwright/issues/42768)):

Expand Down Expand Up @@ -97,7 +97,7 @@ The root layout loads Simple Analytics for page views. A delegated click listene
- `/important` is a seven-round specificity boss battle with hints, explanations, actual isolated CSS previews, scoring and replay. A quiet `{ !important }` footer link and an exact `!important` search lead to it. The examples cover matching, unlayered author declarations; the page links to MDN for the wider cascade and stays out of the sitemap.
- Search `c0ffee` or `#c0ffee` for a short, replayable coffee party. The non-modal message can be dismissed, and reduced-motion visitors get a still celebration. Ordinary search results remain available.
- The favicon sleeps when the tab is hidden and restores the original icons on return, including icons replaced during navigation. It uses a local SVG.
- Drag the fxcss logo in the header or footer and it becomes `fxcss pick` for the site: whatever it is over gets the picker's pink outline, with the element's classes labelled underneath (above, near the bottom of the window). It labels the nearest element that has a class. When some of an element's classes come from the site's own stylesheet rather than Tailwind's utility layer, only those are shown; utility-only lists are shortened. Release, or press Escape, and the logo returns; reduced-motion visitors skip the flight. Dropping it activates nothing, and a click without a drag still goes home. Mouse and pen only, so touch scrolling and taps behave as before.
- Drag the fxcss logo in the header or footer out past its edge and it becomes `fxcss pick` for the site. Until the pointer leaves the logo the press stays a click, however much it wobbles, so a shaky click still goes home. Once lifted, whatever it is over gets the picker's pink outline, with the element's classes labelled underneath (above, near the bottom of the window). It labels the nearest element that has a class. When some of an element's classes come from the site's own stylesheet rather than Tailwind's utility layer, only those are shown; utility-only lists are shortened. Release it over an element to pick it, as a click does in `fxcss pick`: a terminal-style card beside the element prints the CLI's report for it, with its tag and selector, classes (the site's own first), box, notable computed styles and the rules on the site that match it, with rules naming one of its classes listed first and Tailwind's layered rules marked by layer. The card copies the selector and links to the `fxcss pick` documentation. It looks like the terminal of the current time-machine stop: an MS-DOS Prompt in 1999, Terminal on Mac OS X in 2003, and an xterm in 2002. The report itself follows the page, so it lists the time machine's `html[data-retro]` rules when they apply. It is a non-modal dialog that takes focus; Escape or its close button returns focus to the logo, and a press elsewhere or leaving the page closes it. Carry the logo back onto itself, release it outside the page, or press Escape during the drag, and nothing is picked or followed. Either way the logo returns; reduced-motion visitors skip the flight and the card's fade. Dropping it activates nothing underneath, and a click without a drag still goes home. Mouse and pen only, so touch scrolling and taps behave as before.

## Screenshot evidence

Expand Down
105 changes: 68 additions & 37 deletions app/components/brand-link.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useEffect, useRef, useState, type ReactNode } from 'react';
import { followLogoPress } from '../../lib/logo-picker';
import { pickReport, type PickReport } from '../../lib/pick-report';
import { PickCard } from './pick-card';

export function BrandLink({ children }: { children: ReactNode }) {
// Keep an active turn latched when pointer or keyboard focus leaves.
const [spinning, setSpinning] = useState(false);
// Ends a logo drag that outlives the link, such as across navigation.
const stopPicking = useRef<() => void>(undefined);
const link = useRef<HTMLAnchorElement>(null);
// The element a dropped logo picked, reported as `fxcss pick` would.
const [picked, setPicked] = useState<{
element: Element;
report: PickReport;
/** A report describes one page, so it closes when the page changes. */
pathname: string;
}>();
const pathname = usePathname();
// Leaving the page drops its report, so coming back does not revive it.
if (picked && picked.pathname !== pathname) setPicked(undefined);

useEffect(() => {
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
Expand All @@ -31,43 +45,60 @@ export function BrandLink({ children }: { children: ReactNode }) {
setSpinning(true);
}

// The card is the link's sibling, not its child: React events bubble
// through portals, and the link would treat a press on the card as its own.
return (
<Link
className="brand"
href="/"
aria-label="fxcss home"
draggable={false}
data-spinning={spinning || undefined}
onPointerEnter={(event) => {
if (event.pointerType !== 'touch') startSpin();
}}
onPointerDown={(event) => {
// Mouse and pen can pick up the mark. Touch keeps scrolling and
// tapping, and modified clicks keep opening new tabs and windows.
if (
event.pointerType === 'touch' ||
!event.isPrimary ||
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey
)
return;
stopPicking.current?.();
stopPicking.current = followLogoPress(
event.currentTarget,
event.nativeEvent,
);
}}
onFocus={(event) => {
if (event.currentTarget.matches(':focus-visible')) startSpin();
}}
onAnimationEnd={(event) => {
if (event.animationName === 'fxcss-flame-spin') setSpinning(false);
}}
>
{children}
</Link>
<>
<Link
ref={link}
className="brand"
href="/"
aria-label="fxcss home"
draggable={false}
data-spinning={spinning || undefined}
onPointerEnter={(event) => {
if (event.pointerType !== 'touch') startSpin();
}}
onPointerDown={(event) => {
// Mouse and pen can pick up the mark. Touch keeps scrolling and
// tapping, and modified clicks keep opening new tabs and windows.
if (
event.pointerType === 'touch' ||
!event.isPrimary ||
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey
)
return;
stopPicking.current?.();
stopPicking.current = followLogoPress(
event.currentTarget,
event.nativeEvent,
(element) =>
setPicked({ element, report: pickReport(element), pathname }),
);
}}
onFocus={(event) => {
if (event.currentTarget.matches(':focus-visible')) startSpin();
}}
onAnimationEnd={(event) => {
if (event.animationName === 'fxcss-flame-spin') setSpinning(false);
}}
>
{children}
</Link>
{picked && (
<PickCard
element={picked.element}
report={picked.report}
onClose={(restoreFocus) => {
setPicked(undefined);
if (restoreFocus) link.current?.focus({ preventScroll: true });
}}
/>
)}
</>
);
}
152 changes: 152 additions & 0 deletions app/components/pick-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
'use client';

import Link from 'next/link';
import {
useEffect,
useEffectEvent,
useId,
useLayoutEffect,
useRef,
useState,
} from 'react';
import { createPortal } from 'react-dom';
import { Check, Copy, X } from 'lucide-react';
import { labelPosition } from '../../lib/logo-picker';
import { reportLines, type PickReport } from '../../lib/pick-report';

/**
* What a dropped logo picked, printed the way `fxcss pick` prints a click.
* A non-modal dialog beside the element: Escape, the close button, a press
* anywhere else or leaving the page closes it.
*/
export function PickCard({
element,
report,
onClose,
}: {
element: Element;
report: PickReport;
/** `true` when focus should go back to the logo. */
onClose: (restoreFocus: boolean) => void;
}) {
const card = useRef<HTMLDialogElement>(null);
const heading = useId();
const [status, setStatus] = useState('');
const statusTimer = useRef<ReturnType<typeof setTimeout>>(undefined);
const close = useEffectEvent(onClose);
const [header, ...details] = reportLines(report);

// Beside the element, as the label was, and still beside it after scrolling.
useLayoutEffect(() => {
const node = card.current!;
const view = node.ownerDocument.defaultView!;
const root = node.ownerDocument.documentElement;
let frame = 0;
function place() {
frame = 0;
if (!element.isConnected) return close(false);
const { left, top } = labelPosition(
element.getBoundingClientRect(),
{ width: node.offsetWidth, height: node.offsetHeight },
{ width: root.clientWidth, height: root.clientHeight },
6,
8,
);
node.style.translate = `${left}px ${top}px`;
}
function schedule() {
frame ||= view.requestAnimationFrame(place);
}
place();
node.focus({ preventScroll: true });
view.addEventListener('scroll', schedule, { capture: true, passive: true });
view.addEventListener('resize', schedule);
return () => {
view.cancelAnimationFrame(frame);
view.removeEventListener('scroll', schedule, { capture: true });
view.removeEventListener('resize', schedule);
};
}, [element]);

useEffect(() => {
const node = card.current!;
const doc = node.ownerDocument;
function pressElsewhere(event: PointerEvent) {
if (!node.contains(event.target as Node)) close(false);
}
// Only while focus is in the card; search and the time machine keep theirs.
function escape(event: KeyboardEvent) {
if (event.key !== 'Escape') return;
event.preventDefault();
event.stopPropagation();
close(true);
}
doc.addEventListener('pointerdown', pressElsewhere, true);
node.addEventListener('keydown', escape);
return () => {
doc.removeEventListener('pointerdown', pressElsewhere, true);
node.removeEventListener('keydown', escape);
clearTimeout(statusTimer.current);
};
}, []);

async function copy() {
try {
await navigator.clipboard.writeText(report.selector);
setStatus('Copied');
} catch {
setStatus('Select the selector and copy it manually.');
}
clearTimeout(statusTimer.current);
statusTimer.current = setTimeout(() => setStatus(''), 3000);
}

return createPortal(
// Open without showModal: the rest of the page stays usable.
<dialog
ref={card}
open
className="pick-card"
aria-labelledby={heading}
tabIndex={-1}
>
<div className="pick-card-bar">
<span id={heading}>
{/* The prompt changes with the time machine: $, C:\> or %. */}
<span className="pick-card-prompt" aria-hidden="true" />
fxcss pick
</span>
<button
type="button"
className="pick-card-close"
aria-label="Close fxcss pick"
onClick={() => onClose(true)}
>
<X size={15} aria-hidden="true" />
</button>
</div>
<pre className="pick-card-report">
{/* One block per line, so a wrapped rule hangs under its own start. */}
<strong>{header}</strong>
{details.map((line, index) => (
<span key={index}>{line}</span>
))}
</pre>
<div className="pick-card-actions">
<button type="button" onClick={copy}>
{status === 'Copied' ? (
<Check size={14} aria-hidden="true" />
) : (
<Copy size={14} aria-hidden="true" />
)}
Copy selector
</button>
<Link href="/docs/pick" onClick={() => onClose(false)}>
Pick Firefox’s UI with fxcss pick
</Link>
<output className="pick-card-status">{status}</output>
</div>
</dialog>,
element.ownerDocument.body,
);
}
Loading
Loading