@k2b/ui 0.65.0 → 0.66.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.
Files changed (106) hide show
  1. package/README.md +47 -0
  2. package/dist/browser/v2/button.js +180 -0
  3. package/dist/browser/v2/button.js.map +1 -0
  4. package/dist/browser/v2/components.js +763 -0
  5. package/dist/browser/v2/components.js.map +1 -0
  6. package/dist/browser/v2/content.js +1107 -0
  7. package/dist/browser/v2/content.js.map +1 -0
  8. package/dist/browser/v2/controls.js +568 -0
  9. package/dist/browser/v2/controls.js.map +1 -0
  10. package/dist/browser/v2/describe.js +397 -0
  11. package/dist/browser/v2/describe.js.map +1 -0
  12. package/dist/browser/v2/index.js +25 -0
  13. package/dist/browser/v2/index.js.map +1 -0
  14. package/dist/browser/v2/layout.js +578 -0
  15. package/dist/browser/v2/layout.js.map +1 -0
  16. package/dist/browser/v2/link.js +9 -0
  17. package/dist/browser/v2/link.js.map +1 -0
  18. package/dist/browser/v2/marks.js +211 -0
  19. package/dist/browser/v2/marks.js.map +1 -0
  20. package/dist/browser/v2/states.js +180 -0
  21. package/dist/browser/v2/states.js.map +1 -0
  22. package/dist/browser/v2/structure.js +328 -0
  23. package/dist/browser/v2/structure.js.map +1 -0
  24. package/dist/browser/v2/testing/index.js +23 -0
  25. package/dist/browser/v2/testing/index.js.map +1 -0
  26. package/dist/browser/v2/testing/measure-v2-layout.js +762 -0
  27. package/dist/browser/v2/testing/measure-v2-layout.js.map +1 -0
  28. package/dist/browser/v2/testing/settled.js +52 -0
  29. package/dist/browser/v2/testing/settled.js.map +1 -0
  30. package/dist/browser/v2/tokens.js +83 -0
  31. package/dist/browser/v2/tokens.js.map +1 -0
  32. package/dist/browser/v2/types.js +24 -0
  33. package/dist/browser/v2/types.js.map +1 -0
  34. package/dist/ssr/v2/button.js +177 -0
  35. package/dist/ssr/v2/button.js.map +1 -0
  36. package/dist/ssr/v2/components.js +518 -0
  37. package/dist/ssr/v2/components.js.map +1 -0
  38. package/dist/ssr/v2/content.js +727 -0
  39. package/dist/ssr/v2/content.js.map +1 -0
  40. package/dist/ssr/v2/controls.js +268 -0
  41. package/dist/ssr/v2/controls.js.map +1 -0
  42. package/dist/ssr/v2/describe.js +397 -0
  43. package/dist/ssr/v2/describe.js.map +1 -0
  44. package/dist/ssr/v2/index.js +25 -0
  45. package/dist/ssr/v2/index.js.map +1 -0
  46. package/dist/ssr/v2/layout.js +377 -0
  47. package/dist/ssr/v2/layout.js.map +1 -0
  48. package/dist/ssr/v2/link.js +9 -0
  49. package/dist/ssr/v2/link.js.map +1 -0
  50. package/dist/ssr/v2/marks.js +126 -0
  51. package/dist/ssr/v2/marks.js.map +1 -0
  52. package/dist/ssr/v2/states.js +128 -0
  53. package/dist/ssr/v2/states.js.map +1 -0
  54. package/dist/ssr/v2/structure.js +229 -0
  55. package/dist/ssr/v2/structure.js.map +1 -0
  56. package/dist/ssr/v2/testing/index.js +23 -0
  57. package/dist/ssr/v2/testing/index.js.map +1 -0
  58. package/dist/ssr/v2/testing/measure-v2-layout.js +762 -0
  59. package/dist/ssr/v2/testing/measure-v2-layout.js.map +1 -0
  60. package/dist/ssr/v2/testing/settled.js +52 -0
  61. package/dist/ssr/v2/testing/settled.js.map +1 -0
  62. package/dist/ssr/v2/tokens.js +83 -0
  63. package/dist/ssr/v2/tokens.js.map +1 -0
  64. package/dist/ssr/v2/types.js +24 -0
  65. package/dist/ssr/v2/types.js.map +1 -0
  66. package/dist/types/v2/button.d.ts +54 -0
  67. package/dist/types/v2/components.d.ts +173 -0
  68. package/dist/types/v2/content.d.ts +233 -0
  69. package/dist/types/v2/controls.d.ts +118 -0
  70. package/dist/types/v2/describe.d.ts +18 -0
  71. package/dist/types/v2/index.d.ts +22 -0
  72. package/dist/types/v2/layout.d.ts +124 -0
  73. package/dist/types/v2/link.d.ts +7 -0
  74. package/dist/types/v2/marks.d.ts +90 -0
  75. package/dist/types/v2/states.d.ts +45 -0
  76. package/dist/types/v2/structure.d.ts +47 -0
  77. package/dist/types/v2/testing/index.d.ts +16 -0
  78. package/dist/types/v2/testing/measure-v2-layout.d.ts +99 -0
  79. package/dist/types/v2/testing/settled.d.ts +13 -0
  80. package/dist/types/v2/tokens.d.ts +77 -0
  81. package/dist/types/v2/types.d.ts +44 -0
  82. package/dist/v2.css +3072 -0
  83. package/package.json +23 -4
  84. package/skills/k2b-ui/SKILL.md +201 -0
  85. package/skills/k2b-ui/images/form-1440.png +0 -0
  86. package/skills/k2b-ui/images/form-390.png +0 -0
  87. package/skills/k2b-ui/images/list-detail-1440.png +0 -0
  88. package/skills/k2b-ui/images/list-detail-390.png +0 -0
  89. package/skills/k2b-ui/images/mail-1440.png +0 -0
  90. package/skills/k2b-ui/images/mail-390.png +0 -0
  91. package/skills/k2b-ui/images/record-1440.png +0 -0
  92. package/skills/k2b-ui/images/record-390.png +0 -0
  93. package/skills/k2b-ui/images/record-groups-1440.png +0 -0
  94. package/skills/k2b-ui/images/record-groups-390.png +0 -0
  95. package/skills/k2b-ui/images/table-1440.png +0 -0
  96. package/skills/k2b-ui/images/table-390.png +0 -0
  97. package/skills/k2b-ui/recipes/form.tsx +54 -0
  98. package/skills/k2b-ui/recipes/list-detail.tsx +105 -0
  99. package/skills/k2b-ui/recipes/mail.tsx +193 -0
  100. package/skills/k2b-ui/recipes/record-groups.tsx +115 -0
  101. package/skills/k2b-ui/recipes/record.tsx +163 -0
  102. package/skills/k2b-ui/recipes/table.tsx +68 -0
  103. package/skills/k2b-ui/references/mistakes.md +162 -0
  104. package/skills/k2b-ui/references/primitives.md +310 -0
  105. package/skills/k2b-ui/references/recipes.md +101 -0
  106. package/skills/k2b-ui/references/seeing.md +94 -0
