@partrunner-ai/ui 2.4.3 → 2.5.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/DESIGN.md ADDED
@@ -0,0 +1,444 @@
1
+ # Design manual for agents
2
+
3
+ How to build a PartRunner screen with `@partrunner-ai/ui`. Read this file before you write or
4
+ change a screen. In an app it is at `node_modules/@partrunner-ai/ui/DESIGN.md`.
5
+
6
+ This file describes the package version it ships with. If a component named here is not exported
7
+ by the version the app has installed, upgrade the package first. Do not build a local copy.
8
+
9
+ The visual language (palette, radii, shadows, type faces) is in `docs/crystal-guide.md` of the
10
+ platform repository. You do not need it to build a screen: the components already apply it.
11
+
12
+ ## The rule
13
+
14
+ A screen is a **recipe** filled with **package components**. You do not write CSS for a screen.
15
+ If you write a class for colour or type, a `style`, a `<table>`, or a colour value, stop: a
16
+ component does that job.
17
+
18
+ ## 1. Work method
19
+
20
+ Do these five steps in order. Do not start with code.
21
+
22
+ 1. **Write the job in one sentence.** "A Finance analyst finds the fleets with an unpaid charge and
23
+ makes a payment plan for one." The sentence names the person, the thing they look for, and the
24
+ one action that matters most. That action is the screen's primary action.
25
+ 2. **Pick one recipe** from section 2. If none fits, pick the nearest and change the least.
26
+ 3. **Copy the recipe's full example** from `recipes/` in this package and fill it from the
27
+ component table in section 3. Use the app's existing data and text.
28
+ 4. **Write every state** from section 5: loading, empty, error, no permission.
29
+ 5. **Look at the screen.** Run it, take a screenshot at 1440 px and at 390 px, and answer the
30
+ checklist in section 8. Fix each "no". A screen you did not look at is not finished.
31
+
32
+ When you change an existing screen: keep its content, its flow and its words. Change the
33
+ structure only where a rule in this manual is broken.
34
+
35
+ ## 2. Recipes
36
+
37
+ Each recipe has a full example that compiles, with all four states, in this package:
38
+
39
+ | Recipe | Use it when | Full example |
40
+ |---|---|---|
41
+ | List page | the person finds records, then acts on one | `recipes/list-page.md` |
42
+ | Inbox | the person works through many records, one open at a time | `recipes/inbox.md` |
43
+ | Record page | the person reads one record and acts on it | `recipes/record-page.md` |
44
+ | Form | the person creates or changes one record | `recipes/form.md` |
45
+ | Work queue | the person makes the same decision on many records | `recipes/work-queue.md` |
46
+
47
+ The skeletons below show the structure only. Take prop details from the full example.
48
+ `recipes/states.md` shows the four states of section 5 on one region.
49
+ `Page` spaces its direct children. Inside any other container use `Stack` for the gaps.
50
+
51
+ ### 2.1 List page
52
+
53
+ ```tsx
54
+ <Page>
55
+ <PageHeader title="Colocadas" actions={<Button variant="primary">Nueva colocada</Button>} />
56
+ <StatTileGrid columns={4}>…</StatTileGrid> {/* optional, at most 4 tiles */}
57
+ <FilterChipRow aria-label="Estado">…</FilterChipRow> {/* optional, one field, ≤ 7 values */}
58
+ <Toolbar>
59
+ <SearchField aria-label="Buscar" placeholder="Buscar conductor o placa" />
60
+ <DateRangeFilter aria-label="Ventana de fechas" value={range} onChange={setRange}
61
+ presets={DATE_PRESETS} labels={DATE_LABELS} locale="es-MX" size="sm" />
62
+ <MultiSelect variant="filter" aria-label="Filtrar por proyecto" placeholder="Proyecto"
63
+ options={PROJECTS} value={projects} onChange={setProjects} />
64
+ </Toolbar>
65
+ <TableFrame title="Colocadas" count={total}
66
+ footer={<Pagination aria-label="Paginación" page={page} pageSize={25} totalItems={total}
67
+ onPageChange={setPage}
68
+ labels={{ previous: 'Página anterior', next: 'Página siguiente',
69
+ summary: ({ start, end, totalItems }) => `${start}–${end} de ${totalItems}` }} />}>
70
+ <Table<Placement> bare label="Colocadas" rows={rows} getRowKey={(row) => row.id}
71
+ loading={loading} empty={<EmptyState title="Sin colocadas en esta ventana" />}
72
+ columns={[
73
+ { key: 'driver', header: 'Conductor' },
74
+ { key: 'date', header: 'Fecha', render: (row) => formatDate(row.date), hideOnMobile: true },
75
+ { key: 'rate', header: 'Tarifa semanal', numeric: true, render: (row) => formatMoney(row.rate) },
76
+ { key: 'status', header: 'Estado', render: (row) => <Badge tone={TONE[row.status]}>{LABEL[row.status]}</Badge> },
77
+ ]} />
78
+ </TableFrame>
79
+ </Page>
80
+ ```
81
+
82
+ `Pagination`, `DateRangeFilter` and `MultiSelect` have English default labels: always pass the
83
+ Spanish ones. On a phone a table keeps 2 or 3 columns: set `hideOnMobile` on the rest.
84
+
85
+ ### 2.2 Inbox
86
+
87
+ Use it for conversations, cases, tickets and document review. The list stays visible while the
88
+ person reads one record.
89
+
90
+ ```tsx
91
+ <Page width="wide">
92
+ <PageHeader title="Bandeja de flotas" />
93
+ <Toolbar>
94
+ <FilterChipRow aria-label="Vista">
95
+ <FilterChip active={view === 'reply'} count={counts.reply} onClick={() => setView('reply')}>
96
+ Esperan respuesta</FilterChip>
97
+ <FilterChip active={view === 'overdue'} count={counts.overdue} tone="danger" dot
98
+ onClick={() => setView('overdue')}>Vencidas</FilterChip>
99
+ …
100
+ </FilterChipRow>
101
+ <ToolbarSpacer />
102
+ <MultiSelect variant="filter" aria-label="Atiende" placeholder="Atiende"
103
+ options={PEOPLE} value={people} onChange={setPeople} />
104
+ </Toolbar>
105
+ <SplitView
106
+ listLabel="Flotas"
107
+ listHeader={<SearchField aria-label="Buscar flota" placeholder="Buscar flota" />}
108
+ list={
109
+ <ItemList aria-label="Flotas">
110
+ {fleets.map((fleet) => (
111
+ <ItemRow key={fleet.id} selected={fleet.id === openId}
112
+ tone={fleet.urgency ?? undefined} unread={fleet.nextStep === 'reply'}
113
+ leading={<Avatar name={fleet.name} size="sm" tone={toneFromString(fleet.id)} decorative />}
114
+ title={fleet.name}
115
+ description={<><strong>{fleet.lastSpeaker}:</strong> {fleet.lastMessage}</>}
116
+ meta={fleet.lastSeen}
117
+ footer={<>
118
+ {fleet.urgency ? <Badge tone={fleet.urgency} size="sm">{fleet.signal}</Badge> : null}
119
+ 2 aclaraciones · 1 chat · Atiende Ana Ruiz
120
+ </>}
121
+ href={`/bandeja?f=${fleet.id}`} LinkComponent={Link} /> {/* or onClick */}
122
+ ))}
123
+ </ItemList>
124
+ }
125
+ detailLabel="Conversación"
126
+ detailOpen={openId != null}
127
+ onBack={() => router.push('/bandeja')}
128
+ detail={
129
+ fleet == null
130
+ ? <EmptyState icon={Inbox} title="Elige una flota" description="Aquí ves todo lo que tiene abierto." />
131
+ : <Stack>
132
+ <SectionHeading title={fleet.name} description={fleet.rfc}
133
+ actions={<Button variant="secondary">Marcar resuelta</Button>} />
134
+ <Tabs defaultValue="chat">
135
+ <TabsList>
136
+ <TabsTrigger value="chat">Conversación</TabsTrigger>
137
+ <TabsTrigger value="cases">Aclaraciones</TabsTrigger>
138
+ <TabsTrigger value="profile">Perfil</TabsTrigger>
139
+ </TabsList>
140
+ <TabsContent value="chat">…</TabsContent>
141
+ <TabsContent value="cases">…</TabsContent>
142
+ <TabsContent value="profile"><DetailList layout="inline">…</DetailList></TabsContent>
143
+ </Tabs>
144
+ </Stack>
145
+ }
146
+ />
147
+ </Page>
148
+ ```
149
+
150
+ - When the open record is in the URL, the row is a link: `href` and the router's `LinkComponent`.
151
+ Use `onClick` only when the selection is local state.
152
+ - An inbox for work is a ticket desk. Each row answers four questions: who (the `Avatar` and the
153
+ title), what was said last and by whom (the description starts with the speaker: «Flota:»,
154
+ «Soporte:», «Asistente:»), how long it waits (a `Badge` at the start of the `footer`), and what is open
155
+ and who has it (the text of the `footer`). The time of the last message is the `meta`. Do not
156
+ use `trailing` in a ticket desk: a badge there pushes the time and cuts the title.
157
+ - Give each record one next step: ours to reply, ours to work, or theirs. Sort in that order.
158
+ Urgency colour (`tone` on the row and on the badge) shows only when the next step is ours. A
159
+ record that waits for the other side stays quiet.
160
+ - Filters go in a `Toolbar` above the `SplitView`: quick views with counts as `FilterChip`s,
161
+ people and reasons as `MultiSelect variant="filter"`. The list heading shows the count
162
+ («5 de 63 flotas»).
163
+ - In a conversation, every message shows who speaks: an `Avatar` and the name once for each
164
+ group of messages. A person and a bot never look the same: use a different bubble tint and
165
+ name. An event in the thread («Aclaración abierta») is a centred line with a `Badge` and a
166
+ link, not a message bubble.
167
+ - More than 20 rows need a `SearchField` in `listHeader`.
168
+ - Items inside the detail pane are not cards (the pane already has a border). Use
169
+ `SectionHeading`, `DetailList`, `Disclosure` and `Separator`.
170
+ - Chat bubbles and the message composer have no package component yet. They are the one place
171
+ where app CSS is allowed: `--pr-*` tokens only, no `font-size`, no colour values.
172
+
173
+ ### 2.3 Record page
174
+
175
+ ```tsx
176
+ <Page>
177
+ <PageHeader title={fleet.name} subtitle={`${fleet.rfc} · ${fleet.city}`}
178
+ actions={<><Button variant="secondary">Editar datos</Button>
179
+ <Button variant="primary">Crear plan de pago</Button></>} />
180
+ {held ? <Notice tone="warning" title="Pago de la semana 47 retenido"
181
+ actions={<Button variant="secondary" size="sm">Ver pagos</Button>}>
182
+ Falta la constancia de situación fiscal vigente.</Notice> : null}
183
+ <Card>
184
+ <SectionHeading title="Datos generales" />
185
+ <DetailList columns={3}>
186
+ <DetailItem label="RFC">{fleet.rfc}</DetailItem>
187
+ <DetailItem label="Régimen fiscal">{fleet.regime}</DetailItem>
188
+ <DetailItem label="Saldo a cargo" numeric>{formatMoney(fleet.balance)}</DetailItem>
189
+ </DetailList>
190
+ </Card>
191
+ <Tabs defaultValue="routes">…</Tabs> {/* related lists: each panel is a TableFrame */}
192
+ </Page>
193
+ ```
194
+
195
+ A record shown as a card in a list of cards (a payment plan, a case) has this order inside one
196
+ `Card`: `SectionHeading` (title, one `Badge` for the state) → `DetailList` → a `Table bare` if
197
+ the record has lines → one row of actions at the bottom (one primary, the rest in a
198
+ `DropdownMenu`). A `Table bare` inside a `Card` is not a nested box.
199
+
200
+ ### 2.4 Form
201
+
202
+ - Up to 6 fields and no navigation away: `Dialog` (`size="md"`), actions in `footer`.
203
+ - A record edited beside its list: a `Sheet` on the right (`SheetRoot`, `SheetContent`).
204
+ - More than 6 fields or several sections: a page with `Page width="narrow"`.
205
+
206
+ ```tsx
207
+ <Dialog open={open} onClose={close} title="Nuevo plan de pago"
208
+ description="Define cuánto y en cuántas semanas se cobra el saldo."
209
+ footer={<><Button variant="secondary" onClick={close}>Cancelar</Button>
210
+ <Button variant="primary" loading={saving} onClick={save}>Crear plan</Button></>}>
211
+ <Stack>
212
+ {failed ? <ValidationSummary errors={[
213
+ { fieldId: 'plan-amount', label: 'Monto total', message: 'Escribe el monto total.' },
214
+ ]} /> : null}
215
+ <FormField label="Monto total" required error={errors.amount} controlId="plan-amount" fullWidth>
216
+ <Input inputMode="decimal" value={amount} onChange={…} />
217
+ </FormField>
218
+ <FormField label="Primer cobro" hint="El cobro se hace cada semana." controlId="plan-start">
219
+ <DatePicker … />
220
+ </FormField>
221
+ </Stack>
222
+ </Dialog>
223
+ ```
224
+
225
+ One column. Labels above the fields. `FormField` wraps exactly one control and gives it the id
226
+ and the ARIA attributes. Each `ValidationSummary` error names the `fieldId` of its control, so
227
+ its link moves the focus there. Show the summary only after a failed submit. The primary button
228
+ says the result ("Crear plan"), not "Aceptar". A destructive action uses `ConfirmDialog
229
+ destructive`.
230
+
231
+ ### 2.5 Work queue
232
+
233
+ Use it for approvals and reviews. It is a list page where each row has its action.
234
+
235
+ ```tsx
236
+ <Page>
237
+ <PageHeader title="Saldos a cargo" subtitle="8 saldos por revisar · $121,450.00 en total"
238
+ actions={<SegmentedControl aria-label="Vista" value={view} onChange={setView}
239
+ options={[{ value: 'review', label: 'Por revisar' }, { value: 'plans', label: 'Planes' }]} />} />
240
+ <TableFrame title="Por revisar" count={rows.length}>
241
+ <Table<Balance> bare label="Saldos por revisar" rows={rows} getRowKey={(row) => row.id}
242
+ columns={[
243
+ { key: 'fleet', header: 'Flota' },
244
+ { key: 'amount', header: 'Saldo a cargo', numeric: true, render: (row) => formatMoney(row.amount) },
245
+ { key: 'status', header: 'Estado', hideOnMobile: true,
246
+ render: (row) => <Badge tone={TONE[row.status]}>{LABEL[row.status]}</Badge> },
247
+ { key: 'actions', header: 'Acciones', align: 'end', render: (row) => (
248
+ <ToolbarGroup>
249
+ <Button size="sm" variant="secondary" onClick={() => plan(row)}>Crear plan</Button>
250
+ <DropdownMenu>
251
+ <DropdownMenuTrigger asChild>
252
+ <IconButton size="sm" variant="ghost" label={`Más acciones para ${row.fleet}`}
253
+ icon={<MoreHorizontal size={16} aria-hidden />} />
254
+ </DropdownMenuTrigger>
255
+ <DropdownMenuContent align="end">
256
+ <DropdownMenuItem onSelect={() => open(row)}>Ver ficha de la flota</DropdownMenuItem>
257
+ <DropdownMenuItem destructive onSelect={() => waive(row)}>Condonar saldo</DropdownMenuItem>
258
+ </DropdownMenuContent>
259
+ </DropdownMenu>
260
+ </ToolbarGroup>
261
+ ) },
262
+ ]} />
263
+ </TableFrame>
264
+ </Page>
265
+ ```
266
+
267
+ A row shows at most one button. The other actions go in a `DropdownMenu` on an `IconButton`.
268
+ At most 7 columns; move the rest to the record page or a `Sheet`.
269
+
270
+ ## 3. One job, one component
271
+
272
+ Do not choose between two components for one job. If a job is not in the table, see section 9.
273
+
274
+ | Job on the screen | Use | Not this |
275
+ |---|---|---|
276
+ | Page container: width and outer spacing | `Page` (the app shell already gives the `<main>`) | `max-w-*`, padding utilities, a second `<main>` |
277
+ | Page title block | `PageHeader` | a local header component, a hero card |
278
+ | Titled section inside a page | `SectionHeading` | `PageHeader` twice |
279
+ | Gap between your own blocks | `Stack` (`gap`: `xs` 4, `sm` 8, `md` 12, `lg` 16 or `xl` 24 px) | margin utilities, a flex `div` with a class |
280
+ | KPI figures in a row | `StatTile` in `StatTileGrid` | `Card` with a big number |
281
+ | Move between **routes** | `NavigationTabs` (`currentPath`, `items`, the router's `LinkComponent`) | `Tabs`, buttons with `role="tab"` |
282
+ | **Parts of one record** or one section, each with its own content | `Tabs` | `SegmentedControl` |
283
+ | **Which list or view** the page shows (Todas / Mías, Por revisar / Planes, lista / tablero) | `SegmentedControl` | two `Button`s with `aria-pressed` |
284
+ | Filter on one field, ≤ 7 values, with counts | `FilterChip` in `FilterChipRow` | `Badge` as a button |
285
+ | Any other filter | `MultiSelect variant="filter"` | one select per filter |
286
+ | Date window of a list | `DateRangeFilter` | two date inputs |
287
+ | Date field in a form | `DatePicker` | `DateRangeFilter` |
288
+ | Row of controls above a list | `Toolbar` + `SearchField`, `ToolbarGroup`, `ToolbarSpacer` | a flex `div` |
289
+ | Table on a page | `TableFrame` around `Table` (+ `Pagination` in `footer`) | `<table>` with class constants |
290
+ | List beside the open record (inbox, cases) | `SplitView` | a hand-made two-column grid |
291
+ | Rows of the list in a `SplitView` or a side panel | `ItemList` + `ItemRow` | `<button>` rows with local CSS |
292
+ | Facts of one record: label and value | `DetailList` + `DetailItem` | `<dl>`, a two-column `div` grid, a two-column table |
293
+ | Content that opens and closes | `Disclosure` | `<details>`, a button with `aria-expanded` |
294
+ | Message about the page or a section (hold, warning, result) | `Notice tone` | a coloured `div`, red text, a toned `Card` |
295
+ | Confirm a risky action | `ConfirmDialog` | `window.confirm`, a local modal |
296
+ | Form field with label, hint, error | `FormField` around one control | a `<label>` and a `<p>` |
297
+ | Short form or a decision | `Dialog` | a local `Modal` |
298
+ | Edit beside the page content | `Sheet` (`SheetRoot`, `SheetContent`) | a second page |
299
+ | Nothing to show | `EmptyState` | a `<p>` |
300
+ | Loading a table | `Table loading`, or `TableSkeleton` with the compound table | "Cargando…" text |
301
+ | Loading a page | `PageSkeleton variant` | a centred spinner |
302
+ | Status or category label | `Badge tone` | a span with colour classes |
303
+ | Tone dot beside text | `StatusDot` | `Badge dot` with no text |
304
+ | Person by initials | `Avatar` | an initials span |
305
+ | Internal comments on one record | `CommentThread` | a list of cards and a textarea |
306
+ | Link in a sentence or beside a title | `Button variant="link"` (`asChild` around the router link) | a bare `<a>` |
307
+ | Icon in a tinted chip | `IconTile` | a hand-tinted span |
308
+ | Stable colour for an entity | `toneFromString(seed)` | a hex value |
309
+
310
+ ### Ordered tie-breaks
311
+
312
+ Run them top to bottom and stop at the first match.
313
+
314
+ 1. Does the option change the URL path? → `NavigationTabs`.
315
+ 2. Is it a part of one open record or one section (Conversación / Perfil)? → `Tabs`.
316
+ 3. Does it change which list or which view of the data the page shows? → `SegmentedControl`.
317
+ 4. Is it a filter? One field, ≤ 7 values, counts shown → `FilterChip`. A date window →
318
+ `DateRangeFilter`. Anything else → `MultiSelect variant="filter"`.
319
+ 5. Is it a table? Uniform records → `Table columns rows` with `loading` / `empty` / `error`.
320
+ Custom rows → compound `Table`, `TableSkeleton`, `EmptyState`. Both go in `TableFrame`.
321
+
322
+ A page has at most two levels of navigation, and they never look the same. The first level is
323
+ `NavigationTabs`. The second level is a `SegmentedControl` or `FilterChip`s. `Tabs` belong to a
324
+ record, below its heading.
325
+
326
+ Status-to-tone maps stay in the app as data (`{ pending: 'warning' }`) and feed `Badge tone`.
327
+ Do not store class names in a map.
328
+
329
+ ### Props that surprise
330
+
331
+ - `IconButton icon` is an element (`<MoreHorizontal size={16} aria-hidden />`). `EmptyState icon`
332
+ is a component (`icon={Inbox}`).
333
+ - The data-driven `Table` needs its row type: `<Table<Row> … getRowKey={(row) => row.id} />`.
334
+ Its `label` names the table for a screen reader.
335
+ - `TableFrame count` shows a number; `countLabel={(count) => `${count} planes`}` changes its text.
336
+ - `SegmentedControl` is as wide as its options. Pass `fullWidth` only inside a narrow panel.
337
+ - `ItemRow tone` marks urgency with an accent bar on the start edge; pair it with a `Badge`, so
338
+ colour is never the only signal. `ItemRow footer` is the third line; it takes text and a
339
+ `Badge` at the start, not buttons or links.
340
+ - `ItemRow unread` adds a hidden text, «No leído», before the title for a screen reader. Pass
341
+ `unreadLabel` to change it.
342
+ - `DateRangeFilter` presets come from the app (`mexicoCityDaysAgo(7)`). The package owns no date
343
+ logic.
344
+ - `DataTable` is an old alias of `Table`. It is not a second choice: use `Table`.
345
+ - Numbers: `numeric` on a table column, on `TableCell` / `TableHead`, and on `DetailItem`
346
+ gives tabular figures. In a table the value is also end-aligned. On `DetailItem` it is
347
+ end-aligned only in a `DetailList` with `layout="inline"`.
348
+
349
+ ## 4. Hierarchy and density
350
+
351
+ A good screen shows what matters first and makes the rest quiet. Use these limits.
352
+
353
+ | Rule | Limit |
354
+ |---|---|
355
+ | Page chrome above the first row of content (header, tabs, filters) | at most 25 % of a 1440 × 900 window |
356
+ | `PageHeader` | a title; a `subtitle` only for the record's key fact; no `eyebrow` that repeats the menu or the tabs; no explanation paragraph |
357
+ | `Button variant="primary"` | one in each view (a dialog is its own view) |
358
+ | Visible buttons in one row, card or toolbar | 2; the rest in a `DropdownMenu` |
359
+ | Text levels in one region | 3: title, body, meta |
360
+ | Tones other than neutral in one region | 2; a tone means a state, never decoration |
361
+ | Table columns | 7 |
362
+ | `StatTile`s | 4 |
363
+ | Nested bordered boxes (a card in a card) | 0; use `SectionHeading` and `Separator` inside one card |
364
+
365
+ - **Colour is a signal.** `danger` = blocked or lost money. `warning` = needs action soon.
366
+ `success` = done. `info` = neutral news. If more than about 1 row in 5 has a tone, the rule that
367
+ sets the tone is wrong.
368
+ - **Numbers** use tabular figures (`numeric`), end-aligned in a table, and use one format in the whole app, from the
369
+ app's shared helper: money `$12,400.00` (`es-MX`, MXN), dates `24 nov 2026`, a time of the
370
+ same year `24 nov, 13:20`, relative time only for the last 7 days (`hace 3 h`).
371
+ - **Text does not get cut inside a card.** One line of `ItemRow description` may truncate. A
372
+ paragraph wraps. A long field goes to its own `DetailItem span="full"`.
373
+ - **Group, do not run on.** Three or more facts are a `DetailList`, not a sentence with labels
374
+ ("Motivo… Responsable… Estatus…").
375
+ - **Spacing** comes from the components and from `Stack`. Layout-only utility classes of the
376
+ app are allowed for what `Stack` cannot do: a grid of columns, `hidden` at a breakpoint,
377
+ `sr-only`. Classes for colour, type, radius, shadow or an arbitrary value are not.
378
+
379
+ ## 5. States
380
+
381
+ Each data region has four states. Write all four before you call the screen finished.
382
+
383
+ | State | Show | Never |
384
+ |---|---|---|
385
+ | Loading | `Table loading` / `TableSkeleton` / `PageSkeleton` / `Skeleton` in the shape of the content | a text line, a layout that jumps |
386
+ | Empty | `EmptyState` with a title that says why, and the action that fills it | an empty table with headers only |
387
+ | Error | `Notice tone="danger"` with what failed, and a "Reintentar" `Button` in `actions` | red text, a raw error code |
388
+ | No permission | `EmptyState` in place of the content: the title says who can use it ("Solo Finanzas puede ver esta sección"), the description says how to get access. Hide the tabs, filters and actions the person cannot use | an error style; controls that do nothing |
389
+
390
+ A saved change answers at once: the button shows `loading`, then the row changes. A result that
391
+ the person must read is a `Notice tone="success"` near the place of the action.
392
+
393
+ ## 6. Text on the screen
394
+
395
+ - Staff and fleet screens are in Spanish. Sentence case: "Crear plan", not "Crear Plan".
396
+ - A button is a verb plus the object: "Crear plan", "Reabrir semana". Not "Aceptar", "OK".
397
+ - A title is the name of the thing: "Saldos a cargo". Do not explain the screen under it.
398
+ - Help text is one line next to the field or the control it explains. No instruction paragraphs.
399
+ - An error says what happened and what to do: "No se guardó el plan. Revisa el monto e intenta
400
+ de nuevo." Do not show codes, table names or stack text.
401
+ - One word for one thing in the whole app. Do not mix "flota", "transportista" and "proveedor".
402
+
403
+ ## 7. Do not
404
+
405
+ Each of these is a defect. Search your diff for them before you finish.
406
+
407
+ - `<table>`, `<details>`, `<dialog>`, `<dl>`, `role="tablist"`, `role="tab"`, `aria-pressed`
408
+ toggles and `aria-expanded` buttons written by hand.
409
+ - A `style={…}` prop, or a new CSS rule for the colour, type or spacing of a screen.
410
+ - Tailwind palette or arbitrary-value classes: `text-red-700`, `bg-amber-50`, `text-[13px]`.
411
+ - A hex or `rgb()` colour. A `font-size` in app CSS.
412
+ - A local copy of a package component: `Modal`, `StatTile`, `PageHeader`, `Toolbar`, `StatusPill`,
413
+ `Field`, `LoadingBlock`.
414
+ - Overrides of `.pr-*` classes or `--pr-*` variables.
415
+ - A local money or date format that differs from the app's shared helper.
416
+
417
+ ## 8. Checklist — answer with the screenshot open
418
+
419
+ 1. Can a new person say what the screen is for in 3 seconds?
420
+ 2. Is the most important action the only primary button, and is it visible without scroll?
421
+ 3. Does the content start in the top quarter of the window?
422
+ 4. Does each tone mark something that needs attention, and only that?
423
+ 5. Are there at most three text levels in each region, and no text cut by mistake?
424
+ 6. Is every block a package component (no rule from section 7 broken)?
425
+ 7. Do loading, empty, error and no-permission states exist and look right?
426
+ 8. Does the screen work at 390 px wide (one column, no horizontal scroll except inside a table)?
427
+ 9. Can you do the main job with the keyboard only, with a visible focus ring?
428
+ 10. Is each label a real word the team uses, in sentence case?
429
+
430
+ To get the screenshots, render the screen in the app's browser tests with mocked data for each
431
+ state, at 1440 × 900 and 390 × 844. Never point a test at a backend that can write or send.
432
+ Open each image and look at it: alignment, even spacing, cut text, too many accents.
433
+
434
+ Put the two main screenshots in the pull request. A reviewer checks them against this list.
435
+
436
+ ## 9. When a component is missing
437
+
438
+ First check the installed version: the component may exist in a newer release. Upgrade, then use
439
+ it.
440
+
441
+ If no release has it, do not build it in the app. Open an issue or a pull request in
442
+ `partrunner-platform` when the pattern is presentation only and at least two screens need it.
443
+ Until it is released, compose the nearest package components and mark the place with
444
+ `// TODO(ui): <component name>`.
package/README.md CHANGED
@@ -30,34 +30,27 @@ import {
30
30
  The package works with React 18 and 19 and does not require a Tailwind runtime.
31
31
  Styles use semantic `--pr-*` tokens.
32
32
 
33
- ## One job, one component
33
+ ## Build a screen
34
34
 
35
- Do not choose between two components for one job. The short form of the table
36
- in [`docs/crystal-guide.md` § 5b](../../docs/crystal-guide.md) — the guide has the
37
- full table, the ordered tie-breaks and the list page recipe:
35
+ Read [`DESIGN.md`](./DESIGN.md) before you write or change a screen. It ships in this package
36
+ (`node_modules/@partrunner-ai/ui/DESIGN.md`) and holds:
38
37
 
39
- | Job | Component |
40
- | --- | --- |
41
- | Page container | `Page` |
42
- | Page title block | `PageHeader` |
43
- | Section title inside a page | `SectionHeading` |
44
- | KPI row | `StatTile` in `StatTileGrid` |
45
- | Routes | `NavigationTabs` |
46
- | Panels with their own content | `Tabs` |
47
- | Same data, other subset or view | `SegmentedControl` |
48
- | Filter on one field, ≤7 values, with counts | `FilterChip` in `FilterChipRow` |
49
- | Any other filter | `MultiSelect variant="filter"` |
50
- | Date window of a list | `DateRangeFilter` |
51
- | Date field in a form | `DatePicker` |
52
- | Row of list controls | `Toolbar` + `SearchField`, `ToolbarGroup`, `ToolbarSpacer` |
53
- | Table on a page | `TableFrame` around `Table` (+ `Pagination` in `footer`) |
54
- | Loading compound table | `TableSkeleton` |
55
- | Nothing to show | `EmptyState` |
56
- | Status label | `Badge tone` |
57
- | Tone dot beside text | `StatusDot` |
58
- | Person by initials | `Avatar` |
59
- | Icon in a tinted chip | `IconTile` |
60
- | Stable entity colour | `toneFromString(seed)` |
38
+ - the work method: job sentence → recipe → components → states → screenshot and checklist;
39
+ - five page recipes: list, inbox, record, form, work queue. Each one has a full example with
40
+ all four states in [`recipes/`](./recipes) (`node_modules/@partrunner-ai/ui/recipes/*.md`);
41
+ - the job → component table and the ordered tie-breaks — one job, one component;
42
+ - limits for hierarchy and density, the four states of a data region, and text rules;
43
+ - the list of things an app must not hand-build.
44
+
45
+ The recipe examples are generated from the recipe screens of the component catalogue
46
+ (`pnpm preview:components`, view «Recetas»). After a change to a recipe screen, run
47
+ `pnpm --filter @partrunner-ai/ui recipes`. `pnpm test` fails when the files are out of date.
48
+
49
+ To make an app's agents read it, add this line to the app's `AGENTS.md`:
50
+
51
+ ```md
52
+ - Before you write or change a screen, read `node_modules/@partrunner-ai/ui/DESIGN.md` and follow it.
53
+ ```
61
54
 
62
55
  Package code is licensed under MIT. Bundled Barlow and Bebas Neue font files
63
56
  are licensed under the SIL Open Font License 1.1 included in `styles/fonts`.