diff --git a/README.md b/README.md
index bf97099..423ccc9 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@ just verify
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.
-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, 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, 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)):
@@ -97,6 +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.
## Screenshot evidence
diff --git a/app/components/brand-link.tsx b/app/components/brand-link.tsx
index c6e4385..8b2f30d 100644
--- a/app/components/brand-link.tsx
+++ b/app/components/brand-link.tsx
@@ -1,11 +1,14 @@
'use client';
import Link from 'next/link';
-import { useEffect, useState, type ReactNode } from 'react';
+import { useEffect, useRef, useState, type ReactNode } from 'react';
+import { followLogoPress } from '../../lib/logo-picker';
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);
useEffect(() => {
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
@@ -17,6 +20,8 @@ export function BrandLink({ children }: { children: ReactNode }) {
reducedMotion.removeEventListener('change', stopForReducedMotion);
}, []);
+ useEffect(() => () => stopPicking.current?.(), []);
+
function startSpin() {
if (
spinning ||
@@ -31,10 +36,30 @@ export function BrandLink({ children }: { children: ReactNode }) {
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();
}}
diff --git a/app/easter-eggs.css b/app/easter-eggs.css
index 4cbb90e..3042bca 100644
--- a/app/easter-eggs.css
+++ b/app/easter-eggs.css
@@ -122,6 +122,21 @@
.coffee-replay { display: flex !important; padding: 8px 0 0; font-size: 12px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.coffee-dismiss { padding: 2px; margin-left: auto; }
+/* The logo picker wears the outline of `fxcss pick`. Its label is a deeper
+ pink so the white selector text keeps 4.9:1 contrast. */
+.brand { user-select: none; }
+.brand[data-picking] .brand-mark { visibility: hidden; }
+html[data-logo-picking], html[data-logo-picking] * { cursor: grabbing !important; }
+.logo-picker-outline, .logo-picker-ghost, .logo-picker-label { position: fixed; top: 0; left: 0; pointer-events: none; }
+.logo-picker-outline { z-index: 1000; box-sizing: border-box; border: 2px solid #ff0080; border-radius: 3px; background: #ff008024; }
+.logo-picker-ghost { z-index: 1001; scale: 1.15; filter: drop-shadow(0 8px 10px #18213947); }
+.logo-picker-ghost .brand-braces { filter: drop-shadow(0 0 12px #00ddef) drop-shadow(0 0 24px #00ddef88); }
+.logo-picker-label { z-index: 1002; max-width: calc(100% - 8px); overflow: hidden; padding: 2px 6px; border-radius: 3px; background: #db0078; color: #fff; font: 12px/1.5 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; text-overflow: ellipsis; white-space: nowrap; }
+@media (prefers-reduced-motion: no-preference) {
+ .logo-picker-ghost { animation: logo-picker-lift 140ms ease-out; }
+}
+@keyframes logo-picker-lift { from { scale: 1; } }
+
/* The arena uses the site's purple, orange and monospace details. */
.battle-page { max-width: 960px; padding-top: 60px; padding-bottom: 100px; }
.battle-intro { margin-bottom: 40px; }
diff --git a/lib/logo-picker.ts b/lib/logo-picker.ts
new file mode 100644
index 0000000..6927f2d
--- /dev/null
+++ b/lib/logo-picker.ts
@@ -0,0 +1,280 @@
+// Drag the fxcss mark across the site and it outlines the element underneath,
+// with its classes labelled below it: `fxcss pick` for the website itself.
+
+/** Movement that turns a press into a drag; anything shorter stays a click. */
+export const PICK_DISTANCE = 4;
+/** Longer class lists are shortened to this many classes and a count. */
+const SHOWN_CLASSES = 3;
+
+type Box = { left: number; top: number; bottom: number };
+type Size = { width: number; height: number };
+type Picker = { follow(x: number, y: number): void; land(fly: boolean): void };
+
+export function classesOf(element: Element) {
+ return [
+ ...new Set(element.getAttribute('class')?.split(/\s+/).filter(Boolean)),
+ ];
+}
+
+/** The element itself or its nearest ancestor with a class, inside
. */
+export function classedElement(element: Element | null) {
+ for (
+ let current = element;
+ current && current.localName !== 'body' && current.localName !== 'html';
+ current = current.parentElement
+ )
+ if (classesOf(current).length) return current;
+ return null;
+}
+
+/**
+ * Class names in style rules outside cascade layers. Those are the site's own
+ * stylesheets; Tailwind keeps its utilities in a layer.
+ */
+export function authoredClasses(
+ sheets: Iterable<{ readonly cssRules: CSSRuleList }>,
+ LayerBlock: typeof CSSLayerBlockRule = CSSLayerBlockRule,
+) {
+ const names = new Set();
+ function read(rules: Iterable) {
+ for (const rule of rules) {
+ if (rule instanceof LayerBlock) continue;
+ if ('selectorText' in rule)
+ for (const [, name] of String(rule.selectorText).matchAll(
+ /\.(-?[_a-zA-Z][\w-]*)/g,
+ ))
+ names.add(name);
+ if ('cssRules' in rule) read(rule.cssRules as CSSRuleList);
+ }
+ }
+ for (const sheet of sheets) {
+ try {
+ read(sheet.cssRules);
+ } catch {
+ // A stylesheet from another origin keeps its rules private.
+ }
+ }
+ return names;
+}
+
+/**
+ * A compound class selector. When the site's own CSS names some of the
+ * classes, only those are shown, so a Tailwind component's utilities do not
+ * bury the one class that identifies it.
+ */
+export function classLabel(
+ classes: string[],
+ authored: ReadonlySet,
+ escape = (name: string) => CSS.escape(name),
+) {
+ const own = classes.filter((name) => authored.has(name));
+ const shown = own.length ? own : classes;
+ const selector = shown
+ .slice(0, SHOWN_CLASSES)
+ .map((name) => `.${escape(name)}`)
+ .join('');
+ return shown.length > SHOWN_CLASSES
+ ? `${selector} +${shown.length - SHOWN_CLASSES}`
+ : selector;
+}
+
+/**
+ * Underneath the element when there is room, above it when not, otherwise
+ * pinned to the bottom of the viewport. Never off the side of the screen.
+ */
+export function labelPosition(
+ box: Box,
+ label: Size,
+ viewport: Size,
+ gap = 2,
+ margin = 4,
+) {
+ const below = box.bottom + gap;
+ const above = box.top - gap - label.height;
+ const top =
+ below + label.height <= viewport.height - margin
+ ? below
+ : above >= margin
+ ? above
+ : viewport.height - margin - label.height;
+ return {
+ left: Math.max(
+ margin,
+ Math.min(box.left, viewport.width - margin - label.width),
+ ),
+ top: Math.max(margin, top),
+ };
+}
+
+/**
+ * Follows a press on the logo. Past PICK_DISTANCE the mark lifts off and
+ * labels the classed element under the pointer; releasing flies it home, and
+ * Escape puts it back early. The click that ends a drag is swallowed, so
+ * neither the logo nor whatever it was dropped on activates. Returns a
+ * function that ends everything at once.
+ */
+export function followLogoPress(link: HTMLElement, press: PointerEvent) {
+ const home = link.querySelector('.brand-mark');
+ const view = link.ownerDocument.defaultView;
+ if (!home || !view) return () => {};
+ const listening = new AbortController();
+ const { signal } = listening;
+ let picker: Picker | undefined;
+ let held = true;
+
+ function end(fly: boolean) {
+ listening.abort();
+ if (link.hasPointerCapture(press.pointerId))
+ link.releasePointerCapture(press.pointerId);
+ picker?.land(fly);
+ }
+
+ link.setPointerCapture(press.pointerId);
+ link.addEventListener(
+ 'pointermove',
+ (event) => {
+ if (event.pointerId !== press.pointerId || !held) return;
+ const moved = Math.hypot(
+ event.clientX - press.clientX,
+ event.clientY - press.clientY,
+ );
+ if (!picker && moved < PICK_DISTANCE) return;
+ picker ??= liftMark(link, home);
+ picker.follow(event.clientX, event.clientY);
+ },
+ { signal },
+ );
+ link.addEventListener(
+ 'pointerup',
+ (event) => {
+ if (event.pointerId !== press.pointerId) return;
+ end(true);
+ if (picker) swallowClick(view);
+ },
+ { signal },
+ );
+ for (const type of ['pointercancel', 'lostpointercapture'] as const)
+ link.addEventListener(
+ type,
+ (event) => {
+ if (event.pointerId === press.pointerId) end(true);
+ },
+ { signal },
+ );
+ view.addEventListener(
+ 'keydown',
+ (event) => {
+ if (event.key !== 'Escape' || !picker || !held) return;
+ // Only put the logo back; search and the time machine keep their Escape.
+ event.preventDefault();
+ event.stopPropagation();
+ held = false;
+ picker.land(true);
+ },
+ { signal, capture: true },
+ );
+ return () => end(false);
+}
+
+/** The click that ends a drag arrives in the same task as its pointerup. */
+function swallowClick(view: Window) {
+ function swallow(event: MouseEvent) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ view.addEventListener('click', swallow, { capture: true, once: true });
+ view.setTimeout(() => view.removeEventListener('click', swallow, true));
+}
+
+function liftMark(link: HTMLElement, home: SVGSVGElement): Picker {
+ const doc = link.ownerDocument;
+ const view = doc.defaultView!;
+ const root = doc.documentElement;
+ const size = home.getBoundingClientRect();
+ // appendChild, because the Workers types replace Element.append.
+ const [outline, ghost, label] = ['outline', 'ghost', 'label'].map((part) => {
+ const element = doc.body.appendChild(doc.createElement('div'));
+ element.className = `logo-picker-${part}`;
+ element.setAttribute('aria-hidden', 'true');
+ return element;
+ });
+ const mark = ghost.appendChild(home.cloneNode(true) as SVGSVGElement);
+ mark.style.width = `${size.width}px`;
+ mark.style.height = `${size.height}px`;
+ outline.hidden = label.hidden = true;
+ link.toggleAttribute('data-picking', true);
+ root.toggleAttribute('data-logo-picking', true);
+ const authored = authoredClasses(doc.styleSheets);
+ let pointer = { x: 0, y: 0 };
+ let target: Element | null = null;
+ let labelSize = { width: 0, height: 0 };
+ let frame = 0;
+ let flight: Animation | undefined;
+ let landed = false;
+
+ // Every frame, so scrolling and layout changes under a still pointer count.
+ function draw() {
+ ghost.style.translate = `${pointer.x - size.width / 2}px ${pointer.y - size.height / 2}px`;
+ const found = classedElement(doc.elementFromPoint(pointer.x, pointer.y));
+ if (found !== target) {
+ target = found;
+ outline.hidden = label.hidden = !target;
+ if (target) {
+ label.textContent = classLabel(classesOf(target), authored);
+ labelSize = { width: label.offsetWidth, height: label.offsetHeight };
+ }
+ }
+ if (target) {
+ const box = target.getBoundingClientRect();
+ outline.style.translate = `${box.left}px ${box.top}px`;
+ outline.style.width = `${box.width}px`;
+ outline.style.height = `${box.height}px`;
+ const { left, top } = labelPosition(box, labelSize, {
+ width: root.clientWidth,
+ height: root.clientHeight,
+ });
+ label.style.translate = `${left}px ${top}px`;
+ }
+ frame = view.requestAnimationFrame(draw);
+ }
+
+ function settle() {
+ if (landed) return;
+ landed = true;
+ flight?.cancel();
+ ghost.remove();
+ link.removeAttribute('data-picking');
+ }
+
+ return {
+ follow(x, y) {
+ pointer = { x, y };
+ if (!frame) draw();
+ },
+ land(fly) {
+ view.cancelAnimationFrame(frame);
+ outline.remove();
+ label.remove();
+ root.removeAttribute('data-logo-picking');
+ if (!fly || view.matchMedia('(prefers-reduced-motion: reduce)').matches)
+ return settle();
+ if (flight || landed) return;
+ const to = home.getBoundingClientRect();
+ flight = ghost.animate(
+ [
+ {
+ translate: ghost.style.translate,
+ scale: view.getComputedStyle(ghost).scale,
+ },
+ { translate: `${to.left}px ${to.top}px`, scale: '1' },
+ ],
+ {
+ duration: 260,
+ easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
+ fill: 'forwards',
+ },
+ );
+ flight.finished.then(settle, settle);
+ },
+ };
+}
diff --git a/tests/browser/logo-picker.spec.ts b/tests/browser/logo-picker.spec.ts
new file mode 100644
index 0000000..88f793e
--- /dev/null
+++ b/tests/browser/logo-picker.spec.ts
@@ -0,0 +1,120 @@
+import { test, expect, type Locator, type Page } from '@playwright/test';
+
+let browserErrors: string[];
+test.beforeEach(async ({ context, page }) => {
+ await context.route('**/*', (route) =>
+ new URL(route.request().url()).hostname === '127.0.0.1'
+ ? route.continue()
+ : route.abort(),
+ );
+ // Reduced motion lands the logo at once instead of flying it home.
+ await page.emulateMedia({ reducedMotion: 'reduce' });
+ browserErrors = [];
+ page.on('pageerror', (error) => browserErrors.push(error.message));
+});
+test.afterEach(() =>
+ expect(browserErrors, 'uncaught browser errors').toEqual([]),
+);
+
+async function centre(locator: Locator) {
+ const box = (await locator.boundingBox())!;
+ return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
+}
+
+async function dragLogoTo(page: Page, target: Locator) {
+ const start = await centre(page.locator('.site-header .brand-mark'));
+ await page.mouse.move(start.x, start.y);
+ await page.mouse.down();
+ const end = await centre(target);
+ await page.mouse.move(end.x, end.y, { steps: 10 });
+}
+
+const pickerParts = (page: Page) =>
+ page.locator('.logo-picker-outline, .logo-picker-ghost, .logo-picker-label');
+
+test('dragging the logo outlines the element underneath and names its class', async ({
+ page,
+}) => {
+ await page.goto('/docs/watch');
+ const home = page.locator('.site-header .brand-mark');
+ const github = page.locator('.site-header .github-link');
+ await dragLogoTo(page, github);
+ const label = page.locator('.logo-picker-label');
+ await expect(label).toHaveText('.github-link');
+ await expect(home).toHaveCSS('visibility', 'hidden');
+ const target = (await github.boundingBox())!;
+ const outline = (await page.locator('.logo-picker-outline').boundingBox())!;
+ for (const side of ['x', 'y', 'width', 'height'] as const)
+ expect(outline[side]).toBeCloseTo(target[side], 0);
+ const tag = (await label.boundingBox())!;
+ expect(tag.y, 'the label sits underneath').toBeGreaterThanOrEqual(
+ target.y + target.height,
+ );
+ expect(tag.x).toBeCloseTo(target.x, 0);
+
+ await page.mouse.up();
+ await expect(pickerParts(page)).toHaveCount(0);
+ await expect(home).toHaveCSS('visibility', 'visible');
+ await expect(page).toHaveURL(/\/docs\/watch$/);
+});
+
+test('a dropped logo follows no link, and Escape puts it back without leaving the time machine', async ({
+ page,
+}) => {
+ await page.addInitScript(() =>
+ sessionStorage.setItem('fxcss-time-machine', 'windows'),
+ );
+ await page.goto('/docs/watch');
+ await expect(page.locator('html')).toHaveAttribute('data-retro', 'windows');
+ await dragLogoTo(page, page.locator('.site-header .header-install'));
+ await expect(page.locator('.logo-picker-label')).toHaveText(
+ '.header-install',
+ );
+ await page.mouse.up();
+ await expect(pickerParts(page)).toHaveCount(0);
+ await expect(page).toHaveURL(/\/docs\/watch$/);
+
+ await dragLogoTo(page, page.locator('.time-machine-heading strong'));
+ await expect(page.locator('.logo-picker-label')).toHaveText(
+ '.time-machine-heading',
+ );
+ await page.keyboard.press('Escape');
+ await expect(pickerParts(page)).toHaveCount(0);
+ await expect(page.locator('html')).toHaveAttribute('data-retro', 'windows');
+ // The press continues without the logo and ends without a click.
+ const home = await centre(page.locator('.site-header .brand-mark'));
+ await page.mouse.move(home.x, home.y, { steps: 5 });
+ await expect(pickerParts(page)).toHaveCount(0);
+ await page.mouse.up();
+ await expect(page).toHaveURL(/\/docs\/watch$/);
+});
+
+test('a click that wobbles less than the drag distance still goes home', async ({
+ page,
+}) => {
+ await page.goto('/docs/watch');
+ const start = await centre(page.locator('.site-header .brand-mark'));
+ await page.mouse.move(start.x, start.y);
+ await page.mouse.down();
+ await page.mouse.move(start.x + 2, start.y + 1);
+ await page.mouse.up();
+ await expect(page).toHaveURL('/');
+ await expect(pickerParts(page)).toHaveCount(0);
+});
+
+test('a Tailwind component is named by the site’s own class', async ({
+ page,
+}) => {
+ await page.goto('/');
+ const toggle = page.getByRole('button', {
+ name: 'Zoom into the tab',
+ exact: true,
+ });
+ await toggle.evaluate((element) =>
+ element.scrollIntoView({ block: 'center', behavior: 'instant' }),
+ );
+ await dragLogoTo(page, toggle);
+ await expect(page.locator('.logo-picker-label')).toHaveText('.detail-toggle');
+ await page.mouse.up();
+ await expect(pickerParts(page)).toHaveCount(0);
+});
diff --git a/tests/easter-eggs.test.mjs b/tests/easter-eggs.test.mjs
index 620e815..ba115c8 100644
--- a/tests/easter-eggs.test.mjs
+++ b/tests/easter-eggs.test.mjs
@@ -1,6 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { searchSecret } from '../lib/easter-eggs.ts';
+import { authoredClasses, classedElement, classesOf, classLabel, labelPosition } from '../lib/logo-picker.ts';
import { battleRounds, winningRule } from '../lib/specificity.ts';
import { watchSleepyFavicon } from '../lib/sleepy-favicon.ts';
import { retroDestinationForQuery, retroDestinations, storedRetroDestination } from '../lib/time-machine.ts';
@@ -93,3 +94,51 @@ test('favicon sleeps in every format, handles navigation metadata and restores e
assert.equal(listeners.size, 0);
assert.equal(disconnected, true);
});
+
+test('the logo picker labels the nearest classed element, never or ', () => {
+ const element = (localName, className, parentElement = null) => ({ localName, parentElement, getAttribute: (name) => (name === 'class' ? className : null) });
+ const html = element('html', 'js');
+ const body = element('body', 'page', html);
+ const main = element('main', null, body);
+ const card = element('article', ' card missing card ', main);
+ const text = element('p', ' ', card);
+ assert.deepEqual(classesOf(card), ['card', 'missing']);
+ assert.deepEqual(classesOf(text), []);
+ assert.equal(classedElement(text), card);
+ assert.equal(classedElement(card), card);
+ assert.equal(classedElement(main), null);
+ assert.equal(classedElement(null), null);
+});
+
+test('logo picker labels prefer the site’s own classes over layered utilities', () => {
+ class Layer { constructor(cssRules) { this.cssRules = cssRules; } }
+ const authored = authoredClasses([
+ { cssRules: [
+ { selectorText: '.site-header nav a:hover' },
+ { selectorText: 'html[data-retro] :is(.showcase, .field-guide)' },
+ new Layer([{ selectorText: '.inline-flex' }, { media: {}, cssRules: [{ selectorText: '.md\\:flex' }] }]),
+ { media: {}, cssRules: [{ selectorText: '.detail-toggle[data-slot="button"]' }] },
+ { name: 'spin', cssRules: [{ keyText: 'from' }] },
+ ] },
+ { get cssRules() { throw new Error('SecurityError'); } },
+ ], Layer);
+ assert.deepEqual([...authored].sort(), ['detail-toggle', 'field-guide', 'showcase', 'site-header']);
+
+ const escape = (name) => name.replace(/[[\]:]/g, '\\$&');
+ assert.equal(classLabel(['site-header', 'docs-header'], new Set(['site-header', 'docs-header']), escape), '.site-header.docs-header');
+ // A Tailwind component is named by the class the site styles it with.
+ assert.equal(classLabel(['inline-flex', 'hover:bg-muted', 'detail-toggle'], authored, escape), '.detail-toggle');
+ // Utilities alone are shown escaped, and a long list is shortened.
+ assert.equal(classLabel(['lucide', 'lucide-x'], authored, escape), '.lucide.lucide-x');
+ assert.equal(classLabel(['relative', 'h-[1px]', 'hover:underline', 'flex-1', 'gap-2'], authored, escape), '.relative.h-\\[1px\\].hover\\:underline +2');
+});
+
+test('logo picker labels sit underneath, flip above at the bottom and stay on screen', () => {
+ const label = { width: 120, height: 22 };
+ const viewport = { width: 1280, height: 900 };
+ assert.deepEqual(labelPosition({ left: 100, top: 50, bottom: 90 }, label, viewport), { left: 100, top: 92 });
+ assert.deepEqual(labelPosition({ left: 100, top: 800, bottom: 890 }, label, viewport), { left: 100, top: 776 });
+ assert.deepEqual(labelPosition({ left: 1250, top: 50, bottom: 90 }, label, viewport), { left: 1156, top: 92 });
+ // An element taller than the viewport keeps its label inside it.
+ assert.deepEqual(labelPosition({ left: -20, top: -400, bottom: 2000 }, label, viewport), { left: 4, top: 874 });
+});