@tristan2828/ui-foundation 3.1.2 → 3.2.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.
@@ -51,6 +51,13 @@ is right. Do not disable, skip, or work around it.
51
51
  - NEVER import `@tristan2828/ui-foundation/gateway` outside
52
52
  `src/api/gateway/`. Components and hooks call a gateway module through
53
53
  TanStack Query. (Enforced: no-restricted-imports.)
54
+ - NEVER add a database table or column without a comment. The migration
55
+ that creates it also runs `COMMENT ON TABLE` / `COMMENT ON COLUMN`,
56
+ saying what it holds in words someone with only database access can use:
57
+ units, what null means, which table an id points at. A second agent with
58
+ credentials and no repo reads the schema alone. Applies to an app with a
59
+ Postgres backend. (Enforced: `backend/scripts/check_db_comments.py`, run
60
+ by `scripts/check-backend-postgres.sh` after `alembic upgrade head`.)
54
61
  - NEVER let a backend-shaped response reach a component. Paginated data is
55
62
  `Page<T>`. Failures are `AppError`. Queries are `QuerySpec`. The gateway
56
63
  translates; nothing above it knows the wire format. (Enforced: gateway
@@ -8,16 +8,24 @@ composites don't grow that way; they are built against a real app's screen.
8
8
 
9
9
  ## Semantic tones
10
10
 
11
- Three tones carry meaning: **success**, **warning**, **destructive**. Grey
12
- is not a tone — it is the absence of one, and most values should stay grey.
11
+ Four tones carry meaning: **success**, **warning**, **destructive** and
12
+ **info**. Grey is not a tone — it is the absence of one, and most values
13
+ should stay grey.
14
+
15
+ The first three say good or bad. **Info** says neither: *notice this*,
16
+ without a verdict. It is for a state that is worth seeing but isn't good
17
+ news or bad news: in progress, new, scheduled, beta. If the honest answer
18
+ to "is this good?" is "neither, but it matters right now", it's info. If
19
+ the answer is "neither, and it doesn't", it's grey: info is still a
20
+ colour, and the "about a third" limit below counts it.
13
21
 
14
22
  Each tone has two kinds of token, and picking the wrong one is the single
15
23
  most common way to ship an unreadable label:
16
24
 
17
25
  | Token | For | Why it can't be the other one |
18
26
  |---|---|---|
19
- | `--success` / `--warning` / `--destructive` (+ `-foreground`) | a **solid fill**, always with white text on it | chosen to contrast with *white*, so on the page background it's too light in light mode |
20
- | `--success-text` / `--warning-text` / `--destructive-text` | the tone as **text, a border or an icon** on the page background | chosen to contrast with *the page*, so as a fill under white text it's needlessly dark |
27
+ | `--success` / `--warning` / `--destructive` / `--info` (+ `-foreground`) | a **solid fill**, always with white text on it | chosen to contrast with *white*, so on the page background it's too light in light mode |
28
+ | `--success-text` / `--warning-text` / `--destructive-text` / `--info-text` | the tone as **text, a border or an icon** on the page background | chosen to contrast with *the page*, so as a fill under white text it's needlessly dark |
21
29
 
22
30
  Only the `*-text` tokens are remapped in `.dark`. A solid fill keeps one
23
31
  shade in both themes, because it always carries white text and the page
@@ -25,20 +33,22 @@ behind it never enters the calculation.
25
33
 
26
34
  Measured ratios (WCAG 2.x, sRGB) are recorded next to each primitive in
27
35
  the package's `styles/theme.css`, and its `e2e/storybook-visual.spec.ts` re-checks all
28
- nine tone/style combinations with axe against the rendered DOM in both
36
+ twelve tone/style combinations with axe against the rendered DOM in both
29
37
  themes. **A new tone or style is not done until it appears in that story.**
30
38
 
31
39
  ## The three badge styles
32
40
 
33
41
  `Badge` ships each tone in three styles. They are not interchangeable:
34
42
 
35
- - **Outline** — `outline-success`, `outline-warning`, `outline-destructive`.
43
+ - **Outline** — `outline-success`, `outline-warning`, `outline-destructive`,
44
+ `outline-info`.
36
45
  The default choice, and the one proven across real columns. Quiet enough
37
46
  to repeat down 25 rows without the column becoming a wall of color.
38
- - **Tinted** — `tinted-success`, `tinted-warning`, `tinted-destructive`. A
47
+ - **Tinted** — `tinted-success`, `tinted-warning`, `tinted-destructive`,
48
+ `tinted-info`. A
39
49
  low-alpha wash of the tone with `*-text` on top. More presence than
40
50
  outline; use when the value is the point of the row, not a detail of it.
41
- - **Solid** — `success`, `warning`, `destructive`. The loudest. Use for one
51
+ - **Solid** — `success`, `warning`, `destructive`, `info`. The loudest. Use for one
42
52
  value that must be impossible to miss, rarely for a whole column: solid
43
53
  reads as an alert, and a column of alerts reads as noise.
44
54
 
@@ -75,7 +85,7 @@ Two rules that keep this honest:
75
85
 
76
86
  ## Categorical colour
77
87
 
78
- Tones say good or bad. A value that is merely *different* from its
88
+ Tones say good, bad or *notice this*. A value that is merely *different* from its
79
89
  neighbours — a genre, a team, a category — needs a different mechanism, and
80
90
  it is `--category-1` through `--category-8`.
81
91
 
@@ -98,7 +108,9 @@ Four things about them:
98
108
 
99
109
  - **The hues avoid red, green and amber**, which the tones already spend. A
100
110
  category drawn in red reads as "this one is bad" even when nothing is
101
- wrong.
111
+ wrong. Info's blue came later, and slots 1, 6 and 8 sit near it: a table
112
+ that shows an info badge keeps its categories off those three, so a blue
113
+ genre isn't read as "notice this".
102
114
  - **They are ordered by distinctness, not by hue angle.** An app using
103
115
  three categories gets three obviously different colours. Past about five,
104
116
  hue alone stops separating them — slots 3 and 7 are both yellow-greens —
@@ -1,7 +1,7 @@
1
1
  import { useRender } from "@base-ui/react/use-render";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const badgeVariants: (props?: ({
4
- variant?: "link" | "success" | "default" | "outline" | "secondary" | "ghost" | "destructive" | "warning" | "outline-success" | "outline-warning" | "outline-destructive" | "tinted-success" | "tinted-warning" | "tinted-destructive" | null | undefined;
4
+ variant?: "link" | "success" | "default" | "outline" | "secondary" | "ghost" | "destructive" | "warning" | "info" | "outline-success" | "outline-warning" | "outline-info" | "outline-destructive" | "tinted-success" | "tinted-warning" | "tinted-info" | "tinted-destructive" | null | undefined;
5
5
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
6
  declare function Badge({ className, variant, render, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
7
7
  export { Badge, badgeVariants };
@@ -10,14 +10,16 @@ const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-cent
10
10
  destructive: "bg-destructive text-destructive-foreground focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/90",
11
11
  success: "bg-success text-success-foreground focus-visible:ring-success/20 dark:focus-visible:ring-success/40 [a]:hover:bg-success/90",
12
12
  warning: "bg-warning text-warning-foreground focus-visible:ring-warning/20 dark:focus-visible:ring-warning/40 [a]:hover:bg-warning/90",
13
+ info: "bg-info text-info-foreground focus-visible:ring-info/20 dark:focus-visible:ring-info/40 [a]:hover:bg-info/90",
13
14
  outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
14
- // Three tones x three styles. The *-text tokens, never the solid
15
+ // Four tones x three styles. The *-text tokens, never the solid
15
16
  // fill tokens: `border-destructive`/`text-destructive` would use
16
17
  // the shade chosen to carry white text, which is too light to read
17
18
  // against the page in light mode and too dark in dark mode. See
18
19
  // styles/theme.css and conventions/docs/design-language.md.
19
20
  "outline-success": "border-success-text text-success-text",
20
21
  "outline-warning": "border-warning-text text-warning-text",
22
+ "outline-info": "border-info-text text-info-text",
21
23
  "outline-destructive": "border-destructive-text text-destructive-text",
22
24
  // The fill is the solid token at low alpha (a wash of the tone),
23
25
  // while the text is the *-text shade — mixing the two is the point.
@@ -25,6 +27,7 @@ const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-cent
25
27
  // against a near-black page.
26
28
  "tinted-success": "bg-success/15 text-success-text dark:bg-success/20",
27
29
  "tinted-warning": "bg-warning/15 text-warning-text dark:bg-warning/20",
30
+ "tinted-info": "bg-info/15 text-info-text dark:bg-info/20",
28
31
  "tinted-destructive": "bg-destructive/15 text-destructive-text dark:bg-destructive/20",
29
32
  ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
30
33
  link: "text-primary underline-offset-4 hover:underline",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/styles/index.css CHANGED
@@ -44,6 +44,9 @@
44
44
  --color-warning: var(--warning);
45
45
  --color-warning-foreground: var(--warning-foreground);
46
46
  --color-warning-text: var(--warning-text);
47
+ --color-info: var(--info);
48
+ --color-info-foreground: var(--info-foreground);
49
+ --color-info-text: var(--info-text);
47
50
  --color-category-1: var(--category-1);
48
51
  --color-category-2: var(--category-2);
49
52
  --color-category-3: var(--category-3);
package/styles/theme.css CHANGED
@@ -53,6 +53,9 @@
53
53
  --amber-700: oklch(0.555 0.163 48.998); /* white on it: 5.05 */
54
54
  --amber-800: oklch(0.47 0.14 48.998); /* on white: 7.20 */
55
55
  --amber-400: oklch(0.828 0.189 84.429); /* on near-black: 11.53 */
56
+ --blue-700: oklch(0.52 0.17 255); /* white on it: 5.59 */
57
+ --blue-800: oklch(0.45 0.15 255); /* on white: 7.54 */
58
+ --blue-400: oklch(0.75 0.12 255); /* on near-black: 8.90 */
56
59
  /*
57
60
  * Categorical slots. For values that differ from each other but are not
58
61
  * better or worse than each other — a genre, a team, a category. Tones
@@ -65,7 +68,8 @@
65
68
  *
66
69
  * Hues avoid the red and green bands that destructive/success already
67
70
  * spend, and the amber that warning does — a category drawn in red reads
68
- * as "bad". They are ordered by distinctness, not by hue angle, so an app
71
+ * as "bad". The blue slots (1, 6, 8) sit near info's hue, which came
72
+ * later: a table using info keeps its categories off those three. They are ordered by distinctness, not by hue angle, so an app
69
73
  * using only the first three gets three obviously different colours.
70
74
  * Past about five, hue alone stops separating them and the glyph has to
71
75
  * carry the meaning; see docs/design-language.md.
@@ -116,7 +120,9 @@
116
120
  --success-foreground: var(--white);
117
121
  --warning: var(--amber-700);
118
122
  --warning-foreground: var(--white);
119
- /* The three pairs above are a SOLID fill plus its own text color, and
123
+ --info: var(--blue-700);
124
+ --info-foreground: var(--white);
125
+ /* The four pairs above are a SOLID fill plus its own text color, and
120
126
  nothing else. Used as text or a border on the page's own background —
121
127
  an outline badge, a tinted chip, an icon tint — a fill shade is the
122
128
  wrong value: it was picked to carry white, not to read against the
@@ -125,6 +131,7 @@
125
131
  --destructive-text: var(--red-700);
126
132
  --success-text: var(--green-800);
127
133
  --warning-text: var(--amber-800);
134
+ --info-text: var(--blue-800);
128
135
  /* Categorical slots — a glyph tint, never a fill behind text. */
129
136
  --category-1: var(--category-1-700);
130
137
  --category-2: var(--category-2-700);
@@ -175,12 +182,15 @@
175
182
  --success-foreground: var(--white);
176
183
  --warning: var(--amber-700);
177
184
  --warning-foreground: var(--white);
185
+ --info: var(--blue-700);
186
+ --info-foreground: var(--white);
178
187
  /* Solid fills keep one shade in both themes — they always carry white
179
188
  text, so the page behind them never enters the calculation. Only the
180
189
  *-text shades flip, because those read against the page. */
181
190
  --destructive-text: var(--red-400);
182
191
  --success-text: var(--green-400);
183
192
  --warning-text: var(--amber-400);
193
+ --info-text: var(--blue-400);
184
194
  /* Categorical slots — lighter shades to read against the dark page. */
185
195
  --category-1: var(--category-1-400);
186
196
  --category-2: var(--category-2-400);