stitch2 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/config.schema.json +1 -1
- package/dist/canvas.html +4 -1
- package/dist/check.js +33 -3
- package/dist/config.d.ts +2 -1
- package/dist/typecheck.d.ts +2 -0
- package/package.json +1 -1
- package/skills/stitch2/SKILL.md +3 -1
- package/skills/stitch2/references/screens.md +4 -2
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ file that already exists. From there the agent spends its effort on the design.
|
|
|
59
59
|
icon-only controls without a name, more than five bottom-navigation destinations and controls without visible
|
|
60
60
|
focus. Motion: transitions whose length isn't one of DESIGN.md's motion tokens, and anything that still moves
|
|
61
61
|
with reduced motion on. Each screen is also run in long and right-to-left
|
|
62
|
-
pseudo-languages and your locales (see below).
|
|
62
|
+
pseudo-languages and your locales (see below), and, with `modes`, in each app state it is not drawn in.
|
|
63
63
|
- **States** (from `stitch2 check` on the component catalog): every control at rest, hovered, focused and
|
|
64
64
|
pressed, forced through Chromium so the components need nothing extra, side by side on one sheet; with
|
|
65
65
|
warnings for a control that gives no feedback and text that loses contrast in a state.
|
|
@@ -262,7 +262,7 @@ layout first, then a shorter natural word, never a smaller type size.
|
|
|
262
262
|
| `stitch2 init --name N --primary #hex [options]` | Writes a complete DESIGN.md from a few choices |
|
|
263
263
|
| `stitch2 extract <url or file…>` | Writes a DESIGN.md measured from an existing site or screens |
|
|
264
264
|
| `stitch2 canvas` | The canvas at http://localhost:4400 (`PORT` and `HOST` to change) |
|
|
265
|
-
| `stitch2 check [filter] [--shots] [--strict] [--locales l,…]` | All checks, in every theme and check language; `--shots` saves renders to `<design>/renders/` (`--light.png`, `--pseudo.png`…) |
|
|
265
|
+
| `stitch2 check [filter] [--shots] [--strict] [--locales l,…]` | All checks, in every theme, app state and check language; `--shots` saves renders to `<design>/renders/` (`--light.png`, `--pseudo.png`, `--auth-user.png`…) |
|
|
266
266
|
| `stitch2 i18n [filter] [--locale l] [--suggest] [--json]` | Message keys the source or a locale lacks, and screen text with no key |
|
|
267
267
|
| `stitch2 consistency [kind…]` | The consistency report, `<design>/consistency/index.html` |
|
|
268
268
|
| `stitch2 type [filter] [--json]` | The type audit |
|
package/config.schema.json
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"modes": {
|
|
81
81
|
"type": "array",
|
|
82
|
-
"description": "App states every screen can be shown in, picked from the canvas sidebar: signed in or out, a plan, a role. The pick is an attribute on each screen's <html>, so the screens' own CSS and scripts answer to it. The dropdown also offers the screens as drawn, which leaves each one as its file has it.",
|
|
82
|
+
"description": "App states every screen can be shown in, picked from the canvas sidebar: signed in or out, a plan, a role. The pick is an attribute on each screen's <html>, so the screens' own CSS and scripts answer to it. The dropdown also offers the screens as drawn, which leaves each one as its file has it. stitch2 check also runs each screen in every value its file does not already have, one mode at a time, and tags what only shows there.",
|
|
83
83
|
"items": {
|
|
84
84
|
"type": "object",
|
|
85
85
|
"additionalProperties": false,
|
package/dist/canvas.html
CHANGED
|
@@ -920,7 +920,10 @@ function inspector(f) {
|
|
|
920
920
|
li.querySelector('code').textContent = i.selector
|
|
921
921
|
li.onclick = () => {
|
|
922
922
|
const r = rangeOf(s)
|
|
923
|
-
|
|
923
|
+
// An issue found in another app state: show every screen in it, then find the element.
|
|
924
|
+
const [mode, value] = i.mode ? i.mode.split(':') : []
|
|
925
|
+
if (mode && modePick[mode] !== value) { setMode(mode, value); setTimeout(() => locate(f, i.selector), 600) }
|
|
926
|
+
else if (i.width && r && i.width !== s.width) { setWidth(i.width === r[0] ? 'narrow' : i.width === r[1] ? 'wide' : `at:${i.width}`); setTimeout(() => locate(f, i.selector), 900) }
|
|
924
927
|
else locate(f, i.selector)
|
|
925
928
|
}
|
|
926
929
|
ul.append(li)
|
package/dist/check.js
CHANGED
|
@@ -5,13 +5,16 @@
|
|
|
5
5
|
* the canvas shows as badges.
|
|
6
6
|
* Every screen is checked in its own theme, then again in each other theme DESIGN.md defines (designThemes):
|
|
7
7
|
* colours change there, so contrast is checked again, tagged with the theme.
|
|
8
|
+
* Then in each app state (config modes), one mode at a time and in the screen's own theme: a screen is checked with
|
|
9
|
+
* every value its own file does not already have, and what only shows there (a bar that overflows signed in, a control
|
|
10
|
+
* that crowds another) is tagged with the state.
|
|
8
11
|
* Then again in each check language (i18n.ts: the pseudo-languages and the config's): layout problems that
|
|
9
12
|
* show only there (a label running into its neighbour, text cut off, a control drawn backwards right to left),
|
|
10
13
|
* and keys a locale has no translation for, tagged with the locale. Last, each variant at both ends of the widths
|
|
11
14
|
* it covers (config widths: mobile 360–599, desktop 1024–1920 by default) and at every breakpoint inside them
|
|
12
15
|
* (config breakpoints, Tailwind's by default), tagged with the width.
|
|
13
16
|
* Usage: stitch2 check [path filter…] [--shots] [--strict] [--locales ru,ar | all | none]
|
|
14
|
-
* --shots also save page-tall renders to design/renders/ (one per theme, language and width)
|
|
17
|
+
* --shots also save page-tall renders to design/renders/ (one per theme, app state, language and width)
|
|
15
18
|
* --strict exit 1 when any screen has errors (for CI and agent loops)
|
|
16
19
|
* Screens run four at a time; reruns only visit screens that changed since design/checks.json (or
|
|
17
20
|
* everything DESIGN.md, the tokens, the components or the catalog changed since).
|
|
@@ -22,7 +25,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
22
25
|
import { chromium } from '@playwright/test';
|
|
23
26
|
import { fingerprintPaths } from './cache.js';
|
|
24
27
|
import { colourIssues } from './colours.js';
|
|
25
|
-
import { CONFIG_FILE, checkWidths, config } from './config.js';
|
|
28
|
+
import { CONFIG_FILE, checkWidths, config, modes } from './config.js';
|
|
26
29
|
import { collectComponents, collectOptions, consistencyIssues, reuseIssues, } from './consistency.js';
|
|
27
30
|
import { designThemes, motionDurations, typeLevels } from './design-md.js';
|
|
28
31
|
import { checkLocales } from './i18n.js';
|
|
@@ -40,6 +43,7 @@ const filters = args.filter((a, i) => !a.startsWith('--') && (localesFlag < 0 ||
|
|
|
40
43
|
const screens = listScreens().filter((s) => !filters.length || filters.some((f) => s.path.includes(f)));
|
|
41
44
|
const levels = typeLevels();
|
|
42
45
|
const themes = designThemes();
|
|
46
|
+
const appModes = modes();
|
|
43
47
|
const collect = collectOptions();
|
|
44
48
|
/** What the layout audit needs: the comfortable tap size and DESIGN.md's motion durations. */
|
|
45
49
|
const auditOpts = { comfortable: config.comfortableTarget, durations: (() => { try {
|
|
@@ -134,6 +138,23 @@ const checkOne = async (s, worker) => {
|
|
|
134
138
|
}
|
|
135
139
|
if (themes.length > 1)
|
|
136
140
|
await setTheme(page, base);
|
|
141
|
+
// The app states: each value the screen is not drawn in, one mode at a time, then the screen's own value again.
|
|
142
|
+
for (const mode of appModes) {
|
|
143
|
+
const drawn = await page.evaluate((attribute) => document.documentElement.getAttribute(attribute), mode.attribute);
|
|
144
|
+
for (const value of mode.values.filter((v) => v.value !== drawn)) {
|
|
145
|
+
await setAttribute(page, mode.attribute, value.value);
|
|
146
|
+
for (const i of await page.evaluate(audit, auditOpts)) {
|
|
147
|
+
const key = `${i.type} ${i.selector}`;
|
|
148
|
+
if (seen.has(key))
|
|
149
|
+
continue;
|
|
150
|
+
seen.add(key);
|
|
151
|
+
themed.push({ ...i, ...(i.type === 'contrast' ? { theme: base } : {}), mode: `${mode.name}:${value.value}`, message: `${value.label}: ${i.message}` });
|
|
152
|
+
}
|
|
153
|
+
if (shots)
|
|
154
|
+
await shoot(page, s, undefined, undefined, `${mode.name}-${value.value}`);
|
|
155
|
+
}
|
|
156
|
+
await setAttribute(page, mode.attribute, drawn);
|
|
157
|
+
}
|
|
137
158
|
const typed = typeIssues(levels, await page.evaluate(collectText));
|
|
138
159
|
if (shots)
|
|
139
160
|
await shoot(page, s);
|
|
@@ -251,7 +272,16 @@ async function setTheme(page, theme) {
|
|
|
251
272
|
}, theme);
|
|
252
273
|
await page.waitForTimeout(150);
|
|
253
274
|
}
|
|
254
|
-
|
|
275
|
+
async function setAttribute(page, attribute, value) {
|
|
276
|
+
await page.evaluate(([name, to]) => {
|
|
277
|
+
if (to === null)
|
|
278
|
+
document.documentElement.removeAttribute(name);
|
|
279
|
+
else
|
|
280
|
+
document.documentElement.setAttribute(name, to);
|
|
281
|
+
}, [attribute, value]);
|
|
282
|
+
await page.waitForTimeout(150);
|
|
283
|
+
}
|
|
284
|
+
/** A page-tall render; renders in another theme, app state or language than the screen's own get a --<name> suffix. */
|
|
255
285
|
async function shoot(page, s, theme, locale, at) {
|
|
256
286
|
const height = await page.evaluate(() => document.documentElement.scrollHeight);
|
|
257
287
|
await page.setViewportSize({ width: s.width, height: Math.max(844, Math.min(height, MAX_RENDER_HEIGHT)) });
|
package/dist/config.d.ts
CHANGED
|
@@ -60,7 +60,8 @@ export interface LabConfig {
|
|
|
60
60
|
sandboxExclude?: string[];
|
|
61
61
|
/**
|
|
62
62
|
* App states shown across all screens (see ModeConfig). The canvas has a dropdown for each, with the screens as drawn
|
|
63
|
-
* first; picking a value sets its attribute on every screen, live ones and the pictures of the rest.
|
|
63
|
+
* first; picking a value sets its attribute on every screen, live ones and the pictures of the rest. stitch2 check also
|
|
64
|
+
* runs each screen in every value its file does not already have, one mode at a time.
|
|
64
65
|
*/
|
|
65
66
|
modes?: ModeConfig[];
|
|
66
67
|
/** The live app, for stitch2 compare (see compare.ts): its URL, a sign-in script and a route per screen. */
|
package/dist/typecheck.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface Issue {
|
|
|
15
15
|
locale?: string;
|
|
16
16
|
/** Set when the issue shows only at another window width: the edge of its variant's range (config widths). */
|
|
17
17
|
width?: number;
|
|
18
|
+
/** Set when the issue shows only in another app state (config modes): "name:value", as the canvas sidebar names it. */
|
|
19
|
+
mode?: string;
|
|
18
20
|
}
|
|
19
21
|
export interface TextItem {
|
|
20
22
|
selector: string;
|
package/package.json
CHANGED
package/skills/stitch2/SKILL.md
CHANGED
|
@@ -77,6 +77,8 @@ References, read before the first screen:
|
|
|
77
77
|
An issue tagged with a width ("at 1024px: …") breaks at an edge of the windows the variant covers: fix it with a
|
|
78
78
|
responsive rule in the screen, or a new variant when the layout's structure has to change (screens.md, Widths).
|
|
79
79
|
Widths include the breakpoints inside the range; `narrow-layout` is a phone column left in a wide window.
|
|
80
|
+
An issue tagged with an app state ("Signed in: …"; `modes` in the config, screens.md) shows only in that state: fix it in
|
|
81
|
+
the screen's rules for that state, and look at its render (`--auth-user.png`). Clicking it on the canvas shows the state.
|
|
80
82
|
Overlap checks compare the drawn fragments of wrapped inline controls, not the empty corners of their
|
|
81
83
|
bounding boxes. For fixed bars, the browser's paint order decides coverage: a menu painted in front of a
|
|
82
84
|
header is not hidden by it. Native modal dialogs and ARIA modals limit coverage and control comparisons
|
|
@@ -127,7 +129,7 @@ References, read before the first screen:
|
|
|
127
129
|
|---|---|
|
|
128
130
|
| `setup [--name N --primary #hex] [options]` | Sets a project up in one step; keeps every file that exists |
|
|
129
131
|
| `canvas` | The canvas at http://localhost:4400: screens and versions, DESIGN.md, the consistency report, approval and notes |
|
|
130
|
-
| `check [filter] [--shots] [--strict] [--locales l,…]` | Layout, type, reuse and consistency checks, in every theme and check language, and at both ends of each variant's widths; `--shots` saves renders |
|
|
132
|
+
| `check [filter] [--shots] [--strict] [--locales l,…]` | Layout, type, reuse and consistency checks, in every theme, app state and check language, and at both ends of each variant's widths; `--shots` saves renders |
|
|
131
133
|
| `i18n [filter] [--locale l] [--suggest]` | Message keys screens use that the source or a locale lacks, and text with no key (stitch2-i18n) |
|
|
132
134
|
| `consistency [kind…]` | Every shared component cropped from every screen, next to the catalog's version |
|
|
133
135
|
| `type [filter] [--json]` | Every text style a screen uses and the type level it matches |
|
|
@@ -186,8 +186,10 @@ screen per state. Draw it once, let its CSS and scripts answer to an attribute o
|
|
|
186
186
|
The canvas sidebar then has a dropdown for each mode. A value sets the attribute (`data-auth="user"`; `attribute`
|
|
187
187
|
names another) on every screen, live frames and the pictures of the rest, and "As drawn" puts each screen back to what
|
|
188
188
|
its file says. `m` cycles the first mode. A screen is still written for the state it shows (a signed-in account page has
|
|
189
|
-
`data-auth="user"` in its file); modes show the other states of the same screen. `stitch2 check` runs
|
|
190
|
-
|
|
189
|
+
`data-auth="user"` in its file); modes show the other states of the same screen. `stitch2 check` also runs each screen in every
|
|
190
|
+
value its own file does not have, one mode at a time (modes are not combined), and tags what only shows there with the
|
|
191
|
+
state ("Signed in: …"); clicking such an issue on the canvas shows that state. With `--shots` each state is rendered too
|
|
192
|
+
(`<screen>--auth-user.png`): look at it before hand-over.
|
|
191
193
|
|
|
192
194
|
## The canvas
|
|
193
195
|
|