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
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ Fixes found while moving a second PatternLab styleguide (n8d) to Pattern Dump.

- A numbered `templates` or `pages` folder now gets the `full` preview layout its category promises.
The category was matched with its ordering prefix still attached, so a PatternLab tree
(`04-templates`, `05-pages`) could never hit the documented default — only a per-folder
(`04-templates`, `05-pages`) could never hit the documented default. Only a per-folder
`preview: full` could. Folder *labels* still keep the number: `2-col` is a name and `04-templates`
a prefix, and nothing in the string tells them apart, so a numbered folder sets `title:` for a
clean label.
- A `requireScript` or `globalScripts` id with no matching `<scriptsDir>/<id>.ts` is reported instead
of failing inside the preview. `pd dev` names every unresolvable id at startup — with the component
for a `requireScript` — and the script's URL answers 404 saying which file it expected and where,
of failing inside the preview. `pd dev` names every unresolvable id at startup (with the component
for a `requireScript`), and the script's URL answers 404 saying which file it expected and where,
rather than embedding a raw `ENOENT`. Scripts are TypeScript, so a `.js` file of the same name does
not satisfy an id; that is the common case this hid.

Expand Down Expand Up @@ -284,8 +284,8 @@ These can change how an existing project loads or renders:
### Fixed

- A `centered` preview whose height comes from the viewport (`height: 200vh` in the base layer, a
percentage chain) no longer grows without bound. Content-fitting such a height is circular — the
frame's height feeds the content's — and the frame used to double every tick to the browser's
percentage chain) no longer grows without bound. Content-fitting such a height is circular (the
frame's height feeds the content's), and the frame used to double every tick to the browser's
layout ceiling, showing a size like `785 × 33554428`. The run of growth is now detected, the frame
keeps its last steady height and the content scrolls inside it, and the Console says why.
- SCSS edits reach the preview live when `styles.entry` is set, and edits to base-layer styles
Expand Down
10 changes: 6 additions & 4 deletions apps/dev-ui/e2e/document-title.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// The browser tab names the workbench: shell.brand.title (test-bench sets "Test bench"), with the component in front
// on a component route, so tabs and history entries can be told apart. The served page has the brand before any
// The browser tab names the workbench: shell.brand.title (test-bench sets "Test bench"), with the component or folder
// in front on its route, so tabs and history entries can be told apart. The served page has the brand before any
// script runs; the shell keeps the title in step with every navigation, Back included.

import { test, expect } from "@playwright/test";
Expand All @@ -9,10 +9,12 @@ test("the served page's title is the brand", async ({ request }) => {
expect(html).toContain("<title>Test bench</title>");
});

