@chipmobilesdk/rn-theme 0.2.1 → 0.2.2
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/README.md +57 -4
- package/package.json +1 -1
- package/skills/sdk-rn-theme/SKILL.md +19 -1
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ StyleSheet.configure(
|
|
|
77
77
|
|
|
78
78
|
Import the setup module first in the app entrypoint.
|
|
79
79
|
|
|
80
|
-
## Theme Start Strategy
|
|
80
|
+
## Theme Start Strategy
|
|
81
81
|
|
|
82
82
|
Choose exactly one startup strategy.
|
|
83
83
|
|
|
@@ -93,9 +93,62 @@ System adaptive themes:
|
|
|
93
93
|
createUnistylesConfig(config, { adaptiveThemes: true });
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
Using `initialTheme` and `adaptiveThemes: true` together is invalid. Persisting a user theme preference, if needed, belongs in the consuming app.
|
|
97
|
-
|
|
98
|
-
##
|
|
96
|
+
Using `initialTheme` and `adaptiveThemes: true` together is invalid. Persisting a user theme preference, if needed, belongs in the consuming app.
|
|
97
|
+
|
|
98
|
+
## Unistyles 3 Style Authoring and TypeScript Diagnostics
|
|
99
|
+
|
|
100
|
+
### Style arrays and variants solve different problems
|
|
101
|
+
|
|
102
|
+
Unistyles 3 supports React Native's array syntax and recommends it when merging
|
|
103
|
+
independent styles because the array preserves merge order and each style's attached
|
|
104
|
+
Unistyles state:
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<View style={[styles.container, styles.emphasis]} />
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Do not merge Unistyles entries with object spread. After a stylesheet recalculation,
|
|
111
|
+
Unistyles may no longer know the intended override order.
|
|
112
|
+
|
|
113
|
+
Use `styles.useVariants(...)` instead when a finite component prop or state such as
|
|
114
|
+
`selected`, `disabled`, or `size` changes one or more style entries. Variants model
|
|
115
|
+
semantic component states; they are not a replacement for every style array.
|
|
116
|
+
|
|
117
|
+
If a valid array does not typecheck, inspect the inferred type of every entry. A member
|
|
118
|
+
may be a dynamic function that was not called, or TypeScript may have widened a mixed
|
|
119
|
+
stylesheet to an object/function union. Fix that inference instead of casting the array.
|
|
120
|
+
|
|
121
|
+
### Dynamic functions and inference
|
|
122
|
+
|
|
123
|
+
Unistyles supports static objects and dynamic functions, including both in one
|
|
124
|
+
stylesheet. Call a dynamic entry before passing it to a `style` prop, and pass only
|
|
125
|
+
serializable arguments:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<View style={[styles.container, styles.sized(width)]} />
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
If TypeScript widens sibling entries to a union such as
|
|
132
|
+
`UnistylesValues | ((...) => UnistylesValues)`, move the dynamic entries into a separate
|
|
133
|
+
`StyleSheet.create` call. This is a TypeScript inference workaround, not an Unistyles
|
|
134
|
+
runtime restriction. Prefer variants for a finite set of states and dynamic functions
|
|
135
|
+
for open-ended values such as a measured width.
|
|
136
|
+
|
|
137
|
+
### Localize vague TypeScript errors
|
|
138
|
+
|
|
139
|
+
Keep stylesheets at module scope. When TypeScript reports a vague error at every JSX
|
|
140
|
+
use instead of at the invalid style property, temporarily move the relevant
|
|
141
|
+
`StyleSheet.create` declaration above the component or extract the suspect entries into
|
|
142
|
+
a smaller stylesheet. This often makes inference fail at the actual initializer. It is
|
|
143
|
+
a debugging technique, not a required declaration order; the real runtime ordering rule
|
|
144
|
+
remains that `StyleSheet.configure` must run before importing themed components.
|
|
145
|
+
|
|
146
|
+
See the official Unistyles 3 guidance for
|
|
147
|
+
[merging styles](https://www.unistyl.es/v3/guides/merging-styles/),
|
|
148
|
+
[variants](https://www.unistyl.es/v3/references/variants/), and
|
|
149
|
+
[dynamic functions](https://www.unistyl.es/v3/references/dynamic-functions/).
|
|
150
|
+
|
|
151
|
+
## Public Runtime Exports
|
|
99
152
|
|
|
100
153
|
- `createUnistylesConfig(config, options?)`
|
|
101
154
|
- `generateLightPalette(brandColors)`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sdk-rn-theme
|
|
3
|
-
description: "Theming for @chipmobilesdk/rn-theme: brand palettes, Unistyles config, color/typography tokens, dark mode. Use when setting up theming, adding a design token, wiring light/dark, or debugging
|
|
3
|
+
description: "Theming for @chipmobilesdk/rn-theme: brand palettes, Unistyles config, color/typography tokens, dark mode, style composition, variants, and dynamic-style diagnostics. Use when setting up theming, adding a design token, wiring light/dark, or debugging Unistyles setup and type errors."
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@chipmobilesdk/rn-theme"
|
|
6
6
|
packageVersion: "0.2.0"
|
|
@@ -19,6 +19,7 @@ This is the single source of truth for color, typography, spacing and radius tok
|
|
|
19
19
|
- Adding or renaming a design token
|
|
20
20
|
- Wiring light/dark mode or a theme start strategy
|
|
21
21
|
- A screen renders unstyled, or `useStyles` returns an unexpected theme
|
|
22
|
+
- Style arrays, variants, or dynamic functions produce unexpected TypeScript errors
|
|
22
23
|
|
|
23
24
|
## Do not use this for
|
|
24
25
|
|
|
@@ -32,6 +33,22 @@ renders. Getting this wrong produces an app that renders with no styling and no
|
|
|
32
33
|
Read the `## Setup Order` and `## Theme Start Strategy` sections of the README before
|
|
33
34
|
changing entry-point wiring.
|
|
34
35
|
|
|
36
|
+
## Unistyles 3 authoring guardrails
|
|
37
|
+
|
|
38
|
+
- Merge independent styles with array syntax: `[styles.base, styles.extra]`. Do not
|
|
39
|
+
object-spread Unistyles entries. Variants are for finite semantic states such as
|
|
40
|
+
`selected`, `disabled`, or `size`, not a replacement for every array.
|
|
41
|
+
- Call dynamic style entries before passing them to a `style` prop, and use only
|
|
42
|
+
serializable arguments. Mixing static and dynamic entries is supported; if TypeScript
|
|
43
|
+
widens sibling entries into an object/function union, split the dynamic entries into a
|
|
44
|
+
separate stylesheet instead of casting.
|
|
45
|
+
- When an error is reported at many JSX usages, temporarily move the stylesheet above
|
|
46
|
+
the component or isolate suspect entries so the invalid initializer is diagnosed.
|
|
47
|
+
Treat this as a debugging technique, not a runtime ordering requirement.
|
|
48
|
+
|
|
49
|
+
Read `## Unistyles 3 Style Authoring and TypeScript Diagnostics` in the README for the
|
|
50
|
+
reasoning, examples, and upstream documentation links.
|
|
51
|
+
|
|
35
52
|
## Public API (v0.2.0)
|
|
36
53
|
|
|
37
54
|
Runtime:
|
|
@@ -56,4 +73,5 @@ Read only the section you need from
|
|
|
56
73
|
| Full export list | `## Public Runtime Exports`, `## Public Type Exports` |
|
|
57
74
|
| Config rejected at runtime | `## Configuration Validation` |
|
|
58
75
|
| Peer dependency rules | `## Compatibility`, `## Dependency Classification` |
|
|
76
|
+
| Style arrays, variants, or dynamic-style type errors | `## Unistyles 3 Style Authoring and TypeScript Diagnostics` |
|
|
59
77
|
| Upgrading across versions | `## Semver and Migration` |
|