@solidrt/components 0.0.21 → 0.0.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/AGENTS.md +17 -0
- package/README.md +35 -0
- package/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -85,6 +85,23 @@ Most components group props into two objects, plus top-level event handlers:
|
|
|
85
85
|
`setTheme({...})` merges a one-level-deep override. Default is dark. Color
|
|
86
86
|
tokens: `background`, `surface`, `surfaceAlt`, `text`, `textMuted`, `border`,
|
|
87
87
|
`primary`, `onPrimary`, `danger`, `scrim`.
|
|
88
|
+
- `policy` / `setPolicy` / `setPolicyResolver` / `defaultPolicyResolver` /
|
|
89
|
+
`densityScale` - shared REACTIVE behavior (theme answers "how does it look",
|
|
90
|
+
policy answers "how does it behave"). Derived from `@solidrt/core`'s
|
|
91
|
+
`capabilities`/`env` (touch vs. desktop, window size class, display scale).
|
|
92
|
+
Fields: `interaction` (`"touch" | "desktop" | "hybrid"`, gates hover vs.
|
|
93
|
+
long-press affordances), `density` (`"comfortable" | "compact" | "dense"`,
|
|
94
|
+
drives `densityScale()`: 1 / 0.85 / 0.7), `motion` (`"normal" | "reduced" |
|
|
95
|
+
"none"`), `focusRing` (boolean), `textScale`/`textWeightDelta` (Dynamic-Type
|
|
96
|
+
and low-DPI weight compensation, consumed by `Text`), `navigation`
|
|
97
|
+
(`"bottomTabs" | "rail" | "sidebar"`) and `layout` (`"singlePane" |
|
|
98
|
+
"twoPane"`, both recommendations derived from window size class). Read
|
|
99
|
+
`policy.*` directly (reactive getters, like `theme`); `setPolicy({ field:
|
|
100
|
+
value })` pins one field regardless of the derived value, `setPolicy({
|
|
101
|
+
field: undefined })` hands it back to the resolver; `setPolicyResolver(caps
|
|
102
|
+
=> Policies)` replaces the whole derivation for full custom control.
|
|
103
|
+
`Tooltip`, `Select`, `ContextMenu` fork on `policy.interaction`; `NavShell`
|
|
104
|
+
on `policy.navigation`; `SplitView` on `policy.layout`.
|
|
88
105
|
|
|
89
106
|
## Minimal app (verified to render)
|
|
90
107
|
|
package/README.md
CHANGED
|
@@ -28,6 +28,41 @@ setTheme({ color: { primary: "#ff2d55" } }) // override one token
|
|
|
28
28
|
|
|
29
29
|
The color tokens are `background` (window fill), `surface` (control/card fill), `surfaceAlt` (subtle raised/track fill), `text`, `textMuted`, `border`, `primary`, `onPrimary`, `danger`, and `scrim` (modal dim). Non-color tokens are `spacing`, `radius`, `borderWidth`, and `text` (font sizes), shared across presets.
|
|
30
30
|
|
|
31
|
+
## Policies
|
|
32
|
+
|
|
33
|
+
Theme answers "how does it look"; policies answer "how does it behave". Policies are a second reactive layer, derived from the platform facts in `@solidrt/core` (`capabilities`, `env`), so components adapt to touch vs. desktop, window size, and display without every app wiring that logic itself.
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import { policy, setPolicy, densityScale } from "@solidrt/components"
|
|
37
|
+
|
|
38
|
+
policy.interaction // touch vs. desktop affordances (hover, long-press, ...)
|
|
39
|
+
policy.density // control/spacing scale
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`policy` fields:
|
|
43
|
+
|
|
44
|
+
| Field | Type | Description |
|
|
45
|
+
| ----------------- | ---------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
46
|
+
| `interaction` | `"touch" \| "desktop" \| "hybrid"` | Which interaction affordances a component shows (hover states vs. long-press). |
|
|
47
|
+
| `density` | `"comfortable" \| "compact" \| "dense"` | Control/hit-target/spacing scale; see `densityScale()`. |
|
|
48
|
+
| `motion` | `"normal" \| "reduced" \| "none"` | Animation intensity. |
|
|
49
|
+
| `focusRing` | `boolean` | Whether focused controls draw a visible focus indicator. |
|
|
50
|
+
| `textScale` | `number` | Multiplier on type-scale font sizes; defaults to the OS text-scale preference. |
|
|
51
|
+
| `textWeightDelta` | `number` | Weight compensation (in steps of 100) for light-on-dark text on low-DPI displays. |
|
|
52
|
+
| `navigation` | `"bottomTabs" \| "rail" \| "sidebar"` | Recommended nav layout, derived from window size class. |
|
|
53
|
+
| `layout` | `"singlePane" \| "twoPane"` | Recommended single vs. two-pane layout, derived from window size class. |
|
|
54
|
+
|
|
55
|
+
Reads are reactive like `theme`, so a window resize or the first mouse move on a touch-capable device updates every consuming component live.
|
|
56
|
+
|
|
57
|
+
```jsx
|
|
58
|
+
setPolicy({ density: "compact" }) // pin a field, overriding the derived value
|
|
59
|
+
setPolicy({ density: undefined }) // hand it back to the resolver
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`setPolicyResolver((caps) => Policies)` replaces the whole system-derivation function for full custom control; `defaultPolicyResolver` is exported to wrap or extend instead of replacing it outright.
|
|
63
|
+
|
|
64
|
+
`densityScale()` is a reactive multiplier (1 / 0.85 / 0.7 for comfortable/compact/dense) driven by `policy.density`, used internally for spacing and hit-target sizing.
|
|
65
|
+
|
|
31
66
|
## Layout and style
|
|
32
67
|
|
|
33
68
|
Most components group their props into two objects:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidrt/components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Antoine van Wel",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@solidjs/signals": "2.0.0-beta.15",
|
|
21
|
-
"@solidrt/core": "0.0.
|
|
21
|
+
"@solidrt/core": "0.0.22"
|
|
22
22
|
}
|
|
23
23
|
}
|