test("a component route puts the component in front; a folder, and Back to it, the brand alone", async ({ page }) => {
test("a component or folder route puts its title in front, Back restores it, and an unknown route is the brand alone", async ({ page }) => {
await page.goto("/no-such-route");
await expect(page).toHaveTitle("Test bench");
await page.goto("/atoms");
await expect(page.locator("#category-overview")).toBeVisible();
await expect(page).toHaveTitle("Test bench");
await expect(page).toHaveTitle("Atoms · Test bench");
await page.goto("/atoms/button");
await page.waitForSelector("#preview-frame[srcdoc]");
await expect(page).toHaveTitle("Button · Test bench");
Expand Down
4 changes: 2 additions & 2 deletions apps/dev-ui/e2e/static/static-build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ test.describe("static build — built without the audit (--no-audit)", () => {
});

test.describe("static build — the browser tab", () => {
test("names the brand in every shell page, and the component in front on a component route", async ({ page, request }) => {
test("names the brand in every shell page, and the component or folder in front on its route", async ({ page, request }) => {
expect(await (await request.get("atoms/button")).text()).toContain("<title>Test bench</title>");
await page.goto("atoms/button");
await page.waitForSelector("#preview-frame[srcdoc]");
await expect(page).toHaveTitle("Button · Test bench");
await page.goto("atoms");
await expect(page.locator("#category-overview")).toBeVisible();
await expect(page).toHaveTitle("Test bench");
await expect(page).toHaveTitle("Atoms · Test bench");
});
});

Expand Down
4 changes: 2 additions & 2 deletions apps/dev-ui/e2e/theme-picker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// but not clickable, so the user-facing affordance is the chip <label>. Playwright's .check()
// cannot act on them; clicking the label is both the honest path and the working one.
// 2. store.local.theme defaults to "" (store.ts:161), so on a FRESH load no radio is checked and
// the summary reads "— no theme —" -- even though test-bench's config declares default: light.
// the summary reads "(no theme)" -- even though test-bench's config declares default: light.
// The picker reflects shell state, not the project's default theme.

import { test, expect } from "@playwright/test";
Expand All @@ -43,7 +43,7 @@ test.describe("Nav Rail — theme picker", () => {

// The preview is ALWAYS themed: with no ?theme= the server falls back to its configured default
// (routes.ts:303-311), so the body carries data-theme="light". The picker used to read
// "— no theme —" with nothing checked, describing shell state while claiming to describe the
// "(no theme)" with nothing checked, describing shell state while claiming to describe the
// document. It now reports what the user is looking at.
await expect(page.locator(".theme-picker-current-name")).toHaveText("light");
await expect(page.locator(`${radios}:checked`)).toHaveValue("light");
Expand Down
2 changes: 1 addition & 1 deletion apps/dev-ui/src/app/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export async function init(): Promise<void> {
const built = new Date(runtime.builtAt).toLocaleString();
dom.railStatus.dataset.state = "static";
dom.railStatusLabel.textContent = `Static build · ${built}`;
renderConsole(`Static build of ${runtime.builtAt} (pattern-dump ${runtime.pdVersion}) — read-only snapshot, no live reload.`);
renderConsole(`Static build of ${runtime.builtAt} (pattern-dump ${runtime.pdVersion}): a read-only snapshot, no live reload.`);
} else {
connectHmr();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dev-ui/src/app/galleries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function buildVariantsGallery(): Promise<void> {
fig.className = "preview gallery-item";

const isDefault = v.variantParam === undefined;
const labelText = isDefault ? session.current.title : `${session.current.title} — ${v.name}`;
const labelText = isDefault ? session.current.title : `${session.current.title} · ${v.name}`;
const labelHref = isDefault
? `/${session.current.id}${currentVpParam()}`
: `/${session.current.id}${currentVpParam()}#${encodeURIComponent(v.name)}`;
Expand Down
10 changes: 5 additions & 5 deletions apps/dev-ui/src/app/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function connectHmr(): void {
ws.addEventListener("close", () => {
dom.railStatus.dataset.state = "disconnected";
dom.railStatusLabel.textContent = "disconnected"; // announces once via role="status"
renderConsole("HMR disconnected — retrying…");
renderConsole("HMR disconnected, retrying…");
setTimeout(() => connectHmr(), 1000);
});

Expand Down Expand Up @@ -98,14 +98,14 @@ export function connectHmr(): void {
return loadDocument(`tile:${vp ?? ""}`, `${componentId}~${vp ?? ""}`, previewUrl(componentId, vp, store.local.theme || undefined), doc => {
f.srcdoc = doc;
console.log("%c[pd] srcdoc reloaded", "color:#7ed321;font-weight:bold",
`— ${componentId} (${vp ?? "default"})`);
`· ${componentId} (${vp ?? "default"})`);
}, () => f.isConnected && session.current?.id === componentId);
}));
} else {
const variant = session.currentVariant;
await loadDocument("preview", `${componentId}~${variant ?? ""}`, previewUrl(componentId, variant ?? undefined, store.local.theme || undefined), doc => {
dom.iframe.srcdoc = doc;
console.log("%c[pd] srcdoc reloaded", "color:#7ed321;font-weight:bold", `— ${componentId}`);
console.log("%c[pd] srcdoc reloaded", "color:#7ed321;font-weight:bold", `· ${componentId}`);
}, () => session.current?.id === componentId && session.currentVariant === variant);
}
// Re-render the active view.
Expand Down Expand Up @@ -206,7 +206,7 @@ export function connectHmr(): void {
// none. A broken .scss therefore produced nothing in the UI at all — it reached only the
// dev-server's terminal. For a workbench whose whole job is surfacing defects, silently
// swallowing its own build errors is the worst possible failure mode.
renderConsole(`${msg.scope === "build" ? "Build" : "Render"} error — ${msg.message}`, "error");
renderConsole(`${msg.scope === "build" ? "Build" : "Render"} error: ${msg.message}`, "error");

const errId = msg.componentId;
if (errId && errId === session.current?.id) {
Expand Down Expand Up @@ -283,7 +283,7 @@ export function connectHmr(): void {
// A quarantined component is excluded from the tree, so without this line the author sees a
// component silently vanish. Name both paths — renaming or moving one of them resolves it.
renderConsole(
`Handle collision — "${msg.handle}" is held by ${msg.incumbentPath}; ${msg.quarantinedPath} is quarantined until one is renamed`,
`Handle collision: "${msg.handle}" is held by ${msg.incumbentPath}; ${msg.quarantinedPath} is quarantined until one is renamed`,
"error",
);
} else if (msg.type === "page-changed") {
Expand Down
15 changes: 9 additions & 6 deletions apps/dev-ui/src/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { documentTitle } from "../core/title.js";
import { navigate, navigateOverview, navigateUnknown, navigateVariants, swapVariant } from "./navigation.js";


function resolvePathKind(path: string): "component" | "group" | null {
function findTreeNode(path: string): TreeNode | null {
function findNode(nodes: TreeNode[]): TreeNode | null {
for (const n of nodes) {
if (n.path === path) return n;
Expand All @@ -29,8 +29,11 @@ function resolvePathKind(path: string): "component" | "group" | null {
}
return null;
}
const node = findNode(session.tree.roots);
return node ? node.kind : null;
return findNode(session.tree.roots);
}

function resolvePathKind(path: string): "component" | "group" | null {
return findTreeNode(path)?.kind ?? null;
}

// Read the current URL and route to the matching view. All navigation paths —
Expand Down Expand Up @@ -59,11 +62,11 @@ export async function routeFromCurrentLocation(): Promise<void> {
}
// Variant is now in the URL hash (#ghost), not ?v= query param.
const variant = window.location.hash.slice(1) || undefined;
// The tab names the component on a component route (its gallery too), and only the workbench elsewhere.
// The tab names the component or folder the route shows (a component's gallery too), and only the workbench on
// home and on a route the tree doesn't know.
const shown = path.endsWith("/variants") && resolvePathKind(path.slice(0, -"/variants".length)) === "component"
? path.slice(0, -"/variants".length) : path;
document.title = documentTitle(session.brandTitle,
resolvePathKind(shown) === "component" ? session.componentRegistry.get(shown)?.title : undefined);
document.title = documentTitle(session.brandTitle, path ? findTreeNode(shown)?.title : undefined);
if (!path) return;

if (path.endsWith("/variants")) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dev-ui/src/app/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<span class="rail-toggle-label" aria-hidden="true"></span>
</div>
<div class="rail-vp-cluster" role="group" aria-label="Viewport">
<output class="vp-readout">— × —</output>
<output class="vp-readout">(no size)</output>
<div role="radiogroup" aria-label="Viewport size">
<button class="rail-vp-btn" data-vp="fit"
role="radio" aria-checked="true" tabindex="0"
Expand Down
2 changes: 1 addition & 1 deletion apps/dev-ui/src/core/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import { PD_PROTOCOL_VERSION } from "@pattern-dump/contracts";
export function protocolMismatch(serverProtocol: unknown, shellProtocol: number = PD_PROTOCOL_VERSION): string | null {
if (serverProtocol === shellProtocol) return null;
const server = typeof serverProtocol === "number" ? `v${serverProtocol}` : "an unknown version";
return `Protocol mismatch — the server speaks ${server}, this shell expects v${shellProtocol}. ` +
return `Protocol mismatch: the server speaks ${server}, this shell expects v${shellProtocol}. ` +
"Rebuild and restart the dev server, then reload.";
}
3 changes: 2 additions & 1 deletion apps/dev-ui/src/core/title.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ describe("the browser tab's title", () => {
expect(brandTitle(undefined)).toBe("Pattern Dump");
});

it("puts the component in front on a component route, and is the brand alone elsewhere", () => {
it("puts the component or folder in front on its route, and is the brand alone elsewhere", () => {
expect(documentTitle("Acme DS", "Button")).toBe("Button · Acme DS");
expect(documentTitle(brandTitle(undefined), "Button")).toBe("Button · Pattern Dump");
expect(documentTitle("Acme DS", "Atoms")).toBe("Atoms · Acme DS");
expect(documentTitle("Acme DS")).toBe("Acme DS");
});
});
10 changes: 5 additions & 5 deletions apps/dev-ui/src/core/title.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// The browser tab's title: the workbench's name (shell.brand.title, else "Pattern Dump"; the served page starts with
// it), with the component's title in front on a component route, so tabs and history entries can be told apart.
// Every other route (home, a folder, an unknown path) is the name alone.
// it), with the title of the component or folder in front on its route, so tabs and history entries can be told
// apart. Home and an unknown path are the name alone.

/** The name the tab shows without a component: the config's shell.brand.title, else the default. */
export function brandTitle(title: string | undefined): string {
return title ?? "Pattern Dump";
}

/** "<component> · <brand>" on a component route, else the brand. */
export function documentTitle(brand: string, component?: string): string {
return component ? `${component} · ${brand}` : brand;
/** "<component or folder> · <brand>" on its route, else the brand. */
export function documentTitle(brand: string, shown?: string): string {
return shown ? `${shown} · ${brand}` : brand;
}
2 changes: 1 addition & 1 deletion apps/dev-ui/src/dock/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function renderDiagnostics(diagnostics: Diagnostic[]): void {
}
const ruleSpan = document.createElement("span");
ruleSpan.className = "pd-a11y-rule";
ruleSpan.textContent = ` — ${d.ruleId}`;
ruleSpan.textContent = ` · ${d.ruleId}`;
li.appendChild(ruleSpan);
if (d.target) {
const targetSpan = document.createElement("span");
Expand Down
6 changes: 3 additions & 3 deletions apps/dev-ui/src/rail/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// so the preview is themed either way. Anything that DISPLAYS the theme must use activeThemeName();
// anything that SENDS it to the server keeps passing the raw stored value, so "" keeps meaning
// "follow the default" rather than pinning a name. Getting that backwards is exactly how the picker
// came to report "— no theme —" over a document that was plainly themed.
// came to report "(no theme)" over a document that was plainly themed.
//
// The radio inputs are sr-only; the chip <label> is the real affordance.
//
Expand Down Expand Up @@ -69,7 +69,7 @@ export function populateThemePicker(fetchedThemes: ThemeSummary[], onThemeApplie
// The EFFECTIVE theme, not the stored one. store.local.theme is "" until the user picks
// explicitly, and "" means "follow the project default" — the server then falls back to its
// configured defaultTheme, so the preview is themed regardless. Reporting the raw stored value
// made the picker read "— no theme —" over a document that was plainly themed.
// made the picker read "(no theme)" over a document that was plainly themed.
//
// Deliberately NOT seeding store.local.theme with the default: keeping it "" is what lets a later
// change to the project's configured default carry through to anyone who never chose a theme. The
Expand All @@ -88,7 +88,7 @@ export function populateThemePicker(fetchedThemes: ThemeSummary[], onThemeApplie
dom.themePickerSwatch.innerHTML = "";
dom.themePickerSwatch.appendChild(buildSwatchStrip(activeTheme?.tokens, slotsOf(activeTheme)));
// Still reachable — and then genuinely true — when the project configures no themes at all.
dom.themePickerCurrentName.textContent = currentTheme || "— no theme —";
dom.themePickerCurrentName.textContent = currentTheme || "(no theme)";
dom.themePickerReadout.textContent = currentTheme || "";

dom.themePickerList.innerHTML = "";
Expand Down
4 changes: 2 additions & 2 deletions apps/dev-ui/src/stage/viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export function updateReadout(): void {
: "Component preview";
try {
const cw = dom.iframe.contentWindow;
if (!cw) { dom.vpReadout.textContent = "— × —"; return; }
if (!cw) { dom.vpReadout.textContent = "(no size)"; return; }
const w = cw.innerWidth;
const h = cw.innerHeight;
dom.vpReadout.textContent = `${w} × ${h}`;
dom.vpReadout.setAttribute("aria-label", `Viewport ${w} by ${h} pixels`);
} catch {
dom.vpReadout.textContent = "— × —";
dom.vpReadout.textContent = "(no size)";
}
syncMarks();
}
Expand Down
4 changes: 2 additions & 2 deletions docs/development/a11y-coverage.generated.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# A11y Coverage — Pattern Dump
# A11y Coverage · Pattern Dump

> Generated by `nx run a11y:classify` from axe-core 4.11.4. Do not hand-edit.
> Re-run after axe version bumps to reflect any rule tier changes as a git diff.
Expand Down Expand Up @@ -32,7 +32,7 @@ They return `incomplete` in jsdom. Deferred to the on-demand visual tier milesto

Automated axe checks cover structural and ARIA attribute correctness. They do not cover:

- **Colour contrast** (requires computed styles — deferred to the visual tier)
- **Colour contrast** (requires computed styles, so deferred to the visual tier)
- **Keyboard navigation order and focus management** (requires interactive testing)
- **Screen reader announcements** (varies by AT and browser combination)
- **Cognitive accessibility** (readability, plain language, consistent navigation)
Expand Down
2 changes: 1 addition & 1 deletion docs/development/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ second writer:

| Package | Responsibility | Depends on |
|---|---|---|
| `contracts` | The seams: TypeScript types plus a few pure helpers (URL builders, the audit rollup, `staticPathFor`, the preview height fitter). Defines `render()`, the dev-server ↔ dev-ui data API and the HMR protocol, versioned by `PD_PROTOCOL_VERSION`. | — |
| `contracts` | The seams: TypeScript types plus a few pure helpers (URL builders, the audit rollup, `staticPathFor`, the preview height fitter). Defines `render()`, the dev-server ↔ dev-ui data API and the HMR protocol, versioned by `PD_PROTOCOL_VERSION`. | (none) |
| `config` | Loads `pattern-dump.config.ts` / `.json` (TypeScript wins). Shared config types. | contracts |
| `build` | esbuild (TypeScript), Sass + Autoprefixer, Chokidar watching, incremental builds, the SCSS dependency graph, and image encoding: responsive WebP variants by sharp (pinned to one exact release, so the same source gives the same bytes everywhere), cached on disk by their key. | contracts |
| `hotreloader` | `ws`-based hot-reload server and browser client. | contracts |
Expand Down
Loading
Loading