@@ -0,0 +1,310 @@
1
+ # Primitives and components of @k2b/ui/v2
2
+
3
+ Every part marks its root with `data-k2-part="<Name>"`; that name is what
4
+ `describeV2` prints. No part takes `class`, `style`, `size`, `gap`,
5
+ `padding` or `density`. Shared types: `Action = { label, icon?, href?,
6
+ onNavigate?, onClick?, meta?, forward? }`, `Width = { min, default }` (px), `Status =
7
+ "ok" | "warn" | "bad"`, `Person = { name, initials?, color? }`. Icons are
8
+ Tabler names without `ti-` (`plus`, `package`).
9
+
10
+ **Links that open in place.** Every `href` stays a real `<a href>`: it works
11
+ before the page is live and opens in a new tab with a modifier key. Beside
12
+ it, `onNavigate` (type `OnNavigate`, the `LinkNavigateEvent` of
13
+ `@k2b/ssr/nav`) opens the page in place on a plain click or Enter; the
14
+ handler moves history with `push` or `replaceWith`, or loads the page with
15
+ `fallback`. It exists on `Row`, `Tabs` and `Nav` items, `Action` (so on
16
+ `Workspace primary` and every action as data), `Button`, `Chip` and the
17
+ `open` target of a `Table`. Never use `onClick` for what has an address.
18
+
19
+ ## Frame
20
+
21
+ ### Workspace
22
+
23
+ The working surface of an app: one per screen.
24
+
25
+ - `sidebar` (usually `Nav`), `sidebarWidth` (default 200–248), `sidebarLabel`
26
+ (name of its grip).
27
+ - `head`: a `Bar` across the main column (56 px).
28
+ - `primary`: the main `Action`. It floats bottom right on the phone only;
29
+ also put the same action as `Button variant="primary"` in the head end.
30
+ - children: a `Pane` or a `Pane.Split`.
31
+ - Phone (< 768 px): the sidebar leaves, head actions hide unless `keep`.
32
+
33
+ ### Pane
34
+
35
+ A column that scrolls, with no padding: everything in it reaches both edges.
36
+
37
+ - `head` (a `Bar` or `Tabs`), `status` (a `StatusRow`), `label`.
38
+ - `width={{ min, default }}`: only inside `Pane.Split`; puts a grip on its
39
+ line.
40
+ - `detail`: the reader beside a list. What is open belongs in the address:
41
+ render the detail only while the address names an entry. On the phone
42
+ the detail is the page.
43
+ - `back` (an `Action` with `href`: the list's address without the open
44
+ entry, such as "Posteingang"): the way back on the phone, one bar above
45
+ the detail (the part `Back`). A long name (a search) is cut with "…" on
46
+ one line; the whole name stays its accessible name and its hint. A detail
47
+ that closes in place returns the focus to the row that opened it.
48
+ - `scrollKey` (such as "mail-list"): back and forward bring the column
49
+ back to where it was scrolled.
50
+ - `side`: the info column of a record; quieter sections, a `more` link
51
+ becomes a row.
52
+ - children: bands, sections, groups, lists, tables, notices, `Text`.
53
+
54
+ ### Pane.Split
55
+
56
+ Panes side by side (list | reader, main | side). One hairline between, a
57
+ grip where a pane has `width`. A `Pane.Split` may stand inside a `Pane`
58
+ under that pane's `Tabs` head, after content that spans both columns (see
59
+ `record.tsx`).
60
+
61
+ Until v2 has a `Dialog`, a screen "with the dialog open" shows the dialog's
62
+ form as one more `Pane detail` at the end of the split: a head `Bar` with
63
+ its title and a close button, `Band`s of fields, a footer `Bar`. Mark it
64
+ with a `k2b-ui gap` comment. `detail` makes it leave on the phone, where the
65
+ form is its own route. Its confirm button is a default (framed) button: the
66
+ page's one primary stays in the head, and `Workspace primary` must never
67
+ confirm a dialog. When the list beside it is a table, give the dialog pane
68
+ a `width` so the table keeps its columns.
69
+
70
+ ### Bar
71
+
72
+ A bar of fixed height with one line below: `start`, `end`. Height comes
73
+ from the place: 56 as a head, 52 as a status row, 40 inside a pane. Put
74
+ `Text`, `Tabs`, `RecordHead`, `Inline`, `Button`s, `Avatar` in it. Text in
75
+ a bar is cut to one line. Inside a pane a bar stands at the top (a line of
76
+ state under the head, as in `mail.tsx`) or directly after the fields it
77
+ serves (the buttons of a form or of a reply), never between entries. In a
78
+ column narrower than 480 px, a bar inside a pane whose `start` is an
79
+ `Inline` wraps: its things and its `end` flow as one line, one line stays
80
+ 40 px, and only a second line makes the bar higher. A head and a status row
81
+ keep their height.
82
+
83
+ ### Band
84
+
85
+ A block of free height with one line below. `tone`: `note`, `ai`, `yours`,
86
+ `bad`, `warn` (meaning only). Holds `Text`, `Row`, `Prose`, `Tiles`,
87
+ fields. A message in a thread is one `Band`.
88
+
89
+ ### Cells and Cells.Cell
90
+
91
+ 2–4 equal cells with a line between; stacked on the phone. A cell:
92
+ `icon`, `color` (data colour of its area), `label`, `value`, `meta`,
93
+ `href` (adds a chevron). Use for the key statements of a record.
94
+
95
+ ### Tiles
96
+
97
+ Like things to press, such as attachments: `items: { icon, title, meta?,
98
+ href? }[]`, `more` (an action after them), `label`. Never nested.
99
+
100
+ ### Canvas
101
+
102
+ The only place for own drawing and own CSS (a map, a chart). `label`
103
+ (required), `height` in px. It must stand directly in a primitive
104
+ (`<Band><Canvas …/></Band>` or directly in a `Pane`), never as a
105
+ component's root and never in a plain element.
106
+
107
+ ## Structure
108
+
109
+ ### Section
110
+
111
+ A titled part: `icon`, `color` (icon on a tinted tile), `title`, `count`,
112
+ `actions` (≤ 2 text buttons in the head), `summary` (one sentence),
113
+ `more` (one link at the end: "All deliveries ›"; its `meta` shows only in a
114
+ `Pane side`, where the link becomes a row), children. No line under
115
+ the head or between entries, one line at the end. Put `Row`s directly in a
116
+ section, or a `Digest`, `Facts`, `Group`s.
117
+
118
+ ### Group
119
+
120
+ What belongs together, framed: `icon`, `color`, `title`, `count`, `meta`
121
+ (head grows to 56), `state` (a `Chip`; for a running state such as "Läuft"
122
+ `state={<Text weight="medium"><Icon name="gavel" /> Läuft</Text>}`; or an amount),
123
+ `actions` (text buttons),
124
+ `menu` (more deeds behind "…"), `folded` (head only, with a chevron),
125
+ children. No line inside; never a `Group` in a `Group`, and never in a
126
+ `Band` (the band's line would cut the frame). Groups stand in a `Section`
127
+ or directly in a `Pane`. A group's way (arrived → … → paid) is `Steps`
128
+ inside it.
129
+
130
+ ## Content
131
+
132
+ ### List and Row
133
+
134
+ `List` holds `Row`s (`label` names it). A `Row`:
135
+
136
+ - `lines`: 1–3 texts. 1 line 40 px, 2 lines 52 px (second quiet), 3 lines
137
+ 72 px (mail: sender, subject, preview).
138
+ - lead: `icon` + `color`, or `avatar`, or a dot when `unread`.
139
+ - `meta` (quiet note after the title, a count), `time` (top right). Title
140
+ and `meta` share the first line in equal parts, and each takes only what
141
+ it needs: a count or a number stays whole, a long note is cut with "…",
142
+ and the title breaks only when it is longer than its part.
143
+ - `marks` (chips, icons, avatars bottom right): use them with 3 lines; on a
144
+ 2-line row they add a third line. The third line shares its width with
145
+ the marks, so keep it a preview text that may be cut, never an amount.
146
+ - `action` (one framed button at the end; under the text on the phone),
147
+ `end` (a few icon buttons, or the state chip of a one- or two-line row).
148
+ - states: `unread`, `strong`, `selected` (the open one), `yours` (you are
149
+ next).
150
+ - `href` (+ `onNavigate` to open in place) makes the whole row open its
151
+ entry; `onOpen` only for what has no address.
152
+
153
+ Rows may also stand directly in a `Section` or `Band`.
154
+
155
+ A row with an amount, a state and a deed in a narrow column (an invoice in
156
+ a 400 px panel): two lines `[customer, "1.280,00 € · fällig 12. Nov."]`,
157
+ the number as `meta`, the state chip in `end`, the deed as `action`.
158
+
159
+ ### Table
160
+
161
+ `columns: Column<T>[]`, `rows: T[]`, `label`. A column: `title`, `cell(row)`
162
+ returning one value or `{ lines: [line, quietLine] }`, `align: "end"` for
163
+ numbers and amounts, `width={{ min, default }}` (exactly that wide, cut text
164
+ never widens it, grip in the head), `wrap` (one text column may take 3
165
+ lines), `drop` (leaves on the phone). The last column takes the rest. Chips,
166
+ `Progress`, text buttons are fine in cells. `open(row) => { href } | {
167
+ onOpen }` makes each row open its entry.
168
+
169
+ A large table (Grids, a work list) adds, all optional: `rowKey(row)` (needed
170
+ for the next three), `select: { selected, onChange, all, row }` (a box
171
+ column; pair it with `StatusRow selection`), `current` (the open row's key,
172
+ tinted), `sticky` (first column stays while scrolling sideways), `group(row)
173
+ => { key, head: () => JSX, meta?, count? }` (tinted group rows), `sort: { column,
174
+ direction }` (an arrow in that head), `phone(row) => { lines, avatar?, time?
175
+ }` (on the phone each row becomes a two-line row instead).
176
+
177
+ Give every table whose column widths add up to more than a phone (about
178
+ 350 px after the dropped ones) a `phone(row)`; otherwise its last columns
179
+ are cut off at 390 px (the outline reports it). A phone row opens what
180
+ `open(row)` names; a row's other deeds live on the page it opens.
181
+
182
+ `loading` (`true` or `{ rows?, lines? }`): the head stays and placeholder
183
+ rows hold the place of the rows. `empty` (`{ icon, text, action? }`): with
184
+ no rows and nothing loading, the empty state stands in place of the table.
185
+
186
+ ### Facts
187
+
188
+ `items: { label, value, hint?, copy? }[]`: label 12 quiet, value 13, 32 px
189
+ per row; `copy` adds a copy button with that text. `inline` puts all on one
190
+ line with `end` (such as a print button).
191
+
192
+ ### Text
193
+
194
+ `type`: `meta` 12/16, `row` 13/20 (default), `body` 14/20, `lead` 18/24.
195
+ `weight` (`"strong"` 600, `"medium"` 500 for a state or amount that stands
196
+ out a little), `muted`, `tone` (`ok`, `warn`, `bad`, `ai`, `draft`), `href`
197
+ (underlined words that lead somewhere; blue is only for the main action).
198
+ Without `type`, text takes the role of its place.
199
+ In a column it is a block with the text edge; in a bar or row it runs
200
+ inline. Emphasis is a weight, never a size.
201
+
202
+ ### Prose
203
+
204
+ Reading text (14/22, measure 720): `markdown` (rendered safely: no images,
205
+ safe links only) or children.
206
+
207
+ ### Inline
208
+
209
+ One line of things with the one gap of 8 px, such as chips after a count
210
+ in a `Bar start`. In a column narrower than 480 px it wraps onto more
211
+ lines instead of cutting a thing.
212
+
213
+ ### Icon, Avatar, Chip, Progress
214
+
215
+ - `Icon`: `name`, `label` (without one it is decoration), `tone`.
216
+ - `Avatar`: a `Person`; the place sets the size.
217
+ - `Chip`: exactly one kind: `status` (dot + word), `yours` (+ `dot` for
218
+ "in Arbeit"), `tag` (+ `color`), `amount` (`out` or `in`), `ai`, or
219
+ plain; `icon`; `onClick` or `href` makes it a control, `pressed` marks an
220
+ active filter. Never a colour without a word. There is no neutral status:
221
+ "Pausiert" is `warn` or a plain chip.
222
+ - `Progress`: `value`, `of`, `label` ("Arbeitstag 5 von 22").
223
+
224
+ ## Controls
225
+
226
+ - `Button`: `variant` `primary` (one per page), default (framed), `ghost`,
227
+ `text` (quiet, in heads and at row ends); `icon`, `avatar` (a `Person`,
228
+ such as the one a thread is assigned to), `href` (+ `onNavigate`),
229
+ `onClick`, `menu` (chevron), `forward`, `disabled`, `type`, `keep` (stays
230
+ in a head on the phone), `title` (a hint under the pointer, for a button
231
+ whose words give way to its symbol in a narrow place). Without children
232
+ it needs `label`.
233
+ - `Field`: `label`, `name`, `hint`, `error` (replaces the hint, marks the
234
+ control), `optional` (one quiet word at the end of the label line: a unit
235
+ such as "Sekunden", or "optional"), one control as child. `Field.Row`
236
+ puts fields side by side (one column on the phone). `required` keeps the
237
+ form from being sent without a value; the label line shows nothing for
238
+ it, the fields that may stay empty say "optional". After a failed save a
239
+ required field shows `error="Pflichtfeld."`.
240
+ - `Input`: `value`, `placeholder`, `type`, `icon`, `multiline`, `min`,
241
+ `max`, `onInput`; `label` when it stands without a `Field` (a search).
242
+ `onKeyDown` (Enter to search, Escape to clear; while
243
+ `event.isComposing`, Enter belongs to the input method and must not
244
+ search), `ref` (the text field, to focus it), `end` (a symbol or a ghost
245
+ icon button, such as the filter of a search).
246
+ - `Select`: `options` (strings or `{ value, label }`), `value`, `onChange`,
247
+ `placeholder`.
248
+ - `DateInput`: `value`, `onInput`, `placeholder`.
249
+ - `Check`: `label`, `checked` (`true`, `false`, `"mixed"`), `switch`,
250
+ `onChange`.
251
+ - `Choice`: a few visible options, one chosen: `name`, `options`, `value`,
252
+ `label`, `onChange`. With a `label` and no `Field` around it, it shows
253
+ that label as a field of its own; inside a `Field` the field's label is
254
+ its question.
255
+
256
+ ## Components
257
+
258
+ - `Nav`: `title`, `icon`, `groups: { label?, action?, items }[]`, `foot`.
259
+ An item: `label`, `icon`, `href` or `onClick`, `count`, `current`,
260
+ `nested`, `dot` (`"ok"` for something new, `"warn"`/`"bad"` for a
261
+ problem there).
262
+ - `Tabs`: `label`, `items: { label, icon?, count?, href?, onClick?,
263
+ current?, menu? }[]`. In a head `Bar start` they share the bar with actions; as a `Pane`
264
+ head they are their own 44 px bar.
265
+ - `StatusRow`: `lead` (the one statement, "7 ungelesen"), `facts: { before?,
266
+ value?, after? }[]` (leave on the phone, so put what must stay in `lead`),
267
+ `select: { label, checked?, onChange? }` (select-all box), `filters` (end:
268
+ a `Button variant="ghost" menu`, pressed chips; leave on the phone),
269
+ `selection: { count, actions, clear }` (while rows are selected the row
270
+ becomes the bar of what can be done with them).
271
+ - `Path`: `label`, `items: { label, href? }[]`; where a page stands, in the
272
+ head `Bar start` instead of `Tabs`. The last item is the page itself. On
273
+ the phone a head with a path is hidden and the shell's phone bar names
274
+ the page.
275
+ - `Steps`: `label`, `items: { label, meta?, state: "done" | "now" | "next"
276
+ }[]`; a way of a few steps, such as a delivery's way inside its `Group`.
277
+ - `Notice`: `tone` `note`, `ai`, `bad`, `warn`; `title`, `meta`, `icon`,
278
+ `actions` (≤ 2 text buttons), children (the sentence and its
279
+ consequence). Use it for errors with a way out instead of "try again"
280
+ buttons of your own.
281
+ - `Digest`: the newest few without lines: `items: { icon, color?, date,
282
+ title, state: { icon, label, tone? }, text, href? }[]`.
283
+ - `RecordHead`: `name`, `avatar`, `kinds`, `ids: { label?, value, icon?,
284
+ copy? }[]`. Put it in the head `Bar start`.
285
+
286
+ ## States
287
+
288
+ Each stands where the data will stand, without a box, so the head and the
289
+ status row above it never move.
290
+
291
+ - `Empty`: `icon`, `text` (one sentence that says what is the matter: "Noch
292
+ keine Einlieferung." is not "Keine Treffer mit diesem Filter."), `action`
293
+ (the one way out).
294
+ - `Loading`: `rows` (3 when not set; give as many as usually come),
295
+ `lines` (1, 2 or 3, as the rows that will come). It stands where the
296
+ `List` will stand; a `Table` takes `loading` itself.
297
+ - `Failed`: `text` (what could not be loaded and what stays as it is),
298
+ `onRetry`; the button says "Erneut versuchen". Only for data that failed
299
+ to load once, in its place. Never in a status row: a connection that
300
+ retries on its own says so in the `StatusRow` without a button, and
301
+ something a person must fix is a `Notice` that names the deed.
302
+
303
+ ## Tools
304
+
305
+ - `describeV2(element, { layout? })`: the text outline of a screen; see
306
+ `seeing.md`.
307
+ - `@k2b/ui/v2/testing`: `measureV2Layout(page)`, `describeV2Page(page)`,
308
+ `settled(page)` for Playwright tests; see `seeing.md`.
309
+ - Tokens for tests: `typeRoles`, `fontWeights`, `heights`, `textEdge`,
310
+ `radii`, `hairline`, `gripTolerance`.
@@ -0,0 +1,101 @@
1
+ # Recipes
2
+
3
+ A recipe is a whole screen in one file under `recipes/`, with sample data at
4
+ the top and one default export. Copy the file, keep its structure, replace
5
+ the data. The pictures in `images/` are drawn from these files by
6
+ `packages/ui/scripts/v2-preview.ts` (light, 1440 and 390 px), and a browser
7
+ test keeps every recipe free of findings, so code and picture always match.
8
+
9
+ Read the recipe file next to its picture: each part in the code is one
10
+ thing you can point at in the image.
11
+
12
+ ## list-detail.tsx: a list beside the open entry
13
+
14
+ ![list with detail at 1440 px](../images/list-detail-1440.png)
15
+ ![list with detail at 390 px](../images/list-detail-390.png)
16
+
17
+ `Workspace` with `Nav`, a head `Bar` with `Tabs` and the main action;
18
+ `Pane.Split` with the list (`StatusRow`, `List` of two-line `Row`s, the open
19
+ one `selected`) and a `Pane detail` (head `Bar` with the name and actions,
20
+ `Notice tone="bad"` with a way out, `Section`s with `Facts` and `Row`s).
21
+
22
+ - On the phone the detail pane leaves. Open an entry as its own route there.
23
+ - An error of the open entry is a `Notice` at the top of the detail, not a
24
+ red text somewhere.
25
+
26
+ ## form.tsx: a form with server errors and a conflict
27
+
28
+ ![form at 1440 px](../images/form-1440.png)
29
+ ![form at 390 px](../images/form-390.png)
30
+
31
+ `Notice tone="warn"` for a conflict that blocks saving; `Band`s of `Field`s
32
+ (`Field.Row` for fields side by side); a server error goes into the `error`
33
+ of its field; `Choice` and `Check switch` for options; a `Bar` at the end
34
+ with "Cancel" and the one primary "Save", disabled while the conflict lasts.
35
+
36
+ - Validation and server answers live in the app's state; the primitives
37
+ only show `error`.
38
+ - Until v2 has a `Dialog`, the form stands in its own pane or route.
39
+
40
+ ## record.tsx: a record, first tab
41
+
42
+ ![record at 1440 px](../images/record-1440.png)
43
+ ![record at 390 px](../images/record-390.png)
44
+
45
+ `RecordHead` in the head `Bar`; `Tabs` as the head of the record's `Pane`.
46
+ Across both columns: a pinned `Notice tone="note"` and `Cells` with the key
47
+ statements. Below them a `Pane.Split`: the main column with
48
+ `Section "Anstehend"` (`Row yours`, row actions) and a `Section` with a
49
+ `Digest` and a `more` link; a `Pane side` with a `Canvas` (map) and
50
+ `Section` + `Facts`.
51
+
52
+ - What needs a person comes first; history comes after.
53
+ - Area colours (`color`) mark the same area in cells, sections and groups
54
+ (tabs carry no colour).
55
+
56
+ ## record-groups.tsx: a record tab with groups
57
+
58
+ ![record groups at 1440 px](../images/record-groups-1440.png)
59
+ ![record groups at 390 px](../images/record-groups-390.png)
60
+
61
+ One `Section` for the area with a `summary`; one `Group` per delivery with
62
+ `meta`, a `state` chip and actions. Inside a group: a strong sentence, its
63
+ way as `Steps`, a `Table` with two-line cells and `Progress`, `Facts inline`
64
+ with a print button. A finished group is `folded`.
65
+
66
+ - Never a `Group` inside a `Group`, never a line inside one.
67
+ - "You are next" is `Chip yours`, not a red badge.
68
+
69
+ ## mail.tsx: a list with a reader
70
+
71
+ ![mail at 1440 px](../images/mail-1440.png)
72
+ ![mail at 390 px](../images/mail-390.png)
73
+
74
+ Three-line `Row`s (sender, subject, preview) with `unread`, `meta` count,
75
+ `time` and `marks`; `StatusRow` with select-all. The reader: head `Bar`
76
+ with the subject as `Text type="lead"` and actions; a `Bar` with `Inline`
77
+ chips; `Notice tone="ai"` for the summary; one `Band` per message with a
78
+ sender `Row` (avatar, icon buttons in `end`), `Prose`, `Tiles`.
79
+
80
+ - A colleague's internal note in the thread is a `Notice tone="note"` with
81
+ `title` and `meta` (who, when).
82
+ - The reply: until the composer of `@k2b/editor` arrives (gap), a `Band`
83
+ with a `Field` and `<Input multiline />`, followed by a `Bar` whose `end`
84
+ holds "Senden" as a default button (the page's primary stays "Neue
85
+ Nachricht").
86
+
87
+ ## table.tsx: a table with a status row
88
+
89
+ ![table at 1440 px](../images/table-1440.png)
90
+ ![table at 390 px](../images/table-390.png)
91
+
92
+ `StatusRow` with the lead ("3 offen"), facts (sum, overdue) and a filter
93
+ button at the end; `Table` with widths, a status `Chip`, an amount column
94
+ `align: "end"`, one text button per row, `drop` on the columns that matter
95
+ least, and `phone(row)` so the phone shows two-line rows instead of a cut
96
+ table. `open(row)` gives each row the address of its invoice (on the phone
97
+ too); `empty` says "Keine offenen Rechnungen." in place of the table, and
98
+ `loading` would hold its place while the rows load.
99
+
100
+ - The lead says the one thing; the rest are facts, which leave on the phone.
101
+ - A deed per row is a `Button variant="text"` in its own last column.
@@ -0,0 +1,94 @@
1
+ # See what you built
2
+
3
+ You cannot see the screen. Four kinds of feedback replace the look, from the
4
+ cheapest to the most expensive. Run them in this order after every change
5
+ and fix what the cheaper one finds before you pay for the next.
6
+
7
+ | Step | Cost | Finds |
8
+ | --- | --- | --- |
9
+ | types | free with the build | wrong or missing props, an icon button without a name, two `Chip` kinds |
10
+ | rule `v2-app-layout-css` | ~1 s | `class`, `style`, spreads, `innerHTML`, stylesheets outside `Canvas`; a `Canvas` in the wrong place |
11
+ | outline (`describeV2`) | ~30 lines of text | the structure, every text, counts, hidden parts, `Problems` |
12
+ | layout (`measureV2Layout`) | a browser | lines short of the edge, double lines, a line inside one band or group, cut control labels, wrapped one-line texts, text off the four type roles, grips off their line |
13
+ | screenshot | an image per width | everything else; only when in doubt |
14
+
15
+ ## In the Cloud monorepo
16
+
17
+ `packages/ui/scripts/v2-preview.ts` runs all steps on one screen file
18
+ whose default export is a component without props:
19
+
20
+ ```bash
21
+ bun packages/ui/scripts/v2-preview.ts packages/my-app/src/screens/sources.tsx --text
22
+ bun packages/ui/scripts/v2-preview.ts packages/my-app/src/screens/sources.tsx --png .local/shots
23
+ ```
24
+
25
+ - `--text`: types, rule and outline from the server markup, no browser.
26
+ Use it after every edit.
27
+ - without `--text`: Chromium at 1440 and 390 px (`--width` to change),
28
+ outline with layout (hidden parts, dropped columns) and the measurement.
29
+ - `--png <dir>`: also a light screenshot per width.
30
+ - Exit code 0 means every step is clean.
31
+ - On a shared machine, run the browser variant through its load wrapper.
32
+
33
+ `bun run check` runs the rule on every app; `bun run --cwd packages/<app>
34
+ typecheck` runs the types.
35
+
36
+ ## The outline
37
+
38
+ `describeV2` reads the `data-k2-part` marks. One line per part, indented by
39
+ nesting, slots named (`head:`, `status:`). Words in brackets are buttons,
40
+ in parentheses chips, `@Name` an avatar. A long list shows three entries
41
+ and `… n more`. The `Problems` block names what a person would see as
42
+ wrong:
43
+
44
+ ```text
45
+ Workspace (sidebar, head) primary "Neue Quelle"
46
+ Nav "Pulse": 2 entries, current "Quellen"
47
+ head: Bar: Tabs "Ansichten": Alle (3) ✓, Gestört (1) | ["Neue Quelle" primary]
48
+ Pane.Split
49
+ Pane "Quellen" width 320px–400px
50
+ status: StatusRow "3 Quellen" · 1 gestört
51
+ List "Quellen": 3 entries
52
+ Row "Lackfabrik Nordhaus" / "Webhook" · 09:42 opens link
53
+ …
54
+ Pane "Holzwerk Brandt" detail
55
+ head: Bar: "Holzwerk Brandt" lead | ["Bearbeiten"] ["Schließen" ghost link]
56
+ Notice bad "Antwortet nicht": "Seit gestern, 17:20 …" ["Erneut prüfen" text]
57
+
58
+ Problems (1):
59
+ - plain <div> in Pane "Quellen" "lose": no primitive owns it; use Band, …
60
+ ```
61
+
62
+ Compare your outline with the task, not only with the problems: is every
63
+ required part there (the error state, the empty state, the main action, the
64
+ phone)? At 390 px the outline says which parts are hidden and which table
65
+ columns dropped.
66
+
67
+ ## Outside the monorepo
68
+
69
+ `@k2b/ui/v2/testing` brings the same checks to a Playwright test of your
70
+ app (Playwright is an optional peer dependency of `@k2b/ui`):
71
+
72
+ ```ts
73
+ import { expect, test } from "@playwright/test";
74
+ import { describeV2Page, measureV2Layout } from "@k2b/ui/v2/testing";
75
+
76
+ for (const width of [1440, 390])
77
+ test(`the sources screen at ${width} px`, async ({ page }) => {
78
+ await page.setViewportSize({ width, height: 900 });
79
+ await page.goto(url);
80
+ expect(await describeV2Page(page)).not.toContain("Problems");
81
+ expect((await measureV2Layout(page)).problems).toEqual([]);
82
+ });
83
+ ```
84
+
85
+ Print the outline (`console.log(await describeV2Page(page))`) when you
86
+ need to see the screen. With server markup and no browser (happy-dom,
87
+ linkedom), call `describeV2(element)` from `@k2b/ui/v2` without `layout`.
88
+
89
+ ## Screenshots
90
+
91
+ Ask for one only when the outline cannot answer the question: does the
92
+ drawing in a `Canvas` fit, does a long name read well, is the phone layout
93
+ what the task meant. Light mode, 1440 and 390 px. Compare it with the
94
+ recipe pictures in `images/`.