@usableapp/cardds 0.7.178 → 0.7.180

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/bin/cardds.mjs +23 -3
  3. package/css/actions.css +11 -8
  4. package/css/base.css +13 -2
  5. package/css/card.css +39 -7
  6. package/css/layover.css +25 -16
  7. package/css/lists.css +58 -4
  8. package/css/media.css +33 -0
  9. package/css/parts.css +20 -2
  10. package/css/stack.css +43 -1
  11. package/css/tokens.css +4 -1
  12. package/dist/actions/Btn.d.ts +6 -2
  13. package/dist/actions/Btn.js +5 -2
  14. package/dist/cardds.css +246 -41
  15. package/dist/cards/Card.d.ts +1 -1
  16. package/dist/cards/Card.js +4 -1
  17. package/dist/cards/CardParts.d.ts +12 -5
  18. package/dist/cards/CardParts.js +8 -7
  19. package/dist/cards/FeedPost.d.ts +31 -0
  20. package/dist/cards/FeedPost.js +14 -0
  21. package/dist/catalog.json +1 -1
  22. package/dist/index.d.ts +4 -0
  23. package/dist/index.js +4 -0
  24. package/dist/layover/Popup.d.ts +2 -2
  25. package/dist/layover/Popup.js +1 -1
  26. package/dist/lists/Bubble.d.ts +25 -6
  27. package/dist/lists/Bubble.js +17 -8
  28. package/dist/lists/Row.d.ts +11 -2
  29. package/dist/lists/Row.js +4 -3
  30. package/dist/media/Mosaic.d.ts +4 -3
  31. package/dist/media/Mosaic.js +8 -4
  32. package/dist/media/Thumb.d.ts +14 -0
  33. package/dist/media/Thumb.js +12 -0
  34. package/dist/parts/Foot.d.ts +7 -2
  35. package/dist/parts/Foot.js +4 -3
  36. package/dist/parts/Head.d.ts +3 -1
  37. package/dist/parts/Head.js +3 -1
  38. package/dist/scaffold/Centre.d.ts +1 -1
  39. package/dist/scaffold/Centre.js +1 -1
  40. package/dist/scaffold/Panes.d.ts +1 -0
  41. package/dist/scaffold/Panes.js +1 -0
  42. package/dist/sheets/Modal.d.ts +1 -1
  43. package/dist/sheets/Modal.js +1 -1
  44. package/dist/sheets/SheetStack.d.ts +3 -1
  45. package/dist/sheets/SheetStack.js +2 -1
  46. package/dist/sheets/StackSheet.d.ts +6 -4
  47. package/dist/sheets/StackSheet.js +8 -3
  48. package/dist/sheets/stackCard.d.ts +2 -0
  49. package/dist/templates/Home.d.ts +3 -1
  50. package/dist/templates/Home.js +2 -2
  51. package/dist/templates/Splash.d.ts +1 -1
  52. package/dist/templates/Splash.js +1 -1
  53. package/dist/type/Icon.js +1 -1
  54. package/dist/type/Phrase.d.ts +9 -0
  55. package/dist/type/Phrase.js +11 -0
  56. package/dist/type/Strong.d.ts +7 -0
  57. package/dist/type/Strong.js +9 -0
  58. package/dist/type/Text.d.ts +5 -1
  59. package/dist/type/Text.js +7 -3
  60. package/dist/type/icons.d.ts +1 -1
  61. package/dist/type/icons.js +2 -2
  62. package/docs/reference.md +121 -8
  63. package/icons.svg +1 -0
  64. package/lib/audit.mjs +330 -0
  65. package/lib/guide.mjs +1 -1
  66. package/lib/mcp.mjs +13 -0
  67. package/lint/rules.mjs +2 -2
  68. package/package.json +1 -1
package/docs/reference.md CHANGED
@@ -153,6 +153,8 @@ npx cardds scaffold <id> # a whole file from a screen: tsx (the code) or
153
153
  npx cardds get <Name> [--html] # one component: its role, props (a ReactNode prop is a slot), what it composes, its knobs + variations with code
154
154
  npx cardds list # every name by what it is for: one · group-brief · group-detail, the show-only first, then by what the member can do
155
155
  npx cardds check <dir> # the rules — a person's tool, never a session's step
156
+ npx cardds audit [file.html…] # a screen against "Rules of the system": no file = the questions to put to a picture, one set per rule;
157
+ # one file = one rendered page, several = a flow in that order; each fault { rule, page?, where, says }
156
158
  npx cardds guide # the few rules no checker sees, in one short text
157
159
  ```
158
160
 
@@ -163,7 +165,8 @@ component **composes** (the catalog names its own source renders or calls: `Fab`
163
165
  turned on or off", "a code digit by digit") finds the piece (`Toggle`, `Pin`).
164
166
 
165
167
  `list` · `get` · `find` · `scaffold` take `--json` (the function's result) and `--root <path>` (a cardds checkout: rebuilt first, so never stale). The same
166
- five answers over MCP — `list_components` · `get_component` · `find_components` · `scaffold_screen` · `check_source`:
168
+ five answers over MCP — `list_components` · `get_component` · `find_components` · `scaffold_screen` · `check_source` — and a sixth, `audit_screen`, for
169
+ the screen as the member sees it: the questions for a picture (no argument), the faults of a rendered page (`html`), of a flow (`pages`):
167
170
 
168
171
  ```json
169
172
  { "mcpServers": { "cardds": { "command": "npx", "args": ["cardds", "mcp"] } } }
@@ -271,9 +274,15 @@ In a `NoteRow` the words are one flowing line, so the old value follows the new
271
274
 
