@chipmobilesdk/rn-theme 0.2.0 → 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 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
- ## Public Runtime Exports
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,9 +1,9 @@
1
1
  {
2
2
  "name": "@chipmobilesdk/rn-theme",
3
- "version": "0.2.0",
4
- "private": false,
5
- "license": "UNLICENSED",
6
- "main": "src/index.ts",
3
+ "version": "0.2.2",
4
+ "private": false,
5
+ "license": "UNLICENSED",
6
+ "main": "src/index.ts",
7
7
  "types": "src/index.ts",
8
8
  "exports": {
9
9
  ".": {
@@ -18,6 +18,7 @@
18
18
  "src/types",
19
19
  "src/unistyles",
20
20
  "src/utils",
21
+ "skills",
21
22
  "README.md",
22
23
  "CHANGELOG.md"
23
24
  ],
@@ -42,8 +43,8 @@
42
43
  "optional": false
43
44
  }
44
45
  },
45
- "publishConfig": {
46
- "access": "public",
47
- "registry": "https://registry.npmjs.org/"
48
- }
49
- }
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "registry": "https://registry.npmjs.org/"
49
+ }
50
+ }
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: sdk-rn-theme
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
+ metadata:
5
+ package: "@chipmobilesdk/rn-theme"
6
+ packageVersion: "0.2.0"
7
+ user-invocable: true
8
+ disable-model-invocation: false
9
+ ---
10
+
11
+ # @chipmobilesdk/rn-theme
12
+
13
+ Generates light and dark palettes from brand colors and produces a Unistyles config.
14
+ This is the single source of truth for color, typography, spacing and radius tokens.
15
+
16
+ ## Use this when
17
+
18
+ - Bootstrapping theming in a new app
19
+ - Adding or renaming a design token
20
+ - Wiring light/dark mode or a theme start strategy
21
+ - A screen renders unstyled, or `useStyles` returns an unexpected theme
22
+ - Style arrays, variants, or dynamic functions produce unexpected TypeScript errors
23
+
24
+ ## Do not use this for
25
+
26
+ - Chart-specific theming — that is `sdk-rn-chart` (`ChartThemeProvider`)
27
+ - Per-component one-off styles that do not belong in the token set
28
+
29
+ ## Setup order matters
30
+
31
+ Unistyles must be configured **before** the first component that consumes a style
32
+ renders. Getting this wrong produces an app that renders with no styling and no error.
33
+ Read the `## Setup Order` and `## Theme Start Strategy` sections of the README before
34
+ changing entry-point wiring.
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
+
52
+ ## Public API (v0.2.0)
53
+
54
+ Runtime:
55
+
56
+ - `generateLightPalette(brand)` / `generateDarkPalette(brand)` — derive full palettes
57
+ - `createUnistylesConfig(...)` — build the Unistyles configuration object
58
+
59
+ Types: `BrandColors`, `ThemeColors`, `TypographyConfig`, `TypographyToken`, `Typography`,
60
+ `StyleConfig`, `StyleTheme`, `DeepPartial`, `UnistylesThemeFromBrand`
61
+
62
+ Anything not exported from `src/index.ts` is private and may change without a major bump —
63
+ see `## Private Modules` and `## Semver and Migration` in the README.
64
+
65
+ ## Where the detail lives
66
+
67
+ Read only the section you need from
68
+ `node_modules/@chipmobilesdk/rn-theme/README.md`:
69
+
70
+ | Need | Section |
71
+ |---|---|
72
+ | Entry-point wiring | `## Setup Order`, `## Theme Start Strategy` |
73
+ | Full export list | `## Public Runtime Exports`, `## Public Type Exports` |
74
+ | Config rejected at runtime | `## Configuration Validation` |
75
+ | Peer dependency rules | `## Compatibility`, `## Dependency Classification` |
76
+ | Style arrays, variants, or dynamic-style type errors | `## Unistyles 3 Style Authoring and TypeScript Diagnostics` |
77
+ | Upgrading across versions | `## Semver and Migration` |