@app-studio/components 0.10.20 → 0.10.22
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/dist/index.d.ts +1 -0
- package/dist/native/components/Background/Background/Background.view.js +26 -9
- package/dist/native/components/Background/Background/Background.view.js.map +1 -1
- package/dist/native/components/Button/Button/Button.props.d.ts +1 -0
- package/dist/native/components/Button/Button/Button.view.js +11 -3
- package/dist/native/components/Button/Button/Button.view.js.map +1 -1
- package/dist/native/components/Button/Button/Button.view.native.js +8 -3
- package/dist/native/components/Button/Button/Button.view.native.js.map +1 -1
- package/dist/native/components/Button/Button.js +12 -1
- package/dist/native/components/Button/Button.js.map +1 -1
- package/dist/native/components/Form/Password/Password/Password.state.d.ts +4 -1759
- package/dist/native/components/Form/Password/Password/Password.state.js.map +1 -1
- package/dist/native/components/Slider/Slider/Slider.state.js +7 -4
- package/dist/native/components/Slider/Slider/Slider.state.js.map +1 -1
- package/dist/native/components/Toast/Toast/Toast.view.js +3 -3
- package/dist/native/components/Toast/Toast/Toast.view.js.map +1 -1
- package/dist/native/pages/designSystem.page.js +12 -10
- package/dist/native/pages/designSystem.page.js.map +1 -1
- package/dist/web.cjs.js +8 -8
- package/dist/web.cjs.js.map +1 -1
- package/dist/web.esm.js +1442 -1428
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.js +8 -8
- package/dist/web.umd.js.map +1 -1
- package/docs/design-system/llm-design-system.md +41 -9
- package/docs/design-system/theming.md +38 -0
- package/package.json +1 -1
|
@@ -17,15 +17,21 @@ is the **physics**.
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
## 0. TL;DR — the
|
|
20
|
+
## 0. TL;DR — the six rules that make a config coherent
|
|
21
21
|
|
|
22
22
|
1. **Stay vs adapt is decided by the value's *form*.**
|
|
23
23
|
- **Raw hex** (`"#2563eb"`) → **constant** in both modes. Use for brand identity.
|
|
24
24
|
- **`color-*` token** (`"color-black"`) → **flips** automatically. Use for structural neutrals.
|
|
25
|
+
- Corollary: **never branch on the mode to pick a color** (`isDark ? a : b`).
|
|
26
|
+
Both branches already flip, so a ternary double-inverts — or freezes if the
|
|
27
|
+
signal doesn't track the toggle. If you feel the need to branch, you picked
|
|
28
|
+
the wrong token form.
|
|
25
29
|
2. **Brand colors are FILLS, not foreground.** `theme-primary` paints a
|
|
26
30
|
background and pairs with `theme-onPrimary` ink. **Never** use `theme-primary`
|
|
27
31
|
as the text/border color of something sitting directly on a surface — for a
|
|
28
|
-
black/white brand it collides with the surface and vanishes.
|
|
32
|
+
black/white brand it collides with the surface and vanishes. And never compute
|
|
33
|
+
the ink with luminance math — read `theme-onPrimary`; it's the
|
|
34
|
+
contrast-validated slot.
|
|
29
35
|
3. **Surface-contrasting foreground uses neutrals.** Body text, borders,
|
|
30
36
|
dividers, helper text → `theme-text` / `theme-muted` / `theme-border` (or the
|
|
31
37
|
`color-*` neutrals). These flip with the surface, so they stay readable on any
|
|
@@ -33,12 +39,22 @@ is the **physics**.
|
|
|
33
39
|
4. **`primary` and `onPrimary` must use the *same form*.** Both hex, or both
|
|
34
40
|
`color-*`. That keeps the fill and its ink flipping together (or staying
|
|
35
41
|
together) so the label never disappears.
|
|
36
|
-
5. **
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
5. **Know where tokens resolve — and where they silently die.** The resolver runs
|
|
43
|
+
on component **props**, *including string props*: `border={`1px solid
|
|
44
|
+
${token}`}`, gradient and `boxShadow` strings all get embedded tokens
|
|
45
|
+
rewritten to `var(--…)`. Tokens die in exactly three places: **raw React
|
|
46
|
+
`style={{}}` objects** (bypass the resolver), **JS pre-resolution** through
|
|
47
|
+
static/light-only maps (the result freezes to the light value), and
|
|
48
|
+
**malformed tokens built by concatenation** (rule 6). This rule is about
|
|
49
|
+
*consuming* configs; it's also why neutrals must be tokens.
|
|
50
|
+
6. **Alpha is a token suffix, never blind concatenation.** `theme-primary-100` =
|
|
51
|
+
10 %, `color-blue-500-200` = 20 % (alpha 0–1000). Never append a second
|
|
52
|
+
suffix to an already-suffixed token (`color-gray-50-900-100` resolves against
|
|
53
|
+
a CSS variable that doesn't exist), and never concatenate onto a value of
|
|
54
|
+
unknown form (`${palette[0]}15` breaks the day the value is a token instead
|
|
55
|
+
of hex — route mixed-form values through a helper).
|
|
56
|
+
|
|
57
|
+
Everything below is an expansion of these six rules.
|
|
42
58
|
|
|
43
59
|
---
|
|
44
60
|
|
|
@@ -330,6 +346,7 @@ Run through every item — these map 1:1 to the failure modes this system has hi
|
|
|
330
346
|
- [ ] `onPrimary` contrasts `primary` ≥ 4.5:1.
|
|
331
347
|
- [ ] `primary` reads ≥ 3:1 on **both** white and black.
|
|
332
348
|
- [ ] **No `color-*` shade outside `50…900`.** No `920/950/960`.
|
|
349
|
+
- [ ] **`tokens.colors[].value` entries are hex** — they get embedded into gradients/charts where a token would break downstream.
|
|
333
350
|
- [ ] **No brand slot used as body ink**; body uses `text` / `muted`.
|
|
334
351
|
- [ ] **No `theme-primary` used as foreground-on-surface for a monochrome brand** (use `theme-text` / `theme-secondary`).
|
|
335
352
|
- [ ] Every font in `typography` is listed in `metadata.googleFontLinks`; the stack ends in a system fallback.
|
|
@@ -341,6 +358,8 @@ Run through every item — these map 1:1 to the failure modes this system has hi
|
|
|
341
358
|
|
|
342
359
|
## 9. Anti-patterns (do NOT do these)
|
|
343
360
|
|
|
361
|
+
Authoring a config:
|
|
362
|
+
|
|
344
363
|
| ❌ Anti-pattern | Why it breaks | ✅ Instead |
|
|
345
364
|
|----------------|---------------|-----------|
|
|
346
365
|
| `"text": "#111111"` | Frozen dark ink → invisible on dark canvas | `"text": "color-black"` |
|
|
@@ -349,8 +368,21 @@ Run through every item — these map 1:1 to the failure modes this system has hi
|
|
|
349
368
|
| `primary` hex + `onPrimary` `"color-white"` | Mismatched forms → label flips off the fill | Same form for both |
|
|
350
369
|
| `theme-primary` as outline/link color on a **black** brand | Collides with the surface, vanishes | `theme-text` or `theme-secondary` |
|
|
351
370
|
| Writing a separate `<brand>.dark.json` | Unnecessary; dark is derived | One config, adaptive tokens |
|
|
352
|
-
| Adding `appearance === 'dark' ? … : …` anywhere | The system flips for you via tokens | Use the right token form |
|
|
353
371
|
| `color-gray-950` | Invalid shade | `color-gray-900` |
|
|
372
|
+
| `tokens.colors[].value` holding a token | Palette values get embedded in gradients/charts | Hex only in `tokens.colors[].value` |
|
|
373
|
+
|
|
374
|
+
Consuming a config (component/page code) — each of these is a real production
|
|
375
|
+
failure we have hit:
|
|
376
|
+
|
|
377
|
+
| ❌ Anti-pattern | Why it breaks | ✅ Instead |
|
|
378
|
+
|----------------|---------------|-----------|
|
|
379
|
+
| `isDark ? 'color-gray-900' : 'color-gray-50'` | Both tokens already flip → the ternary double-inverts and picks the wrong one in dark | The single adaptive token |
|
|
380
|
+
| Branching colors on a signal that isn't the toggle (`identity.theme`, cached mode) | The branch freezes; the section desyncs from the rest of the page when the user toggles | Adaptive tokens; mode flags only for behavior (e.g. `reversed`) |
|
|
381
|
+
| Token inside raw `style={{ boxShadow: '… color-black-150' }}` | Raw `style` bypasses the resolver → declaration silently dropped | Move to the app-studio prop (`boxShadow={…}`) |
|
|
382
|
+
| Pre-resolving in JS (`normalizeToHex(theme.canvas)`) and rendering the result | Static maps are light-only → value frozen to light mode | Pass the token as a prop; `getColor` only for non-app-studio consumers (charts, canvas, svg) |
|
|
383
|
+
| `${palette[0]}15`, `hex + '80'`, `token + '-900'` on unknown-form values | Valid for only one form; double suffixes resolve to nonexistent variables — silent transparent | Single alpha suffix on a known token; a form-aware helper for mixed values |
|
|
384
|
+
| Luminance math / hardcoded `color-white` for button ink | Discards the contrast-validated `onPrimary`; NaNs on token input | `color="theme-onPrimary"` on a `theme-primary` fill |
|
|
385
|
+
| "Fixing" `border={`1px solid ${borderColor}`}` by pre-resolving it | Token-bearing **string props are valid** — the resolver rewrites them to `var(--…)` | Leave it (or use the `borderWidth`/`borderStyle`/`borderColor` prop triple) |
|
|
354
386
|
|
|
355
387
|
---
|
|
356
388
|
|
|
@@ -187,6 +187,44 @@ function Snippet() {
|
|
|
187
187
|
}
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
+
### 3.5 Where tokens resolve — and where they silently die
|
|
191
|
+
|
|
192
|
+
The resolver runs on **app-studio component props — including string props**.
|
|
193
|
+
`processStyleProperty` scans any string prop value for tokens and rewrites each
|
|
194
|
+
to `var(--…)`, so all of these are valid and flip per mode:
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
<View borderColor="theme-border" /> // plain prop
|
|
198
|
+
<View border={`1px solid ${borderColor}`} /> // token inside a shorthand string — VALID
|
|
199
|
+
<View background={`linear-gradient(90deg, ${palette0}, transparent)`} /> // token inside a gradient string — VALID
|
|
200
|
+
<View boxShadow={`0 10px 25px -5px color-black-300`} /> // token inside a shadow string — VALID
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Tokens die in exactly **three** places:
|
|
204
|
+
|
|
205
|
+
1. **Raw React `style={{}}` objects** (and any CSS emitted outside app-studio
|
|
206
|
+
props — `className` CSS, `<style>` strings, iframe-injected CSS). These
|
|
207
|
+
bypass the resolver; the token is invalid CSS and the whole declaration is
|
|
208
|
+
silently dropped. Symptom: missing shadow/background/border, no error.
|
|
209
|
+
2. **JS pre-resolution.** Resolving a token to a hex in JS (a static token→hex
|
|
210
|
+
map, a `normalizeToHex`-style helper, `getColorHex` cached at module scope)
|
|
211
|
+
produces the **light** value and freezes it — the rendered color never flips.
|
|
212
|
+
Pass the token through as a prop instead; call `useTheme().getColor` only for
|
|
213
|
+
non-app-studio consumers (charts, canvas, svg attributes), inside the
|
|
214
|
+
component so it tracks the live mode.
|
|
215
|
+
3. **Malformed tokens from concatenation.** A second alpha suffix on an
|
|
216
|
+
already-suffixed token (`color-gray-50-900` + `-100` → `color-gray-50-900-100`)
|
|
217
|
+
resolves against a CSS variable that does not exist; a suffix concatenated
|
|
218
|
+
onto a value of unknown form (`${palette[0]}15`) is valid for hex and broken
|
|
219
|
+
for tokens. Append a **single** alpha suffix to a **known** token; route
|
|
220
|
+
mixed-form values through a form-aware helper.
|
|
221
|
+
|
|
222
|
+
Corollary — the mode-branching trap: never pick a color with
|
|
223
|
+
`isDark ? tokenA : tokenB`. Both tokens already flip, so the ternary
|
|
224
|
+
double-inverts (or freezes, if the branching signal doesn't track the toggle).
|
|
225
|
+
Mode flags are for *behavior* (e.g. a Button's `reversed`), never for choosing
|
|
226
|
+
a color value.
|
|
227
|
+
|
|
190
228
|
---
|
|
191
229
|
|
|
192
230
|
## 4. Token reference
|