Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(i18n): widen Crowdin screenshot coverage and keep every tag in frame (#6334)

nynexman4464a4bcbeb026ae
diff --git a/.github/workflows/crowdin-upload.yml b/.github/workflows/crowdin-upload.yml
index 7e29a7756b..24ff1962d6 100644
--- a/.github/workflows/crowdin-upload.yml
+++ b/.github/workflows/crowdin-upload.yml
@@ -13,6 +13,7 @@ on:
branches: [main]
paths:
- 'packages/core/locales/en.json'
+ - '.github/workflows/crowdin-upload.yml'
workflow_dispatch:
permissions: {}
@@ -41,3 +42,41 @@ jobs:
env:
CROWDIN_PROJECT_ID: ${{ vars.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
+
+ # File-level context is a field on the Crowdin file record, and a
+ # crowdin.yml `files:` entry has no key for it, so the upload above
+ # cannot carry it. Tone and terminology belong in the Crowdin style
+ # guide, not here.
+ - name: Set file-level context
+ env:
+ CROWDIN_PROJECT_ID: ${{ vars.CROWDIN_PROJECT_ID }}
+ CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
+ SOURCE_PATH: /packages/core/locales/en.json
+ CONTEXT: >-
+ English source strings for Astryx's reusable React UI components.
+ They appear in product-neutral controls across many host
+ applications, including compact visible controls and screen-reader
+ labels. Use the key's component segment, per-string description,
+ and tagged screenshots to identify each surface. Preserve ICU
+ placeholders and rich-text tags exactly.
+ run: |
+ set -euo pipefail
+ api="https://api.crowdin.com/api/v2/projects/$CROWDIN_PROJECT_ID/files"
+ auth="Authorization: Bearer $CROWDIN_PERSONAL_TOKEN"
+ files=$(curl --fail-with-body -sS -H "$auth" "$api?limit=500") ||
+ { echo "::error::$files"; exit 1; }
+ file=$(jq --arg p "$SOURCE_PATH" '[.data[].data | select(.path == $p)][0]' <<<"$files")
+ id=$(jq -r '.id // empty' <<<"$file")
+ if [ -z "$id" ]; then
+ echo "::error::no file at $SOURCE_PATH — upload sources first"
+ exit 1
+ fi
+ if [ "$(jq -r '.context // ""' <<<"$file")" = "$CONTEXT" ]; then
+ echo "file $id already carries this context"
+ exit 0
+ fi
+ patch=$(jq -n --arg c "$CONTEXT" '[{op: "replace", path: "/context", value: $c}]')
+ out=$(curl --fail-with-body -sS -X PATCH "$api/$id" \
+ -H "$auth" -H 'Content-Type: application/json' --data "$patch") ||
+ { echo "::error::$out"; exit 1; }
+ echo "set context on file $id"
diff --git a/internal/scripts/README.md b/internal/scripts/README.md
index 388420dcac..5b5290bfe0 100644
--- a/internal/scripts/README.md
+++ b/internal/scripts/README.md
@@ -9,6 +9,10 @@ Internal build-time scripts. Not shipped, not part of any package.
| `upload-crowdin-screenshots.mjs` | Build storybook, capture in-context screenshots for i18n catalog keys, upload to Crowdin, and POST tag positions so each screenshot pixel-links to the matching source string. |
| `lib/crowdin-strategies.mjs` | Declarative measurement strategies (visibleText, option, placeholder, ariaLabel, chipOperator, filterInput, footerButton, srOnlyLabel, srOnlyReveal) used by the upload script to resolve tag coordinates. |
+The file-level context Crowdin shows beside every string in the catalog is a
+field on the file record, not something `crowdin.yml` can declare; a step in
+`.github/workflows/crowdin-upload.yml` sets it after the source upload.
+
## upload-crowdin-screenshots.mjs
Automates the "screenshot with in-context tags" flow for [Crowdin](https://crowdin.com/), the translation platform used by astryx.
@@ -61,7 +65,11 @@ Some catalog strings are aria-labels on widgets that render no visible text (bar
- `srOnlyLabel` — tag rect lands on the visible ancestor widget. Best when the widget has some other identifying feature (icon, adjacent text).
- `srOnlyReveal` — injects a small yellow label bubble next to the widget during screenshot capture, then tags the bubble. Translators see the actual aria-label text pinned to the widget. Best when the widget has no visible cue at all.
-Reveal bubbles only exist inside the screenshot pipeline — they are never rendered in production.
+Reveal bubbles only exist inside the screenshot pipeline — they are never rendered in production. A bubble beside a widget at the edge of the viewport slides along that edge until it fits.
+
+### A tag has to fit the screenshot
+
+Crowdin rejects a tag rectangle that leaves the uploaded image, so every strategy requires the viewport to contain a candidate's rect. A match below the fold is reported unresolved rather than trimmed or scrolled into view — widen the target's `viewport` if a string you want tagged sits outside it.
### Deterministic tagging, not `--auto-tag`
diff --git a/internal/scripts/lib/crowdin-strategies.mjs b/internal/scripts/lib/crowdin-strategies.mjs
index f064c16315..d95f1b4db1 100644
--- a/internal/scripts/lib/crowdin-strategies.mjs
+++ b/internal/scripts/lib/crowdin-strategies.mjs
@@ -11,7 +11,8 @@
// `interact()` function before measurement.
//
// All strategy code is inlined into a single browserside function
-// (STRATEGY_FN_SOURCE) which is stringified and executed via page.evaluate.
+// (see buildMeasureSource) which is stringified and executed via
+// page.evaluate. The geometry helpers below are injected into that source.
export const STRATEGY_NAMES = [
'visibleText',
@@ -25,6 +26,111 @@ export const STRATEGY_NAMES = [
'srOnlyReveal',
];
+// Gap in CSS px between a reveal bubble and the widget it labels — a little
+// wider beside the widget than above or below it.
+export const REVEAL_BUBBLE_GAP = {block: 4, inline: 6};
+
+// Layout coordinates carry float error, so an edge mathematically on the
+// boundary can measure a fraction past it.
+const EDGE_EPSILON = 1e-6;
+
+/**
+ * True when the capture contains the whole rect.
+ *
+ * Crowdin validates every tag against its image, so containment is part of
+ * whether a DOM match is usable at all — a match below the fold is not a
+ * match, and a later candidate may still be a good one. Partial rects are
+ * rejected rather than trimmed; nothing here scrolls.
+ */
+export function rectWithinViewport(rect, viewport) {
+ if (!rect) return false;
+ if (!(rect.width > 0) || !(rect.height > 0)) return false;
+ return (
+ rect.x >= -EDGE_EPSILON &&
+ rect.y >= -EDGE_EPSILON &&
+ rect.x + rect.width <= viewport.width + EDGE_EPSILON &&
+ rect.y + rect.height <= viewport.height + EDGE_EPSILON
+ );
+}
+
+/**
+ * Viewport-space rect for a reveal bubble of `bubbleSize` placed at
+ * `placement` beside `widgetRect`, clamped inside the viewport on both axes.
+ *
+ * Clamping slides the bubble along the edge it would have crossed, so the tag
+ * still labels the widget it was placed against. A bubble larger than the
+ * viewport is pinned at the origin and `rectWithinViewport` then rejects it.
+ */
+export function placeRevealBubble(widgetRect, bubbleSize, placement, viewport) {
+ const {width, height} = bubbleSize;
+ const centeredX = widgetRect.x + widgetRect.width / 2 - width / 2;
+ const centeredY = widgetRect.y + widgetRect.height / 2 - height / 2;
+ let x;
+ let y;
+ switch (placement) {
+ case 'below':
+ x = centeredX;
+ y = widgetRect.y + widgetRect.height + REVEAL_BUBBLE_GAP.block;
+ break;
+ case 'above':
+ x = centeredX;
+ y = widgetRect.y - height - REVEAL_BUBBLE_GAP.block;
+ break;
+ case 'left':
+ x = widgetRect.x - width - REVEAL_BUBBLE_GAP.inline;
+ y = centeredY;
+ break;
+ case 'right':
+ default:
+ x = widgetRect.x + widgetRect.width + REVEAL_BUBBLE_GAP.inline;
+ y = centeredY;
+ }
+ return {
+ x: Math.min(Math.max(x, 0), Math.max(0, viewport.width - width)),
+ y: Math.min(Math.max(y, 0), Math.max(0, viewport.height - height)),
+ width,
+ height,
+ };
+}
+
+/**
+ * CSS pixels → the integer device pixels Crowdin stores a tag in.
+ *
+ * Both EDGES are rounded and the size derived from them: rounding position
+ * and size independently can push `x + width` a pixel past the capture.
+ */
+export function toDevicePixelRect(rect, dpr) {
+ const x = Math.round(rect.x * dpr);
+ const y = Math.round(rect.y * dpr);
+ return {
+ x,
+ y,
+ width: Math.round((rect.x + rect.width) * dpr) - x,
+ height: Math.round((rect.y + rect.height) * dpr) - y,
+ };
+}
+
+// Free variables the stringified browser function reads from module scope.
+// Anything it uses has to be listed here to reach the page.
+const BROWSER_HELPERS = [rectWithinViewport, placeRevealBubble];
+const BROWSER_CONSTANTS = {REVEAL_BUBBLE_GAP, EDGE_EPSILON};
+
+/**
+ * Source for `page.evaluate`: an expression evaluating to the `measure`
+ * function, with the geometry helpers inlined.
+ */
+export function buildMeasureSource() {
+ return [
+ '(() => {',
+ ...Object.entries(BROWSER_CONSTANTS).map(
+ ([name, value]) => `const ${name} = ${JSON.stringify(value)};`,
+ ),
+ ...BROWSER_HELPERS.map(fn => fn.toString()),
+ `return (${browserSideMeasure.toString()})();`,
+ '})()',
+ ].join('\n');
+}
+
// This function is stringified and evaluated in the browser. Do not import
// anything from Node.js in here. `strategy` is the strategy name, `args` is
// an array of positional arguments.
@@ -38,7 +144,16 @@ export function browserSideMeasure() {
if (!visible(el)) return null;
const r = el.getBoundingClientRect();
if (r.width <= 0 || r.height <= 0) return null;
- return {x: r.x, y: r.y, width: r.width, height: r.height};
+ const rect = {x: r.x, y: r.y, width: r.width, height: r.height};
+ return inViewport(rect) ? rect : null;
+ }
+ // The screenshot is the viewport, so a rect the viewport does not
+ // contain cannot be tagged on it.
+ function inViewport(rect) {
+ return rectWithinViewport(rect, {
+ width: window.innerWidth,
+ height: window.innerHeight,
+ });
}
// Matches when trimmed `actual === want`, or (when tolerance > 0) when
// `actual.startsWith(want)` and the extra suffix is <= `tolerance` chars.
@@ -104,6 +219,7 @@ export function browserSideMeasure() {
// Callers that specifically want sr-only labels should use
// the srOnlyLabel strategy instead.
if (r.width < 6 || r.height < 6) continue;
+ if (!inViewport(r)) continue;
// Prefer the SMALLEST matching element — it's the most specific
// (avoids picking up giant wrapper divs whose textContent happens
// to equal the target text because they contain only that node).
@@ -224,6 +340,7 @@ export function browserSideMeasure() {
if (!rects.length) continue;
const r = rects[0];
if (r.width <= 0 || r.height <= 0) continue;
+ if (!inViewport(r)) continue;
return {x: r.x, y: r.y, width: r.width, height: r.height};
}
}
@@ -279,6 +396,7 @@ export function browserSideMeasure() {
if (!isVisibleAtCenter(b)) continue;
const r = b.getBoundingClientRect();
if (r.width <= 0 || r.height <= 0) continue;
+ if (!inViewport(r)) continue;
// Pick the smallest — typically the actual footer button (larger
// matches would be wrapper divs with the same text).
if (!best || r.width * r.height < best.w * best.h) {
@@ -323,11 +441,10 @@ export function browserSideMeasure() {
const place = placement || 'right';
// Idempotent: if a reveal bubble for this text already exists (from
- // a pre-screenshot pass), just return its rect instead of injecting
- // another one. We stash the viewport-relative paint rect at
- // injection time as data-* attrs, because getBoundingClientRect()
- // on top-layer descendants can shift between calls
- // (containing-block vs viewport) in some browsers.
+ // a pre-screenshot pass), return the rect recorded when it was
+ // placed. That recorded rect is the authority — re-deriving it from
+ // the DOM would have to redo positionBubble's containing-block
+ // correction.
function readCachedRect(el) {
if (!el) return null;
const cx = parseFloat(el.getAttribute('data-crowdin-vx') || '');
@@ -340,12 +457,11 @@ export function browserSideMeasure() {
}
return null;
}
- function cachePaintRect(bubble) {
- const p = bubble.getBoundingClientRect();
- bubble.setAttribute('data-crowdin-vx', String(p.x));
- bubble.setAttribute('data-crowdin-vy', String(p.y));
- bubble.setAttribute('data-crowdin-vw', String(p.width));
- bubble.setAttribute('data-crowdin-vh', String(p.height));
+ function cacheRect(bubble, rect) {
+ bubble.setAttribute('data-crowdin-vx', String(rect.x));
+ bubble.setAttribute('data-crowdin-vy', String(rect.y));
+ bubble.setAttribute('data-crowdin-vw', String(rect.width));
+ bubble.setAttribute('data-crowdin-vh', String(rect.height));
}
const existing = document.querySelector(
@@ -353,11 +469,7 @@ export function browserSideMeasure() {
);
if (existing) {
const cached = readCachedRect(existing);
- if (cached) return cached;
- const er = existing.getBoundingClientRect();
- if (er.width > 0 && er.height > 0) {
- return {x: er.x, y: er.y, width: er.width, height: er.height};
- }
+ if (cached) return inViewport(cached) ? cached : null;
}
// Two match paths (deduped):
@@ -433,39 +545,29 @@ export function browserSideMeasure() {
S.lineHeight = '14px';
}
- // Compute viewport-space left/top for the bubble at `place`, then
- // translate to containing-block-space when parented to a top-layer
- // element (native <dialog>/[popover]) whose `position: fixed`
- // descendants are scoped to the dialog's origin.
- function positionBubble(bubble, widgetRect, place, modalHost) {
+ // Place the bubble at `place`, clamped inside the viewport, and
+ // return the rect it occupies in the screenshot. `position: fixed`
+ // resolves against a transformed ancestor or the top layer, not
+ // always the viewport, so write viewport coordinates, read back where
+ // the browser painted, and correct by the difference.
+ function positionBubble(bubble, widgetRect, place) {
const b = bubble.getBoundingClientRect();
- let left = 0;
- let top = 0;
- switch (place) {
- case 'below':
- left = widgetRect.left + widgetRect.width / 2 - b.width / 2;
- top = widgetRect.bottom + 4;
- break;
- case 'above':
- left = widgetRect.left + widgetRect.width / 2 - b.width / 2;
- top = widgetRect.top - b.height - 4;
- break;
- case 'left':
- left = widgetRect.left - b.width - 6;
- top = widgetRect.top + widgetRect.height / 2 - b.height / 2;
- break;
- case 'right':
- default:
- left = widgetRect.right + 6;
- top = widgetRect.top + widgetRect.height / 2 - b.height / 2;
- }
- if (modalHost) {
- const mr = modalHost.getBoundingClientRect();
- left -= mr.left;
- top -= mr.top;
+ const target = placeRevealBubble(
+ widgetRect,
+ {width: b.width, height: b.height},
+ place,
+ {width: window.innerWidth, height: window.innerHeight},
+ );
+ bubble.style.left = `${target.x}px`;
+ bubble.style.top = `${target.y}px`;
+ const painted = bubble.getBoundingClientRect();
+ const dx = target.x - painted.x;
+ const dy = target.y - painted.y;
+ if (Math.abs(dx) >= 0.5 || Math.abs(dy) >= 0.5) {
+ bubble.style.left = `${target.x + dx}px`;
+ bubble.style.top = `${target.y + dy}px`;
}
- bubble.style.left = `${Math.max(0, Math.round(left))}px`;
- bubble.style.top = `${Math.max(0, Math.round(top))}px`;
+ return target;
}
const uniqueWidgets = findWidgetsForRevealText(text);
@@ -473,9 +575,12 @@ export function browserSideMeasure() {
// Inject one bubble per widget so translators see the reveal for
// every occurrence (e.g. "Expand row" on multiple rows).
- let lastBubble = null;
+ let lastRect = null;
for (const anc of uniqueWidgets) {
const pr = anc.getBoundingClientRect();
+ // A widget outside the capture gets no bubble: clamping one into
+ // view would park a tag on whatever is at the edge.
+ if (!inViewport(pr)) continue;
const bubble = document.createElement('div');
applyBubbleStyle(bubble, text);
// Native <dialog>.showModal() renders inside the browser's "top
@@ -487,12 +592,12 @@ export function browserSideMeasure() {
anc.closest('dialog[open]') || anc.closest('[popover]');
const host = modalHost || document.body;
host.appendChild(bubble);
- positionBubble(bubble, pr, place, modalHost);
- cachePaintRect(bubble);
- lastBubble = bubble;
+ const rect = positionBubble(bubble, pr, place);
+ cacheRect(bubble, rect);
+ lastRect = rect;
}
- if (!lastBubble) return null;
- return readCachedRect(lastBubble);
+ // A bubble larger than the viewport cannot be placed legally.
+ return inViewport(lastRect) ? lastRect : null;
}
// Dispatcher --------------------------------------------------------------
diff --git a/internal/scripts/upload-crowdin-screenshots.mjs b/internal/scripts/upload-crowdin-screenshots.mjs
index 06c53ba683..2349e28a6f 100644
--- a/internal/scripts/upload-crowdin-screenshots.mjs
+++ b/internal/scripts/upload-crowdin-screenshots.mjs
@@ -21,7 +21,8 @@
// packages/core/locales/en.json (warn+skip unknowns).
// 3. Start a local static server, launch chromium.
// 4. For each target: navigate, interact, screenshot, measure each
-// declared tag's rect using its named strategy.
+// declared tag's rect using its named strategy. A rect the capture
+// does not contain is reported unresolved, never tagged.
// 5. Upload the PNG to Crowdin (WITHOUT --auto-tag), then POST manual
// tags for the rects we measured.
//
@@ -50,7 +51,11 @@ import * as http from 'node:http';
import * as fs from 'node:fs';
import * as path from 'node:path';
import {fileURLToPath} from 'node:url';
-import {browserSideMeasure, STRATEGY_NAMES} from './lib/crowdin-strategies.mjs';
+import {
+ buildMeasureSource,
+ STRATEGY_NAMES,
+ toDevicePixelRect,
+} from './lib/crowdin-strategies.mjs';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const REPO_ROOT = path.resolve(__dirname, '..', '..');
@@ -785,6 +790,597 @@ const TARGETS = [
t('astryx.tableGroupedRows.expandGroup', 'srOnlyReveal', 'Expand group Infra', 'right'),
],
},
+
+ // ==========================================================================
+ // Catalog-coverage targets
+ //
+ // One target per story that renders strings the targets above do not
+ // already tag. A (key, story, strategy) triple is only valid when the
+ // story's own component is the one that REFERENCES the key — six
+ // components own a `Clear {label}`, so a text match alone is a
+ // coincidence. Strings reachable only inside a closed overlay are
+ // deliberately absent.
+ //
+ // These use the non-mutating strategies rather than srOnlyReveal: several
+ // injected bubbles on one target would overlap each other.
+ // ==========================================================================
+ {
+ name: 'transferlist-default',
+ storyId: 'lab-transferlist--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.transferList.addAll', 'visibleText'),
+ t('astryx.transferList.addOption', 'visibleText', "Add all"),
+ t('astryx.transferList.clear', 'visibleText'),
+ t('astryx.transferList.removeOption', 'ariaLabel', "Remove Name"),
+ t('astryx.transferList.reorderInstructions', 'srOnlyLabel'),
+ t('astryx.transferList.reorderOption', 'ariaLabel', "Reorder Name"),
+ t('astryx.transferListSelector.triggerLabel', 'visibleText', "Move fields between the panels. The selected order is the display order."),
+ ],
+ },
+ {
+ name: 'dateinput-default',
+ storyId: 'core-dateinput--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.dateInput.closeCalendar', 'srOnlyLabel'),
+ t('astryx.dateInput.openCalendar', 'ariaLabel'),
+ t('astryx.dateInput.placeholder', 'placeholder'),
+ t('astryx.dateInput.toggleCalendarClose', 'srOnlyLabel'),
+ ],
+ },
+ {
+ name: 'datetimeinput-default',
+ storyId: 'core-datetimeinput--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.dateTimeInput.openTimePicker', 'ariaLabel', "Open calendar"),
+ t('astryx.dateTimeInput.timePlaceholder', 'placeholder'),
+ ],
+ },
+ {
+ name: 'listinput-loading',
+ storyId: 'lab-listinput--loading',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.listInput.removeItem', 'ariaLabel', "Remove tag 1"),
+ t('astryx.listInput.reorderItem', 'ariaLabel', "Reorder tag 1"),
+ ],
+ },
+ {
+ name: 'pagination-default',
+ storyId: 'core-pagination--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.pagination.goToPage', 'ariaLabel', "Go to page 1"),
+ t('astryx.pagination.label', 'ariaLabel'),
+ t('astryx.pagination.next', 'ariaLabel'),
+ t('astryx.pagination.previous', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'stepper-default',
+ storyId: 'core-stepper--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.step.goToStep', 'ariaLabel', "Go to step 1: Create workspace, completed"),
+ t('astryx.step.goToStepWithStatus', 'ariaLabel', "Go to step 1: Create workspace, completed"),
+ t('astryx.step.status.completed', 'srOnlyLabel'),
+ t('astryx.stepper.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'carousel-default',
+ storyId: 'core-carousel--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.carousel.scrollLeft', 'ariaLabel'),
+ t('astryx.carousel.scrollRight', 'ariaLabel'),
+ t('astryx.carousel.slideLabel', 'ariaLabel', "Slide 1 of 8"),
+ ],
+ },
+ {
+ name: 'listinput-empty-mailing-list',
+ storyId: 'lab-listinput--empty-mailing-list',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.listInput.addItem', 'visibleText', "Add a subscriber to get started."),
+ t('astryx.listInput.emptyDescription', 'visibleText', "Add a subscriber to get started."),
+ t('astryx.listInput.emptyTitle', 'visibleText', "No subscribers yet"),
+ ],
+ },
+ {
+ name: 'calendar-default',
+ storyId: 'core-calendar--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.calendar.nextMonth', 'ariaLabel'),
+ t('astryx.calendar.previousMonth', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'daterangeinput-default',
+ storyId: 'core-daterangeinput--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.dateRangeInput.placeholder', 'visibleText'),
+ ],
+ },
+ {
+ name: 'fileinput-required',
+ storyId: 'core-fileinput--required',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.fileInput.placeholder', 'visibleText'),
+ ],
+ },
+ {
+ name: 'markdown-default',
+ storyId: 'core-markdown--default',
+ // 800 tall leaves the task list below the fold, so it goes untagged.
+ viewport: {width: 1200, height: 1000},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.markdown.table', 'visibleText'),
+ t('astryx.markdown.taskList', 'srOnlyLabel'),
+ ],
+ },
+ {
+ name: 'multiselector-empty-states',
+ storyId: 'core-multiselector--empty-states',
+ viewport: {width: 1200, height: 800},
+ // The options panel only exists once the trigger is clicked.
+ interact: async page => {
+ await page.locator('button:visible').first().click({timeout: 3000});
+ await page.waitForTimeout(500);
+ },
+ selector: null,
+ manualTags: [
+ t('astryx.multiSelector.empty', 'visibleText'),
+ t('astryx.multiSelector.selectPlaceholder', 'visibleText'),
+ ],
+ },
+ {
+ name: 'multiselector-searchable-sections',
+ storyId: 'core-multiselector--searchable-sections',
+ viewport: {width: 1200, height: 800},
+ // The options panel only exists once the trigger is clicked.
+ interact: async page => {
+ await page.locator('button:visible').first().click({timeout: 3000});
+ await page.waitForTimeout(500);
+ },
+ selector: null,
+ manualTags: [
+ t('astryx.multiSelector.searchOptions', 'ariaLabel'),
+ t('astryx.multiSelector.searchPlaceholder', 'placeholder'),
+ ],
+ },
+ {
+ name: 'numberinput-with-number-steppers',
+ storyId: 'core-numberinput--with-number-steppers',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.numberInput.decrementLabel', 'ariaLabel', "Decrement Quantity"),
+ t('astryx.numberInput.incrementLabel', 'ariaLabel', "Increment Quantity"),
+ ],
+ },
+ {
+ name: 'selector-empty-states',
+ storyId: 'core-selector--empty-states',
+ viewport: {width: 1200, height: 800},
+ // The options panel only exists once the trigger is clicked.
+ interact: async page => {
+ await page.locator('button:visible').first().click({timeout: 3000});
+ await page.waitForTimeout(500);
+ },
+ selector: null,
+ manualTags: [
+ t('astryx.selector.empty', 'visibleText'),
+ t('astryx.selector.placeholder', 'visibleText'),
+ ],
+ },
+ {
+ name: 'selector-searchable-with-sections',
+ storyId: 'core-selector--searchable-with-sections',
+ viewport: {width: 1200, height: 800},
+ // The options panel only exists once the trigger is clicked.
+ interact: async page => {
+ await page.locator('button:visible').first().click({timeout: 3000});
+ await page.waitForTimeout(500);
+ },
+ selector: null,
+ manualTags: [
+ t('astryx.selector.searchOptions', 'ariaLabel'),
+ t('astryx.selector.searchPlaceholder', 'placeholder'),
+ ],
+ },
+ {
+ name: 'stepper-status-vertical',
+ storyId: 'core-stepper--status-vertical',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.step.optional', 'visibleText'),
+ t('astryx.step.status.error', 'srOnlyLabel'),
+ ],
+ },
+ {
+ name: 'transferlist-searchable',
+ storyId: 'lab-transferlist--searchable',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.transferList.availableLabel', 'visibleText'),
+ t('astryx.transferList.searchLabel', 'placeholder', "Search 200 fields"),
+ ],
+ },
+ {
+ name: 'avatargroup-default',
+ storyId: 'core-avatargroup--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.avatarGroup.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'avatargroup-server-side-count',
+ storyId: 'core-avatargroup--server-side-count',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.avatarGroup.overflow', 'ariaLabel', "44 more"),
+ ],
+ },
+ {
+ name: 'breadcrumbs-default',
+ storyId: 'core-breadcrumbs--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.breadcrumbs.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'button-loading',
+ storyId: 'core-button--loading',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.button.loading', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'calendar-with-selected-date',
+ storyId: 'core-calendar--with-selected-date',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.calendar.daySelected', 'ariaLabel', "Thursday, January 15, 2026, selected"),
+ ],
+ },
+ {
+ name: 'chat-default',
+ storyId: 'core-chat--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.chatMessage.messageFrom', 'ariaLabel', "Message from user"),
+ ],
+ },
+ {
+ name: 'chat-message-status',
+ storyId: 'core-chat--message-status',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.chatToolCalls.status.error', 'visibleText'),
+ ],
+ },
+ {
+ name: 'citation-label',
+ storyId: 'core-citation--label',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.citation.label', 'ariaLabel', "Citation 1: React Documentation"),
+ ],
+ },
+ {
+ name: 'codeblock-default',
+ storyId: 'core-codeblock--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.codeBlock.copyCode', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'daterangeinput-with-warning-status',
+ storyId: 'core-daterangeinput--with-warning-status',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.dateInput.clear', 'ariaLabel', "Clear Date range"),
+ ],
+ },
+ {
+ name: 'dropdownmenu-compact-drill-in-presentation',
+ storyId: 'core-dropdownmenu--compact-drill-in-presentation',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.dropdownMenu.back', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'fileinput-multiple-files',
+ storyId: 'core-fileinput--multiple-files',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.fileInput.placeholderMultiple', 'visibleText'),
+ ],
+ },
+ {
+ name: 'metadatalist-show-more',
+ storyId: 'core-metadatalist--show-more',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.metadataList.showMore', 'visibleText'),
+ ],
+ },
+ {
+ name: 'moremenu-default',
+ storyId: 'core-moremenu--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.moreMenu.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'multiselector-searchable',
+ storyId: 'core-multiselector--searchable',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.multiSelector.selectAll', 'srOnlyLabel'),
+ ],
+ },
+ {
+ name: 'multiselector-default',
+ storyId: 'core-multiselector--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.multiSelector.selectionCount', 'visibleText', "2 selected"),
+ ],
+ },
+ {
+ name: 'outline-compact',
+ storyId: 'core-outline--compact',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.outline.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'pagination-compact-variant',
+ storyId: 'core-pagination--compact-variant',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.pagination.pageAnnounce', 'visibleText', "Page 1 of 10"),
+ ],
+ },
+ {
+ name: 'pagination-dots-variant',
+ storyId: 'core-pagination--dots-variant',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.pagination.pageIndicators', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'popover-default',
+ storyId: 'core-popover--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.popover.close', 'srOnlyLabel'),
+ ],
+ },
+ {
+ name: 'powersearch-default',
+ storyId: 'core-powersearch--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.powersearch.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'sidenav-with-header-menu',
+ storyId: 'core-sidenav--with-header-menu',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.sideNav.heading.openMenu', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'sidenav-default',
+ storyId: 'core-sidenav--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.sideNav.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'spinner-default',
+ storyId: 'core-spinner--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.spinner.loading', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'stepper-status-all-states',
+ storyId: 'core-stepper--status-all-states',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.step.status.warning', 'srOnlyLabel'),
+ ],
+ },
+ {
+ name: 'tablist-default',
+ storyId: 'core-tablist--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.tabList.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'table-default',
+ storyId: 'core-table--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.table.label', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'thumbnail-with-remove',
+ storyId: 'core-thumbnail--with-remove',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.thumbnail.remove', 'ariaLabel', "Remove photo.png — Removable thumbnail"),
+ ],
+ },
+ {
+ name: 'timeinput-with-clear-button',
+ storyId: 'core-timeinput--with-clear-button',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.timeInput.clearLabel', 'ariaLabel', "Clear Start time"),
+ ],
+ },
+ {
+ name: 'timeinput-native-picker-modes',
+ storyId: 'core-timeinput--native-picker-modes',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.timeInput.openPicker', 'ariaLabel', "Open nativePicker='always'"),
+ ],
+ },
+ {
+ name: 'timeinput-default',
+ storyId: 'core-timeinput--default',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.timeInput.placeholder', 'placeholder'),
+ ],
+ },
+ {
+ name: 'token-with-remove',
+ storyId: 'core-token--with-remove',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.token.remove', 'ariaLabel', "Remove Removable"),
+ ],
+ },
+ {
+ name: 'treelist-fully-expanded',
+ storyId: 'core-treelist--fully-expanded',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.treeList.toggleChildren', 'ariaLabel'),
+ ],
+ },
+ {
+ name: 'typeahead-status-variant-comparison',
+ storyId: 'core-typeahead--status-variant-comparison',
+ viewport: {width: 1200, height: 800},
+ interact: async () => {},
+ selector: null,
+ manualTags: [
+ t('astryx.typeahead.searchPlaceholder', 'placeholder'),
+ ],
+ },
];
// ---------- validation ----------
@@ -858,7 +1454,7 @@ async function main() {
if (missing.length) warn(`⚠ --only names not found in TARGETS: ${missing.join(', ')}`);
}
- const measureFnSource = `(${browserSideMeasure.toString()})()`;
+ const measureFnSource = buildMeasureSource();
try {
for (const target of targets) {
@@ -898,6 +1494,9 @@ async function main() {
}
const outPath = path.join(OUT_DIR, `${target.name}.png`);
+ // A viewport capture is the viewport at the device pixel ratio.
+ const imageWidth = target.viewport.width * DPR;
+ const imageHeight = target.viewport.height * DPR;
if (target.selector) {
await page.locator(target.selector).first().screenshot({path: outPath});
} else {
@@ -927,19 +1526,20 @@ async function main() {
measured.push({
key: tag.key,
strategy: tag.strategy,
- position: {
- x: Math.round(rect.x * DPR),
- y: Math.round(rect.y * DPR),
- width: Math.round(rect.width * DPR),
- height: Math.round(rect.height * DPR),
- },
+ position: toDevicePixelRect(rect, DPR),
});
}
}
const hit = measured.filter(m => m.position).length;
log(` ↳ measured ${hit}/${measured.length} tag positions`);
for (const m of measured) {
- if (!m.position) warn(` · skip ${m.key} (${m.reason}${m.strategy ? ` via ${m.strategy}` : ''})`);
+ if (!m.position) {
+ warn(` · skip ${m.key} (${m.reason}${m.strategy ? ` via ${m.strategy}` : ''})`);
+ } else if (DRY_RUN || SKIP_UPLOAD) {
+ // Print the rect against the image size on inspectable runs.
+ const p = m.position;
+ log(` · ${m.key} [${p.x},${p.y} ${p.width}×${p.height}] → ${p.x + p.width},${p.y + p.height} of ${imageWidth}×${imageHeight}`);
+ }
}
}