272
275
  (cardds#219) A list read and then left — the notifications under a bell — is four pieces, each opt-in; a screen written before them is unchanged.
273
276
 
274
- - **`Popup`** is a panel hung under the button that opens it: a head (`title`, a second line `meta`, ONE `Btn` as `action` at the right) and the list as its children. It is a native popover like `Menu popover`: any button with `popoverTarget={id}` opens it (the popup knows no button), a tap outside or Esc closes it. It is never wider than the screen less `--popup-margin` (default `--sp-3`) each side, and at most `--popup-w` (default 384) wide; too tall for the room under the button (at most `--popup-max-h`, default 576), the list scrolls inside it and the head stays at the top, opaque, so a row's fill passes under it. A button at the screen's right: with `end` the popup's right edge is the button's and it grows leftwards (the bar's own inset is its right margin; `--popup-margin` keeps the left one); without `end` it starts at the button's left edge and grows rightwards. Where the browser cannot anchor to the button (iOS before 26) it hangs under the top bar. The paper is the card-1 ground (`--popup-bg`, `--popup-border`, `--popup-radius`, `--popup-shadow`); head knobs `--popup-pad-x`, `--popup-pad-y`, `--popup-head-gap`. The unread count on the button is the app's: `<Btn shape="round" icon="bell" label="Notifications" count={n} popoverTarget="inbox" />`. Story `Popup · UnderABell`.
275
- - **`Rows joined`**: the rows touch (no `--rows-gap`), each is a band edge to edge of the list with its own padding (`--rows-joined-pad-x` 16, `--rows-joined-pad-y` 12) and a border under it, the last too (`--rows-joined-border`, default the hairline), so a row with a fill reads as a band joined to the next. The between-rows hairline is not drawn. For a holder with no padding of its own (a `Popup`); in a `Card` the rows would stand inside its padding. `Rows` without `joined` is unchanged.
277
+ - **`Popup`** is a panel hung under the button that opens it: a head (`title`, a second line `meta`, ONE `Btn` as `action` at the right) and the list as its children. It is a native popover like `Menu popover`: any button with `popoverTarget={id}` opens it (the popup knows no button), a tap outside or Esc closes it. It stands narrower than the cards under it, so their edges show on both sides: `--sp-2` in from the card's edge on the button's side and `--sp-6` in on the far side (a card stands `--screen-pad` in from the screen; 375 wide: a popup at x 40–351 over cards at 16–359). `--popup-margin`, when a project sets it, replaces both distances with one value (measured from the button's edge on its side and from the screen's edge on the far side when anchored; from the screen's edges when hung under the top bar), and still sets the margin under the popup. It is at most `--popup-w` (default 384) wide; too tall for the room under the button (at most `--popup-max-h`, default 576), the list scrolls inside it and the head stays at the top, opaque, so a row's fill passes under it. A button at the screen's right: with `end` the popup's right edge is `--sp-2` in from the button's and it grows leftwards (its left side is `--sp-6` in from the cards); without `end` its left edge is `--sp-2` in from the button's and it grows rightwards (its right side `--sp-6` in). Where the browser cannot anchor to the button (iOS before 26) it hangs under the top bar. The paper is the card-1 ground (`--popup-bg`, `--popup-border`, `--popup-radius`, `--popup-shadow`); head knobs `--popup-pad-x`, `--popup-pad-y`, `--popup-head-gap`. The unread count on the button is the app's: `<Btn shape="round" icon="bell" label="Notifications" count={n} popoverTarget="inbox" />`. Story `Popup · UnderABell`.
278
+ - **`Rows joined`**: the rows touch (no `--rows-gap`), each is a band edge to edge of the list with its own padding (`--rows-joined-pad-x` 16, `--rows-joined-pad-y` 12) and a border under it, the last too (`--rows-joined-border-w` default `--px`, a thin line, and `--rows-joined-border` default `--hairline-soft`, 10% of the ink: faint, cardds#229), so a row with a fill reads as a band joined to the next. The between-rows hairline is not drawn. For a holder with no padding of its own (a `Popup`); in a `Card` the rows would stand inside its padding. `Rows` without `joined` is unchanged.
276
279
  - **`Row unread`**: a row never opened has a very light grey fill over the whole row, the token `--unread-bg` (4% of the row's ink over whatever ground it stands on, so it is a light grey on paper and a light lift on a dark ground; knob `--row-unread-bg`). A screen reader hears "unread" (`unreadLabel` for another word). Drop `unread` once it is read; the fill is only the state, the app owns it.
280
+ - **`Row todo`** (cardds#223): a checklist item still to do and open to press. Where a `done` row has its tick, a `todo` row has an empty dashed circle of the same size and place, and its title and second line are faded (`--row-todo-ink`, default 40% of the card's ink; the ring is the same ink, knob `--row-todo-ring`): faded and dashed read as "not done yet", and the whole row is the target — a link or a button (`href`, or `as="a"` with the app's `onClick`) that takes the member where the thing is done. The circle is drawn, never a control, and the app's words name the row; the size is `--row-done-size`, as the tick's. `todo` is ignored on a `done` row. A `done` row keeps its muted title by default; `fullInk` keeps the card's ink beside the tick (the finished lines stand out against the faded ones). Stories `Row · Todo`, `Row · Controlled`.
281
+ - **A notification that is one line of words** (cardds#229, Lh 2026-11-18): `<Row leadLines={3} leadText="caption" unread><AvatarStack><Stamp bare … /></AvatarStack><Text level="caption" lines={3} corner="5 min" grow><Strong>Auntie Sri</Strong> • thank you for…</Text></Row>`. Three pieces, each opt-in:
282
+ - `Row leadLines` (1 to 3, with `leadText` `body` (default) or `caption`, the level of the words beside it): the lead stands as tall as that many lines of the text's line height (`--lh-*` × `--fs-*`, so it follows the text size). A `Stamp` in an `AvatarStack` is that tall at its 4:5 shape; a `Lead` is a square as wide as that stamp, in the middle of the height. A row with its lead 3 lines tall and fewer words is as tall as the stamp.
283
+ - `Strong`: some words heavy inside running text (`--strong-weight`, default `--fw-bold`, clearly heavier than every level's own, caption's medium included); the size, ink and line stay the text's. Works inside `Text lines`.
284
+ - `Text corner`: one short word (a time) at the top end of the words, muted (`--text-corner-ink`) and at the text's size, `--text-corner-gap` from them; the first line runs round it, the next lines are the full width. With `lines` the cut counts only the lines shown, and the corner never makes the row taller than its visible lines. Not with `expand`. A row that holds the time as an `End` instead takes a whole column from the words.
285
+ Stories `Row · Notifications`, `Row · LeadLines`, `Strong · InACaption`, `Strong · InCutWords`, `Text · CornerWord`, `Text · CornerOneLine`.
277
286
  - **`Lead tone`**: the box takes a FILL, one of six colours — `blue`, `green`, `amber`, `red`, `pink`, `violet` (`--tone-blue` … `--tone-violet`) — with no outline, and its icon is the ondark ink on it (white). It tells kinds of thing apart (the bank, a reminder, points); the names are colours, never a meaning: the app picks which kind wears which, and a person's lead is still a stamp or an avatar. Each colour holds the icon at 4.5:1 or more in every palette cardds ships ([Ink follows its ground](#ink-follows-its-ground)): the lowest is blue on clay, 4.74; green 5.84, amber 5.16, red 4.98, pink 5.23, violet 6.56 on clay, the dimmest ink. Colour is in `palette.css` and every coloured mode has them (a project's own `data-palette` too); the wireframe keeps six greys. A project whose ondark ink is dimmer retunes the tone `inkGrounds()` names (`--tone-<name>`), in its theme. Knobs `--lead-bg`, `--lead-ink`. Story `Lead · Tones`.
278
287
 
279
288
  ```tsx
@@ -399,7 +408,7 @@ of `Screen`:
399
408
  `<Sheet state="full" states="full" handle={false}>` · `<Head variant="sheet" title={name} />` (its close asks the sheet for `away`) ·
400
409
  `Body` (the `Thread`, or a `StickyThread lapped`) · `<Foot><MessageBar…/></Foot>`. The `MessageBar` is the foot's one child
401
410
  and takes its line and its padding; it stands on the sheet's bottom edge above the keyboard, and the body stops above it
402
- however tall it grows. The sheet's `topRow` is its pinned row under the head (the request the chat is about), as the
411
+ however tall it grows (`<Foot layer>` gives its strip a ground of its own: see Foot, below). The sheet's `topRow` is its pinned row under the head (the request the chat is about), as the
403
412
  Screen's. In the sticky look the sheet's last child is a `StickyAnswer` in place of the Foot. Opening at, and following,
404
413
  the last words is the app's (`scrollIntoView({ block: 'end' })` on the thread). Stories: `Bubble/ChatSheet`, `StickyScreens/ChatSheet`.
405
414
  - **A Thread follows its end, names no one twice** (Lh 2026-10-29). While the reader is at the last words, the `Thread` keeps
@@ -408,8 +417,28 @@ of `Screen`:
408
417
  and slides back down; at the end it is gone (`jumpLabel` names it, `false` drops it). The thread ends with room
409
418
  (`--thread-end-size`, default `--sp-4`) above the bar, so the last bubble's `meta` is never under it. A `Bubble`'s `author` leads
410
419
  its meta line only where the Thread's `authors` says: `none` (default — a 1-to-1 chat, the head names the person), `change` (a
411
- group: where the sender changes), `every`. A `Bubble`'s `day` (the date, with the time alone in `meta`) shows only where it
420
+ group: where the sender changes), `every` (a list of comments from several people: each names its writer). A `Bubble`'s `day` (the date, with the time alone in `meta`) shows only where it
412
421
  changes from the bubble before (`days="change"`, the default; `every` on each). `showAuthor` / `showDay` override one bubble. Stories `Bubble · JumpToLatest`, `Bubble · Group`.
422
+ - **A Thread in a feed has room of its own** (Lh 2026-11-17, cardds#214). A `Thread` that is a direct child of a `CardList`, between its cards,
423
+ is no chat: it has no bar under it, and a bubble is no card, so it crowds the card beside it. Its room over it and under it is the same,
424
+ `--thread-room-size` (default `--sp-4`), on top of the list's gap (`--card-list-gap`); `--thread-end-size` is the chat's and not read there.
425
+ Pass `jumpLabel={false}` (a feed has no last words to jump to). Story `Bubble · InFeed`.
426
+ - **Who said it stands above the message** (Lh 2026-11-17, cardds#214). `Bubble metaAbove` puts the caption line over the message instead of
427
+ under it, for a list of comments from several people, who read who is speaking before the words: `lead` (the picture: an `AvatarStack` with a
428
+ `Stamp bare`, an `Avatar`, at its own size) · `author` in bold (`--bubble-author-font`, `--bubble-author-ink`) · `day` · `meta`
429
+ (the time, small, after a "·"), on ONE line that never wraps (the name is cut with "…", the lead and the time keep their size). The bubble stands under the line from
430
+ its start edge, as wide as its words up to `--bubble-max-w` (the line is in that cap too), `--sp-2` below it (`--bubble-meta-above-gap`): never led in
431
+ beside the picture, which left a few words a line. The line is first in the markup, so it is heard before the words. `lead` and `author` show where the
432
+ Thread's `authors` says (`every` in a comment list); where they do not (the same writer twice, `change`), the line is the time alone. Mine (`side="right"`):
433
+ the line at the right over the bubble, usually the time alone. Without `metaAbove` the caption stays under the message and `lead` is not drawn.
434
+ `action` is ONE round `Btn` beside the message, centred on its height: after theirs, before mine (a delete, a reply), `--bubble-action-gap` (`--sp-2`) from it, inside
435
+ the same cap. It is not for a `Bubble` with `href` or `onClick` (a button in a link): there it is ignored with a warning, and a pressed message with its button
436
+ stands in a `Row` (story `Bubble · FeedReply`). Stories `Bubble · Comments`, `Bubble · InFeed`.
437
+ - **The message it answers** (Lh 2026-11-18, cardds#227). `Bubble quote` puts one line at the top INSIDE the bubble, over the words: the message this one
438
+ answers (`Noi: Could I have a cutting?`), cut at one line with "…", a rule at its start like the `quote` of a `MessageBar`, small (`caption`) and fainter than the
439
+ words. It is the muted ink of the bubble's ground, so it holds on a theirs and a mine bubble alike (`--bubble-quote-ink`, `--bubble-quote-rule-ink`). The app
440
+ passes the words only; the rule is drawn. It is part of the bubble: `onClick`, `href` and `highlighted` take the line with the words (a tap on it is a tap on
441
+ the bubble). The reply flow beside it is the app's: the `Bubble highlighted` the member is answering and `MessageBar quote` under the thread. Story `Bubble · Quote`.
413
442
  - **A pressed message, and the one looked at** (Lh 2026-10-28). A `Bubble` with `href` is a link (an `<a>`, `target`/`rel`
414
443
  beside it), with `onClick` a pressed one (`role="button"`, Enter and Space); both dim under the finger (the PRESS list's DIM)
415
444
  and take the focus ring. `highlighted` rings the message the member is looking at — the one a reply points at, the one a
@@ -546,6 +575,10 @@ whose markup has rules, because the sheet's box is the step itself:
546
575
  bigger through `--count-in-size`. A screen reader hears each number (`aria-live`). Not `Countdown`, which is a small link that waits.
547
576
  - **A `Modal` mounted with `open={false}` draws nothing and never calls `onClosed`** (it was never shown), the same in production and
548
577
  under React StrictMode. It appears when `open` turns `true`; each close after that plays the leave and calls `onClosed` once.
578
+ - **Where a `Modal` stands** (Lh 2026-11-18, cardds#231): its own 40% point is on the stage's 40% line (`--screen-centre`), as a `Card centre` (*Anatomy*, "Where the
579
+ centre is"), at rest, while it drops in and while its drawer comes out (the box grows about that point). It is capped so the 40% above the line clears the top bar's
580
+ line and the 60% below stays out of the bar's room (`--bar-reserve`); a taller `Body` scrolls and the `ModalAsk` keeps its height. A `Modal` with no `Body` (the confirm) and one with
581
+ no `ModalAsk` (details) stand on the same line. Story `Modal · TallUnderTopBar`.
549
582
  - **cardds names its own controls, in the page's language** (Lh 2026-09-29): a handle, a back button, a Pin's cells… read
550
583
  their name from `src/words.ts` by `<html lang>` (en, th ship; `setWords(lang, {…})` adds one). An app passes no label that
551
584
  only repeats these words; a prop still wins.
@@ -554,7 +587,7 @@ whose markup has rules, because the sheet's box is the step itself:
554
587
 
555
588
  One card at the human centre — the introduction screens, and any screen with
556
589
  one thing to read and one move. The heading above, the bar below, the card
557
- between at 40% down the screen (see *Anatomy*, "Where the centre is"):
590
+ between: its own 40% point on the line 40% down the screen (see *Anatomy*, "Where the centre is"):
558
591
 
559
592
  ```html
560
593
  <div class="screen screen--fill">
@@ -697,6 +730,20 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
697
730
  with `form labelled` its `label` is SHOWN as words at its left, the two
698
731
  centred as one line (Lh 2026-10-10). The narrowing from three on is the knob `--foot-crowd-pad-x` (default
699
732
  `--sp-2`): a theme that wants one pill shape for worded and icon-only Btns sets it to the Btn's own side padding.
733
+ - **A post's moves are a `BtnGroup` frame** (Lh 2026-11-18, cardds#213, design B). One frame, equal shares, a rule between them; each
734
+ a round `Btn` of an icon and its NUMBER as a word beside it (`<Btn shape="round" icon="heart" label="Like, 5">5</Btn>`, none at 0 — not
735
+ `count`, the badge on the corner), no other words, the whole share the tap. In one frame: switches that stay on (`select="many"` +
736
+ `value` / `onChange`: the liked share filled), plain commands (no `value`: comments) and a move DONE ALREADY (`Btn aria-disabled`: the
737
+ share faded, `--off`; no give, no dim; `onClick` never called and the group's `value` never switched by a press; still focused and read —
738
+ `disabled` would take it out). A move done (passed on) STAYS in `value` and has `aria-disabled`: its share is the pressed fill, faded
739
+ (Lh 2026-11-18) — an app does it this way. The report flag at the post's head is the stock `flag` icon. The spoken name is each `label`
740
+ (say the number in it). The same row under a post in the feed and on the post's own page. Stories `BtnGroup · PostRow`, `PostRowControlled`.
741
+ - **A sheet's foot on a ground of its own** (`Foot layer`, Lh 2026-11-17, cardds#214). In a `Sheet` the foot's strip — the room the body stops above —
742
+ is the sheet's own colour, so the comments scrolling behind a `MessageBar` and the bar read as one. `<Foot layer>` gives that strip a ground of its own,
743
+ edge to edge, with a rule over it: the sheet's colour a little darker (`--foot-layer-bg`, default 8% of the dark ink over the sheet's own colour — opaque,
744
+ and darker on a dark sheet too) and `--foot-layer-rule-ink` (default `--hairline`) for the rule. The strip is not bigger: the foot, its
745
+ padding and the body's stop are the same, so nothing is covered. What stands on it keeps its look (a `MessageBar`'s box is still the paper). Off by
746
+ default, a sheet's foot is as before; on a `Card` the prop draws nothing (a card's own is `paper="bands"`). Story `Bubble · Comments`.
700
747
  - **Wrap buttons** (`Foot wrap`, `BtnRow wrap`, Lh 2026-10-28): each `Btn` as wide as its words, with its own side
701
748
  padding (never narrowed), from the start, wrapping to a new line when they do not fit. `end` stands them at the
702
749
  foot's (the row's) end: `<Foot wrap end><Btn>Reply</Btn><Btn>Open the chat</Btn></Foot>` (stories `Foot · Wrap`, `BtnRow · Wrap`).
@@ -781,6 +828,20 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
781
828
  `art` (0.7.165) swaps the drawn cat for the app's own picture (its Lottie
782
829
  player, an image): drawn centred `--feed-end-art-w` wide (default 30% of the feed's width), hidden from a screen reader;
783
830
  cardds plays nothing. Story `CardFeed · EndArt`.
831
+ - **A feed of thin cards** (`CardList thin`, Lh 2026-11-17, cardds#213 — "ก การ์ดบาง"). A `CardList` with `thin` makes EVERY `Card` in it
832
+ thinner, posts and plain cards alike: its padding `--sp-4`, its corner `--r-base`, the gap between its parts `--sp-5` (the cards stay
833
+ `--card-list-gap`, `--sp-3`, apart). It sets the card's rest values for the list's cards alone (`--card-pad-rest`, `--card-gap-rest`,
834
+ `--r-card`), so a card's variants and parts follow; a card outside the list and a `Thread` between its cards do not change. Knobs
835
+ `--card-list-thin-pad` · `--card-list-thin-gap` · `--card-list-thin-radius`. Story `FeedPost · Feed`.
836
+ - **`FeedPost`** (cardds#213): ONE post in a feed, a card of its own — `lead` (an `Avatar`, or a `Stamp bare` in an `AvatarStack`, at a led
837
+ `Head`'s size) · `author` (bold, the label's size) · `time` (` · 40 min` after it on the same line, small and muted) · `via` (the line
838
+ under them: who passed it on, who mentioned the member; none when it came straight) · `end` (the `Head`'s end: a round `Btn size="sm"`, the
839
+ report flag; the member's own post has none) · children (the words: a `Text expand` or `lines`, or a voice row) · `media` (a picture FULL
840
+ WIDTH, the media's corner, at its own shape up to the tallest the post allows — knob `--feed-post-media-ratio`, width / height, default
841
+ `4 / 3`; a taller one is cut in its middle; on a post's own sheet an app sets `4 / 5`) · `actions` (the moves, a `BtnGroup` frame, below).
842
+ The head's lines stand `--sp-1` apart, the post's parts `--sp-5` (knob `--feed-post-gap`). `onPress` + `pressLabel` press it whole
843
+ (`Card onPress`: its buttons keep their own press). It stands in a `CardList thin` with the feed's other cards, never in a card
844
+ (`card-in-card`). Stories `FeedPost · Feed`, `Words`, `Photo`, `TallPhoto`, `PassedOn`.
784
845
  - **A card pressed whole with controls inside** (timebank, 2026-10-29): `Card
785
846
  onPress` + `pressLabel`. A touch anywhere on the card off a control calls
786
847
  `onPress`; a link, a button, a `LinkBlock` or any control inside keeps its
@@ -801,7 +862,12 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
801
862
  ring. A folding card is never pressed whole. Not on a `row`, `sm`, `stack`
802
863
  or `paper="bands"` card, nor with `back` or `onPress` (it is ignored there,
803
864
  with a warning). The card draws its own chevron down as the head's last
804
- end (after the app's ends), turned up while open, as a `Banner`'s. Stories `Card · Folds`, `FoldsControlled`.
865
+ end (after the app's ends), turned up while open, as a `Banner`'s. In a
866
+ `Head variant="date"` the chevron stands at the head's top right, beside
867
+ the chips (the upper row when there are two, `chipsBelow`), and makes no row
868
+ under the title; an `end` the app gives that head keeps its own row there.
869
+ Stories `Card · Folds`, `FoldsControlled`, `FoldsDate`, `FoldsDateOpen`,
870
+ `FoldsDateTwoRows`, `FoldsDateTwoRowsOpen`.
805
871
  - A page with **one feature and one CTA** (an install page, a single
806
872
  decision) may be contained in one card: head, the pitch, foot.
807
873
  - **A bottom sheet holds what the member acts on** — controls, or small
@@ -946,7 +1012,17 @@ between at 40% down the screen (see *Anatomy*, "Where the centre is"):
946
1012
  read sits at the middle of the four fifths above it: **the human centre is
947
1013
  40% down the screen, not 50%** (`--screen-centre`, Lh 2026-09-10). A screen
948
1014
  with one card and nothing else to read puts it there (`.card--centre`, the
949
- introduction screens); a splash puts its mark there.
1015
+ introduction screens); a splash puts its mark there. **A box stands on that
1016
+ line by ITS OWN 40% point, not its middle** (Lh 2026-11-18: "find the centre of
1017
+ the screen at 40%, then the centre of the card at 40% too, put the two together"):
1018
+ the point 40% down the box lands on the point 40% down the screen, so the box's
1019
+ middle is a tenth of its height under the line and always over the screen's own middle. One token says it,
1020
+ `--centre-at` (0.4): `--screen-centre` is that share of the screen, `--centre-lift`
1021
+ the box's translate, and the same rule serves the four places that centre a box —
1022
+ `.card--centre`, `.screen__centre`, the splash's group and the `Modal` (never a
1023
+ `top: 50%` with `translate: -50%`). A growing box (the `Modal`'s drawer coming out) grows
1024
+ about its 40% point, which stays on the line. The cap is the room above the
1025
+ line / 0.4, or the room below it (the bar's reserve) / 0.6, whichever is less.
950
1026
 
951
1027
  Live: every screen in the gallery (`npm run dev`).
952
1028
 
@@ -1105,6 +1181,16 @@ stamps.
1105
1181
  Green (`--signal-ok`) unless `tone` names another signal; `--mark-bg` / `--mark-ink` retune it. It is information, never
1106
1182
  a control, and never a chip or a line of its own.
1107
1183
 
1184
+ **`Phrase`** keeps a few words on ONE line inside running text (cardds#224): the line breaks before it or after it, never inside it. Thai has no spaces between words, so a line is cut wherever it runs out: a `Chip` in the middle of a sentence and the word after it comes out split (`…ของเพื่อนบ้านทุก` / `คน`). Wrap the words that belong together: `<Text level="body">จะขึ้นในหน้า <Chip sm>ฮัลโหลๆ</Chip> <Phrase>ของเพื่อนบ้านทุกคน</Phrase></Text>`. It is inline and works in any `Text` level, in a `ModalAsk` `caption` and beside a `Chip`; a phrase longer than the room it has breaks inside itself, never out of its box. Keep it to a few words: a long sentence is not a phrase. Story `Modal · PhraseAfterChip`.
1185
+
1186
+ **`Thumb` and `ThumbGrid`** (cardds#232): a small square photo that is a button, and the grid it stands in. `<ThumbGrid><Thumb src={url} label="Photo 1, tap to remove" onClick={ask} />…</ThumbGrid>`: the squares
1187
+ show only the photo (`object-fit: cover`, corner `--r-control`, no words over or under it; without `src` a `Placeholder`'s crossed box), the whole square is the button with the app's `label` and `onClick`, it
1188
+ gives under the finger like a tile. The grid is five to a row (`--thumb-grid-cols`), as wide as the box it stands in, each square a fifth of that width less the gaps (`--thumb-grid-gap`, `--sp-2`): ten photos are two full rows,
1189
+ and in a `Modal` on a 375px phone each square is above `--tap-sm`. What a press does (ask before removing, open the photo) is the app's: a `Modal` of its own. Not `Mosaic` (a fixed arrangement of the photos in a card, not pressable) and not `Lead` (a box for an icon or a letter).
1190
+ Stories `Thumb · Default`, `ThreeInAModal`, `TenInAModal`.
1191
+
1192
+ **Photos on a post** (cardds#226): three pieces. `Mosaic` takes 2 to 10 photos: two stand side by side, equally tall; three are one big photo left and two small right; from four up it shows the first three the same way and darkens the small lower one with `+n`, n the photos not shown (the scrim twice, so the number holds 4.5:1 over any photo; knobs `--mosaic-more-bg`, `--mosaic-more-ink`, `--mosaic-more-font`; the children after the third are not drawn). The mosaic's one accessible name is its `label`. `CardMedia full` is the rounded full-width picture OUTSIDE a card, in a `Page` of a full screen: edge to edge of its holder, corner `--r-media`, the picture's own ratio, a taller picture cut at its middle past `--card-media-max-ratio` (height ÷ width, default `1.25`, 4:5). `Panes` is also the photo slide show of a full screen: in a `Page`, one `Pane` per photo (a `CardMedia full`), up to 10; the dots stand on one line at 375px. Opening a photo to zoom is not in cardds. Stories `Mosaic · Two` · `Three` · `Seven`, `CardMedia · FullInAPage`, `Panes · PhotoSlides`.
1193
+
1108
1194
  ## Postcards
1109
1195
 
1110
1196
  A postcard is the one piece of mail with no envelope: the written side is the card, and the corner (a stamp, the postmark
@@ -1306,6 +1392,33 @@ question and hunts for its answer. Rules 11–13 serve that:
1306
1392
  is a zero-specificity `:where()` list (the user-select list is a plain
1307
1393
  list of single selectors), so a component's own rule always wins.
1308
1394
 
1395
+ 16. **One layer over the screen: never a sheet in a sheet** (Lh 2026-11-24: "ตอนนี้เราเป็น sheet stack เปิด sheet
1396
+ แล้วไปการ์ด จากนั้นการ์ดเรากำลังจะกลับไป ชีท อีกทีนึง มันจะเป็นชีทในชีทแล้ว ภาษาดีไซน์คือมันกลายเป็นงานซ้อนกันข้างในเกินไป").
1397
+ A screen (a flooded stack sheet counts as the screen) takes at most ONE layer over it, and only for work the member
1398
+ writes or fills in. Before adding a layer, take the first of these that fits:
1399
+ - **More of what the member is looking at opens where it is.** A list of cards: `Card folds` (the head always
1400
+ shows; a tap opens the content and the foot in place). A queue the system hands over one card at a time:
1401
+ `CardFeed`. Never a sheet that repeats the card it was opened from.
1402
+ - **The moves on one thing are one button with a menu.** A small `Menu popover` that the button opens with
1403
+ `popoverTarget`, holding only the moves open at that moment; picking one closes it. The button says that it
1404
+ opens a menu: its words, then a `chevron-down` (`<Btn popoverTarget="…">มีปัญหา <Icon name="chevron-down"
1405
+ size="xs" /></Btn>`; Lh 2026-11-24: "ปุ่มมีปัญหาควรแสดงตัวด้วยว่าเป็นปุ่มประเภทที่กดแล้วจะมีเมนูอื่นๆ ให้เลือก").
1406
+ Never a sheet of options.
1407
+ - **Writing or filling in is the one task sheet.** `SheetStage over dim` holding one `Sheet` (`Head` · `Body` ·
1408
+ `Foot`), laid over the home as the ask sheet is (`Home/AskSheet`). Nothing in it opens a second sheet; a question
1409
+ it has to ask is a `Modal` with a `ModalAsk`.
1410
+ - **One thing keeps one card in every state.** The same parts in the same places and the same size from its first
1411
+ state to its last (Lh 2026-11-24: "การ์ดไม่ควรเปลี่ยนขนาดหรือเปลี่ยนรายละเอียด ทำให้การ์ด consistent"). A state
1412
+ changes only the signal chip, the status line under the title (the head's `meta`; Lh 2026-11-24: "ใต้ชื่อคำขอ"),
1413
+ the line that says where the thing's value stands, and the words of the primary button. The foot keeps one shape
1414
+ in every state that has moves: the menu button left, the one primary right.
1415
+
1416
+ The check (Lh 2026-11-24): draw the main screen once with everything open: every part of the card, one card open,
1417
+ its deepest menu shown open. "ถ้าหน้านั้นดูรู้เรื่อง และ UI ไม่เละถือว่าเป็นดีไซน์ที่ใช้ได้". A structure that only reads
1418
+ when it is shown screen by screen does not hold. The tool for this check is `audit_screen` (`npx cardds audit`): given
1419
+ a picture it asks this rule's questions, given the rendered DOM of a page or the pages of a flow it names what breaks
1420
+ this rule on the screen.
1421
+
1309
1422
  ## A project's theme
1310
1423
 
1311
1424
  A project retunes cardds from ONE file of its own, and nothing else. Copy
package/icons.svg CHANGED
@@ -60,6 +60,7 @@
60
60
  <symbol id="lightbulb" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1.3.5 2.6 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></symbol>
61
61
  <symbol id="music" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></symbol>
62
62
  <symbol id="file-text" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></symbol>
63
+ <symbol id="flag" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" x2="4" y1="22" y2="15"/></symbol>
63
64
  <symbol id="hourglass" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 22h14"/><path d="M5 2h14"/><path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22"/><path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2"/></symbol>
64
65
  <symbol id="thermometer" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z"/></symbol>
65
66
  <symbol id="droplet" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"/></symbol>
package/lib/audit.mjs ADDED
@@ -0,0 +1,330 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
6
+ const REFERENCE_FILE = join(PACKAGE_ROOT, 'docs', 'reference.md');
7
+ const ICON_SPRITE_FILE = join(PACKAGE_ROOT, 'icons.svg');
8
+ const RULES_HEADING = '## Rules of the system';
9
+ const LAYER_RULE = 16;
10
+ const MENU_ICON = 'chevron-down';
11
+ const CLASSES_SHOWN_MAX = 3;
12
+ const WORDS_SHOWN_MAX = 40;
13
+ const WORDS_SEARCHED_MAX = WORDS_SHOWN_MAX * 4;
14
+
15
+ const VOID_TAGS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
16
+ const TEXT_TAGS = new Set(['script', 'style']);
17
+ const NAMED_CHARACTERS = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
18
+
19
+ const COMMENT_OPEN = '<!--';
20
+ const COMMENT_CLOSE = '-->';
21
+ const CDATA_OPEN = '<![CDATA[';
22
+ const CDATA_CLOSE = ']]>';
23
+ const TAG = /<[!?][^<>]*>|<\/([a-zA-Z][^\s>/<]*)[^<>]*>|<([a-zA-Z][^\s>/<]*)((?:"[^"]*"|'[^']*'|[^'"<>])*?)(\/?)>/y;
24
+ const ATTRIBUTE = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
25
+
26
+ const decodeEntities = (text) => text.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (whole, name) => {
27
+ if (name[0] !== '#') return NAMED_CHARACTERS[name.toLowerCase()] ?? whole;
28
+ const code = name[1].toLowerCase() === 'x' ? parseInt(name.slice(2), 16) : Number(name.slice(1));
29
+ return code <= 0x10ffff ? String.fromCodePoint(code) : whole;
30
+ });
31
+
32
+ const attributesOf = (source) => Object.fromEntries(
33
+ [...source.matchAll(ATTRIBUTE)].map(([, name, double, single, bare]) => [name.toLowerCase(), decodeEntities(double ?? single ?? bare ?? '')]),
34
+ );
35
+
36
+ const endOfText = (html, tag, from) => {
37
+ const closing = new RegExp(`</${tag}`, 'gi');
38
+ closing.lastIndex = from;
39
+ return closing.exec(html)?.index ?? html.length;
40
+ };
41
+
42
+ const endOfMarkup = (html, closing, from) => {
43
+ const at = html.indexOf(closing, from);
44
+ return at < 0 ? html.length : at + closing.length;
45
+ };
46
+
47
+ export function parse(html) {
48
+ const root = { tag: '#document', attrs: {}, children: [], parent: null };
49
+ const openCounts = new Map();
50
+ const tag = new RegExp(TAG);
51
+ let current = root;
52
+ let consumed = 0;
53
+ let at = 0;
54
+ const addText = (to) => {
55
+ const raw = html.slice(consumed, to);
56
+ if (raw) current.children.push({ text: decodeEntities(raw), parent: current });
57
+ };
58
+ const closeTag = (name) => {
59
+ if (!openCounts.get(name)) return;
60
+ for (let node = current; node.parent; node = node.parent) {
61
+ openCounts.set(node.tag, openCounts.get(node.tag) - 1);
62
+ if (node.tag === name) {
63
+ current = node.parent;
64
+ return;
65
+ }
66
+ }
67
+ };
68
+ const skip = (to, from) => {
69
+ addText(from);
70
+ consumed = at = to;
71
+ };
72
+ while (at < html.length) {
73
+ const start = html.indexOf('<', at);
74
+ if (start < 0) break;
75
+ if (html.startsWith(COMMENT_OPEN, start)) {
76
+ skip(endOfMarkup(html, COMMENT_CLOSE, start + COMMENT_OPEN.length), start);
77
+ continue;
78
+ }
79
+ if (html.startsWith(CDATA_OPEN, start)) {
80
+ skip(endOfMarkup(html, CDATA_CLOSE, start + CDATA_OPEN.length), start);
81
+ continue;
82
+ }
83
+ tag.lastIndex = start;
84
+ const token = tag.exec(html);
85
+ if (!token) {
86
+ at = start + 1;
87
+ continue;
88
+ }
89
+ const [whole, closing, opening, attributes, selfClosed] = token;
90
+ skip(start + whole.length, start);
91
+ if (closing) closeTag(closing.toLowerCase());
92
+ if (!opening) continue;
93
+ const name = opening.toLowerCase();
94
+ const element = { tag: name, attrs: attributesOf(attributes), children: [], parent: current };
95
+ current.children.push(element);
96
+ if (TEXT_TAGS.has(name)) consumed = at = endOfText(html, name, at);
97
+ else if (!selfClosed && !VOID_TAGS.has(name)) {
98
+ openCounts.set(name, (openCounts.get(name) ?? 0) + 1);
99
+ current = element;
100
+ }
101
+ }
102
+ addText(html.length);
103
+ return root;
104
+ }
105
+
106
+ const isElement = (node) => node.tag !== undefined;
107
+ const classesOf = (node) => (node.attrs.class ?? '').split(/\s+/).filter(Boolean);
108
+ const hasClass = (node, name) => classesOf(node).includes(name);
109
+ const hasAttribute = (node, name) => Object.hasOwn(node.attrs, name);
110
+
111
+ const pushReversed = (pending, children) => {
112
+ for (let index = children.length - 1; index >= 0; index--) pending.push(children[index]);
113
+ };
114
+
115
+ function* descendants(node, isClosed = () => false) {
116
+ const pending = [];
117
+ pushReversed(pending, node.children);
118
+ while (pending.length) {
119
+ const child = pending.pop();
120
+ if (!isElement(child)) continue;
121
+ yield child;
122
+ if (!isClosed(child)) pushReversed(pending, child.children);
123
+ }
124
+ }
125
+
126
+ const wordsIn = (node, limit = Infinity) => {
127
+ const texts = [];
128
+ const pending = [];
129
+ let length = 0;
130
+ pushReversed(pending, node.children);
131
+ while (pending.length && length < limit) {
132
+ const child = pending.pop();
133
+ if (isElement(child)) pushReversed(pending, child.children);
134
+ else {
135
+ texts.push(child.text);
136
+ length += child.text.length;
137
+ }
138
+ }
139
+ return texts.join('').replace(/\s+/g, ' ').trim();
140
+ };
141
+
142
+ const clipped = (words) => (words.length > WORDS_SHOWN_MAX ? `${words.slice(0, WORDS_SHOWN_MAX - 1)}…` : words);
143
+
144
+ const isCard = (node) => hasClass(node, 'card');
145
+ const isSheet = (node) => isCard(node) && hasClass(node, 'sheet');
146
+ const isModal = (node) => isCard(node) && hasClass(node, 'modal');
147
+ const isLayer = (node) => isSheet(node) || isModal(node);
148
+ const isGone = (node) => hasClass(node, 'sheet--away') || hasAttribute(node, 'inert') || hasAttribute(node, 'hidden');
149
+ const isOpenLayer = (node) => isLayer(node) && !isGone(node);
150
+ const isButton = (node) => node.tag === 'button' || (node.tag === 'a' && (hasClass(node, 'btn') || hasClass(node, 'icon-btn')));
151
+
152
+ const headOf = (card) => [...descendants(card, isCard)].find((node) => hasClass(node, 'head'));
153
+
154
+ const titleOf = (card) => {
155
+ const head = headOf(card);
156
+ if (!head) return '';
157
+ const title = [...descendants(head)].find((node) => hasClass(node, 'words__title'));
158
+ return wordsIn(title ?? head);
159
+ };
160
+
161
+ const describe = (node) => {
162
+ const id = hasAttribute(node, 'id') ? `#${node.attrs.id}` : '';
163
+ const classes = classesOf(node).slice(0, CLASSES_SHOWN_MAX).map((name) => `.${name}`).join('');
164
+ const words = (isCard(node) && titleOf(node)) || clipped(wordsIn(node, WORDS_SEARCHED_MAX));
165
+ return `${node.tag}${id}${classes}${words ? ` "${words}"` : ''}`;
166
+ };
167
+
168
+ const found = (node, says) => ({ rule: LAYER_RULE, where: describe(node), says });
169
+ const onPage = (item, page) => ({ rule: item.rule, page, where: item.where, says: item.says });
170
+
171
+ const drawingOf = (svg) => svg.children.filter(isElement).map((part) => `${part.tag}${JSON.stringify(Object.entries(part.attrs).sort())}`).join('');
172
+
173
+ const iconDrawing = (name) => {
174
+ const sprite = parse(readFileSync(ICON_SPRITE_FILE, 'utf8'));
175
+ const symbol = [...descendants(sprite)].find((node) => node.tag === 'symbol' && node.attrs.id === name);
176
+ return symbol ? drawingOf(symbol) : null;
177
+ };
178
+
179
+ const LAYER_KINDS = [
180
+ { name: 'sheet', is: isSheet },
181
+ { name: 'modal', is: isModal },
182
+ ];
183
+
184
+ const layersOverScreen = (root) => {
185
+ const open = [...descendants(root)].filter(isOpenLayer);
186
+ return LAYER_KINDS.flatMap(({ name, is }) => {
187
+ const sameKind = open.filter(is);
188
+ return sameKind.slice(1).map((layer, index) => found(layer, `${name} ${index + 2} of ${sameKind.length} is open over the screen at the same time: a screen takes at most one layer`));
189
+ });
190
+ };
191
+
192
+ const isIcon = (svg, name, drawing) => (hasAttribute(svg, 'data-icon') ? svg.attrs['data-icon'] === name : drawingOf(svg) === drawing);
193
+
194
+ const menuButtonsWithoutChevron = (root) => {
195
+ const everything = [...descendants(root)];
196
+ const menuIds = new Set(everything.filter((node) => hasClass(node, 'menu') && hasAttribute(node, 'id')).map((node) => node.attrs.id));
197
+ const chevron = iconDrawing(MENU_ICON);
198
+ const showsChevron = (button) => [...descendants(button)].some((node) => node.tag === 'svg' && isIcon(node, MENU_ICON, chevron));
199
+ return everything
200
+ .filter((node) => menuIds.has(node.attrs.popovertarget) && !showsChevron(node))
201
+ .map((button) => found(button, `opens a Menu but has no ${MENU_ICON} icon: the button says it opens a menu, its words then <Icon name="${MENU_ICON}" size="xs" />`));
202
+ };
203
+
204
+ const sheetCardsRepeatingScreen = (root) => {
205
+ const everything = [...descendants(root)];
206
+ const onScreen = [...descendants(root, isLayer)].filter((node) => isCard(node) && !isLayer(node));
207
+ const screenTitles = new Set(onScreen.map(titleOf).filter(Boolean));
208
+ const openSheets = everything.filter((node) => isSheet(node) && !isGone(node));
209
+ const sheetCards = new Set(openSheets.flatMap((sheet) => [sheet, ...[...descendants(sheet, isSheet)].filter((node) => isCard(node) && !isModal(node))]));
210
+ return [...sheetCards]
211
+ .filter((card) => screenTitles.has(titleOf(card)))
212
+ .map((card) => found(card, `repeats the card "${titleOf(card)}" on the screen under the sheet: more of what the member is looking at opens where it is (Card folds), a sheet is for what they write or fill in`));
213
+ };
214
+
215
+ const auditPage = (root) => [...layersOverScreen(root), ...menuButtonsWithoutChevron(root), ...sheetCardsRepeatingScreen(root)];
216
+
217
+ const partsOf = (card) => {
218
+ const inside = [...descendants(card, (node) => isCard(node) || hasClass(node, 'menu'))];
219
+ const foot = inside.find((node) => hasClass(node, 'foot'));
220
+ const buttons = foot ? [...descendants(foot, (node) => hasClass(node, 'menu'))].filter(isButton).length : 0;
221
+ return [
222
+ 'head',
223
+ inside.some((node) => hasClass(node, 'note-row')) && 'NoteRow',
224
+ inside.some((node) => hasClass(node, 'rows')) && 'Rows',
225
+ foot && `foot with ${buttons} ${buttons === 1 ? 'button' : 'buttons'}`,
226
+ ].filter(Boolean).join(' · ');
227
+ };
228
+
229
+ const firstCardOfEachTitle = (root) => {
230
+ const cards = new Map();
231
+ for (const node of descendants(root)) {
232
+ const title = isCard(node) ? titleOf(node) : '';
233
+ if (title && !cards.has(title)) cards.set(title, node);
234
+ }
235
+ return cards;
236
+ };
237
+
238
+ const partsChangingAcrossPages = (pages) => {
239
+ const firstSeen = new Map();
240
+ return pages.flatMap(({ name, root }) => [...firstCardOfEachTitle(root)].flatMap(([title, card]) => {
241
+ const parts = partsOf(card);
242
+ const before = firstSeen.get(title);
243
+ if (!before) {
244
+ firstSeen.set(title, { page: name, parts });
245
+ return [];
246
+ }
247
+ if (before.parts === parts) return [];
248
+ return [onPage(found(card, `"${title}" has ${parts} here but ${before.parts} on ${before.page}: one thing keeps the same parts on every page`), name)];
249
+ }));
250
+ };
251
+
252
+ const pageName = (page, index) => (typeof page.name === 'string' && page.name ? page.name : `page ${index + 1}`);
253
+
254
+ export const screen = (html) => auditPage(parse(html));
255
+
256
+ export function flow(pages) {
257
+ const parsed = pages.map((page, index) => ({ name: pageName(page, index), root: parse(page.html) }));
258
+ return [
259
+ ...parsed.flatMap(({ name, root }) => auditPage(root).map((item) => onPage(item, name))),
260
+ ...partsChangingAcrossPages(parsed),
261
+ ];
262
+ }
263
+
264
+ const withoutMarks = (text) => text.replace(/\*\*/g, '').replace(/\s+/g, ' ').trim();
265
+
266
+ const rulesIn = (markdown) => {
267
+ const lines = markdown.split('\n');
268
+ const start = lines.findIndex((line) => line.startsWith(RULES_HEADING));
269
+ if (start < 0) return [];
270
+ const length = lines.slice(start + 1).findIndex((line) => line.startsWith('## '));
271
+ const section = lines.slice(start + 1, length < 0 ? undefined : start + 1 + length);
272
+ const rules = [];
273
+ let current = null;
274
+ for (const line of section) {
275
+ const heading = /^(\d+)\.\s+\*\*(.+?)\*\*\s?(.*)$/.exec(line);
276
+ if (heading) {
277
+ current = { number: Number(heading[1]), name: heading[2].replace(/\.$/, ''), lines: [heading[3]] };
278
+ rules.push(current);
279
+ } else if (current && (line.trim() === '' || /^\s/.test(line))) current.lines.push(line);
280
+ else current = null;
281
+ }
282
+ return rules;
283
+ };
284
+
285
+ const blocksIn = (lines) => {
286
+ const blocks = [];
287
+ let open = null;
288
+ let fenced = false;
289
+ for (const line of lines) {
290
+ if (/^\s*```/.test(line)) {
291
+ fenced = !fenced;
292
+ open = null;
293
+ } else if (fenced) continue;
294
+ else if (line.trim() === '') open = null;
295
+ else if (/^\s*[-*]\s+/.test(line)) {
296
+ open = { bullet: true, text: line.replace(/^\s*[-*]\s+/, '') };
297
+ blocks.push(open);
298
+ } else if (open) open.text += ` ${line.trim()}`;
299
+ else {
300
+ open = { bullet: false, text: line.trim() };
301
+ blocks.push(open);
302
+ }
303
+ }
304
+ return blocks;
305
+ };
306
+
307
+ const questionFor = (block, index) => {
308
+ const text = withoutMarks(block.text);
309
+ const labelled = block.bullet ? /^\*\*(.+?)\*\*\s*(.*)$/.exec(block.text) : null;
310
+ if (labelled) return `${labelled[1].replace(/\.$/, '')}: does the picture do this? ${withoutMarks(labelled[2])}`;
311
+ if (block.bullet) return `Does the picture do this? ${text}`;
312
+ if (/^The check\b/.test(text)) return `How to check: ${text.replace(/^The check\s*/, '')}`;
313
+ return index === 0 ? `Does the picture keep this? ${text}` : `Does the picture keep this too? ${text}`;
314
+ };
315
+
316
+ export const questions = (markdown = readFileSync(REFERENCE_FILE, 'utf8')) => rulesIn(markdown).map((rule) => ({
317
+ rule: rule.number,
318
+ name: rule.name,
319
+ questions: blocksIn(rule.lines).map(questionFor),
320
+ }));
321
+
322
+ export function audit({ html, pages } = {}) {
323
+ if (html !== undefined && pages !== undefined) return { error: 'give html (one page) or pages (a flow), not both' };
324
+ if (pages !== undefined) {
325
+ const listed = Array.isArray(pages) && pages.every((page) => typeof page?.html === 'string');
326
+ return listed ? flow(pages) : { error: 'pages is an array of { name, html }, each html a string' };
327
+ }
328
+ if (html === undefined) return questions();
329
+ return typeof html === 'string' ? screen(html) : { error: 'html is a string: the rendered DOM of one page' };
330
+ }
package/lib/guide.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  // not here — they are in its JSDoc (get_component) and in lint/rules.mjs.
5
5
  export const GUIDE = `cardds — BEFORE drawing any phone-width / mobile screen in a project with @usableapp/cardds, or that Lh asks to build "with cardds": load these tools (ToolSearch "cardds" if deferred) and call find_components. Even when the request only says prototype, poc, mock-up, sketch, "show me a design", หน้า, หน้าจอ, ขึ้นหน้า, ขอดู prototype — a screen, card, bottom sheet, sheet stack, form step, sticky note / post-it, chat of notes, stamp, postcard, home. Never hand-write HTML, CSS or emoji for what it has.
6
6
  ORDER: find → scaffold or get → write. First question: has cardds drawn this screen already? find BOTH ways: by the axes (represents · shape · interact) and by the task's English noun ("sticky", "stamp", "chat").
7
- TOOLS: find_components · scaffold_screen · get_component · list_components. No MCP: npx cardds find|scaffold|get|list --json. check / check_source: a person's tool, never a session's step.
7
+ TOOLS: find_components · scaffold_screen · get_component · list_components. No MCP: npx cardds find|scaffold|get|list --json. check / check_source: a person's tool, never a session's step. audit_screen (npx cardds audit): a screen drawn, as a picture or as the rendered DOM of a page or a flow, against the rules of the system.
8
8
  What no checker sees:
9
9
  1. cardds is a framework you take from outside. Never edit or release cardds, or node_modules, from a consumer project. What cannot be set from outside is a framework gap: STOP, tell the user what you needed.
10
10
  2. Adjust from outside only, widest first: theme.css bases → knobs (--<component>-<what>) → props/slots. Theme values are the user's call, never yours. cardGrounds() / inkGrounds() name a card or a word the member cannot see (docs/reference.md).
package/lib/mcp.mjs CHANGED
@@ -6,6 +6,7 @@ import { dirname, join } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import * as catalog from './catalog.mjs';
8
8
  import { GUIDE } from './guide.mjs';
9
+ import { audit } from './audit.mjs';
9
10
 
10
11
  const { version } = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8'));
11
12
  /* A server lives as long as its session — hours, across releases. What it serves must be the catalog as it is NOW (Lh 2026-10-10: a
@@ -75,6 +76,18 @@ const TOOLS = [
75
76
  inputSchema: { type: 'object', properties: { code: str('the .tsx/.jsx source'), filename: str('its file name, for the report (default screen.tsx)') }, required: ['code'] },
76
77
  run: (_cat, a) => catalog.check(a.code, a.filename),
77
78
  },
79
+ {
80
+ name: 'audit_screen',
81
+ description: 'Audit a screen the way the member sees it, against the rules of cardds (docs/reference.md, "Rules of the system"). Three ways. A PICTURE: you are looking at an image of a screen — call it with nothing, and it returns one set of questions per rule ({ rule, name, questions }); put each set to the picture and answer rule by rule. ONE PAGE already built: pass html, the rendered DOM of that page (what the browser shows, document.body.outerHTML — not the source code) and it returns what the DOM shows against rule 16 (more than one layer open over the screen, a button that opens a Menu with no chevron-down icon, a card in an open sheet that repeats a card of the screen under it). A FLOW: pass pages, [{ name, html }] in the order the member walks them, and it returns each page\'s items and what is wrong across pages (the same card with other parts on another page: head · NoteRow · Rows · foot and its buttons). Every item is { rule, page?, where, says }: where is the selector and the words seen on the screen, says is the fault in one line. [] means nothing found; a document that is not cardds gives []. It reads no image and opens no browser.',
82
+ inputSchema: {
83
+ type: 'object',
84
+ properties: {
85
+ html: str('the rendered DOM of ONE page, as a string; omit it, and pages, to get the questions for a picture'),
86
+ pages: { type: 'array', items: { type: 'object', properties: { name: str('the page\'s name, in the report'), html: str('the rendered DOM of this page') }, required: ['html'] }, description: 'a flow: the pages in the order the member walks them' },
87
+ },
88
+ },
89
+ run: (_cat, a) => audit(a),
90
+ },
78
91
  ];
79
92
 
80
93
  const reply = (id, result) => ({ jsonrpc: '2.0', id, result });