@flipova/foundation 2.2.1 → 2.4.0-beta.1
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/CHANGELOG.md +6 -0
- package/README.md +157 -156
- package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
- package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
- package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
- package/components/ui/accordion/AnimatedHeight.tsx +3 -15
- package/components/ui/accordion/AnimatedIcon.tsx +2 -9
- package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
- package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
- package/components/ui/accordion/index.tsx +71 -139
- package/components/ui/actionsheet/index.tsx +63 -105
- package/components/ui/alert/index.tsx +20 -50
- package/components/ui/alert-dialog/index.tsx +23 -48
- package/components/ui/avatar/index.tsx +32 -68
- package/components/ui/badge/index.tsx +18 -49
- package/components/ui/bottomsheet/index.tsx +20 -52
- package/components/ui/box/index.tsx +4 -9
- package/components/ui/box/index.web.tsx +3 -9
- package/components/ui/button/index.tsx +73 -109
- package/components/ui/calendar/creator.tsx +69 -30
- package/components/ui/calendar/index.tsx +81 -159
- package/components/ui/calendar/styles.tsx +10 -10
- package/components/ui/card/index.tsx +8 -9
- package/components/ui/card/index.web.tsx +4 -10
- package/components/ui/center/index.tsx +6 -11
- package/components/ui/center/index.web.tsx +3 -9
- package/components/ui/checkbox/index.tsx +46 -107
- package/components/ui/date-time-picker/creator.tsx +14 -1
- package/components/ui/date-time-picker/index.tsx +107 -156
- package/components/ui/date-time-picker/index.web.tsx +11 -33
- package/components/ui/date-time-picker/styles.tsx +5 -5
- package/components/ui/divider/index.tsx +5 -6
- package/components/ui/drawer/index.tsx +108 -128
- package/components/ui/fab/index.tsx +25 -68
- package/components/ui/flat-list/index.tsx +11 -8
- package/components/ui/form-control/index.tsx +49 -90
- package/components/ui/gluestack-ui-provider/config.ts +69 -2
- package/components/ui/gluestack-ui-provider/index.tsx +32 -12
- package/components/ui/gluestack-ui-provider/index.web.tsx +43 -16
- package/components/ui/gluestack-ui-provider/script.ts +13 -8
- package/components/ui/gluestack-ui-provider/theme-context.ts +36 -1
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +11 -4
- package/components/ui/grid/index.tsx +128 -165
- package/components/ui/grid/index.web.tsx +17 -19
- package/components/ui/grid/styles.tsx +1 -3
- package/components/ui/heading/index.tsx +146 -169
- package/components/ui/heading/index.web.tsx +7 -28
- package/components/ui/heading/styles.tsx +5 -5
- package/components/ui/hstack/index.tsx +16 -15
- package/components/ui/hstack/index.web.tsx +17 -17
- package/components/ui/hstack/styles.tsx +5 -5
- package/components/ui/icon/index.tsx +95 -486
- package/components/ui/icon/index.web.tsx +79 -439
- package/components/ui/image/index.tsx +13 -18
- package/components/ui/image-viewer/index.tsx +149 -221
- package/components/ui/image-viewer/index.web.tsx +88 -113
- package/components/ui/input/index.tsx +20 -33
- package/components/ui/link/index.tsx +16 -22
- package/components/ui/liquid-glass/index.tsx +19 -25
- package/components/ui/menu/index.tsx +44 -66
- package/components/ui/modal/index.tsx +70 -91
- package/components/ui/popover/index.tsx +102 -121
- package/components/ui/portal/index.tsx +5 -6
- package/components/ui/pressable/index.tsx +5 -9
- package/components/ui/progress/index.tsx +4 -11
- package/components/ui/radio/index.tsx +47 -83
- package/components/ui/select/index.tsx +38 -59
- package/components/ui/select/select-actionsheet.tsx +61 -108
- package/components/ui/skeleton/index.tsx +22 -43
- package/components/ui/skeleton/index.web.tsx +63 -75
- package/components/ui/slider/index.tsx +36 -56
- package/components/ui/spinner/index.tsx +1 -10
- package/components/ui/switch/index.tsx +6 -13
- package/components/ui/table/index.tsx +39 -102
- package/components/ui/table/index.web.tsx +41 -79
- package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
- package/components/ui/tabs/creator.tsx +32 -24
- package/components/ui/tabs/index.tsx +253 -309
- package/components/ui/text/index.tsx +23 -37
- package/components/ui/text/index.web.tsx +33 -35
- package/components/ui/text/styles.tsx +5 -5
- package/components/ui/textarea/index.tsx +24 -38
- package/components/ui/toast/index.tsx +47 -52
- package/components/ui/tooltip/index.tsx +12 -28
- package/components/ui/vstack/index.tsx +17 -17
- package/components/ui/vstack/index.web.tsx +17 -17
- package/components/ui/vstack/styles.tsx +5 -5
- package/design/canonical.index.txt +15 -1
- package/design/manifest.xml +2 -0
- package/design/schema.xsd +11 -0
- package/design/themes.xml +175 -2
- package/design/tools/design.js +15 -12
- package/design/tools/npm.js +4 -3
- package/design/tools/sources/.generate/config.py +60 -2
- package/dist/{chunk-RPLDFHEZ.mjs → chunk-2R66P5X5.mjs} +1907 -3130
- package/dist/chunk-2R66P5X5.mjs.map +1 -0
- package/dist/{chunk-JVHJUIXV.js → chunk-LCTFQJZM.js} +1909 -3129
- package/dist/chunk-LCTFQJZM.js.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +303 -291
- package/dist/index.mjs +1 -1
- package/dist/ui/index.d.mts +44 -3
- package/dist/ui/index.d.ts +44 -3
- package/dist/ui/index.js +303 -291
- package/dist/ui/index.mjs +1 -1
- package/package.json +12 -7
- package/dist/chunk-JVHJUIXV.js.map +0 -1
- package/dist/chunk-RPLDFHEZ.mjs.map +0 -1
package/design/themes.xml
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
default="light">
|
|
30
30
|
<items>
|
|
31
31
|
<!-- Light Theme -->
|
|
32
|
-
<theme id="light" mode="light">
|
|
32
|
+
<theme id="light" mode="light" variant="default">
|
|
33
33
|
<roleMap>
|
|
34
34
|
<role id="background">
|
|
35
35
|
<ref>$ref.tokens.color.gray.50</ref>
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
</roleMap>
|
|
116
116
|
</theme>
|
|
117
117
|
<!-- Dark Theme -->
|
|
118
|
-
<theme id="dark" mode="dark">
|
|
118
|
+
<theme id="dark" mode="dark" variant="default">
|
|
119
119
|
<roleMap>
|
|
120
120
|
<role id="background">
|
|
121
121
|
<ref>$ref.tokens.color.gray.900</ref>
|
|
@@ -200,5 +200,178 @@
|
|
|
200
200
|
</role>
|
|
201
201
|
</roleMap>
|
|
202
202
|
</theme>
|
|
203
|
+
<!-- Spring variant: a seasonal light/dark PAIR. Same roles, seasonal
|
|
204
|
+
greens, so the app can offer it as a theme and still honour the
|
|
205
|
+
light/dark mode the user picked. -->
|
|
206
|
+
<theme id="spring-light" mode="light" variant="spring">
|
|
207
|
+
<roleMap>
|
|
208
|
+
<role id="background">
|
|
209
|
+
<ref>$ref.tokens.color.success.50</ref>
|
|
210
|
+
</role>
|
|
211
|
+
<role id="foreground">
|
|
212
|
+
<ref>$ref.tokens.color.success.900</ref>
|
|
213
|
+
</role>
|
|
214
|
+
<role id="card">
|
|
215
|
+
<ref>$ref.tokens.color.white</ref>
|
|
216
|
+
</role>
|
|
217
|
+
<role id="card-foreground">
|
|
218
|
+
<ref>$ref.tokens.color.success.900</ref>
|
|
219
|
+
</role>
|
|
220
|
+
<role id="popover">
|
|
221
|
+
<ref>$ref.tokens.color.white</ref>
|
|
222
|
+
</role>
|
|
223
|
+
<role id="popover-foreground">
|
|
224
|
+
<ref>$ref.tokens.color.success.900</ref>
|
|
225
|
+
</role>
|
|
226
|
+
<role id="primary">
|
|
227
|
+
<ref>$ref.tokens.color.success.600</ref>
|
|
228
|
+
</role>
|
|
229
|
+
<role id="primary-foreground">
|
|
230
|
+
<ref>$ref.tokens.color.white</ref>
|
|
231
|
+
</role>
|
|
232
|
+
<role id="secondary">
|
|
233
|
+
<ref>$ref.tokens.color.success.500</ref>
|
|
234
|
+
</role>
|
|
235
|
+
<role id="secondary-foreground">
|
|
236
|
+
<ref>$ref.tokens.color.white</ref>
|
|
237
|
+
</role>
|
|
238
|
+
<role id="muted">
|
|
239
|
+
<ref>$ref.tokens.color.success.100</ref>
|
|
240
|
+
</role>
|
|
241
|
+
<role id="muted-foreground">
|
|
242
|
+
<ref>$ref.tokens.color.success.700</ref>
|
|
243
|
+
</role>
|
|
244
|
+
<role id="accent">
|
|
245
|
+
<ref>$ref.tokens.color.success.200</ref>
|
|
246
|
+
</role>
|
|
247
|
+
<role id="accent-foreground">
|
|
248
|
+
<ref>$ref.tokens.color.success.900</ref>
|
|
249
|
+
</role>
|
|
250
|
+
<role id="destructive">
|
|
251
|
+
<ref>$ref.tokens.color.error.600</ref>
|
|
252
|
+
</role>
|
|
253
|
+
<role id="destructive-foreground">
|
|
254
|
+
<ref>$ref.tokens.color.white</ref>
|
|
255
|
+
</role>
|
|
256
|
+
<role id="border">
|
|
257
|
+
<ref>$ref.tokens.color.success.200</ref>
|
|
258
|
+
</role>
|
|
259
|
+
<role id="input">
|
|
260
|
+
<ref>$ref.tokens.color.success.200</ref>
|
|
261
|
+
</role>
|
|
262
|
+
<role id="ring">
|
|
263
|
+
<ref>$ref.tokens.color.success.400</ref>
|
|
264
|
+
</role>
|
|
265
|
+
<role id="success">
|
|
266
|
+
<ref>$ref.tokens.color.success.600</ref>
|
|
267
|
+
</role>
|
|
268
|
+
<role id="success-foreground">
|
|
269
|
+
<ref>$ref.tokens.color.white</ref>
|
|
270
|
+
</role>
|
|
271
|
+
<role id="warning">
|
|
272
|
+
<ref>$ref.tokens.color.warning.600</ref>
|
|
273
|
+
</role>
|
|
274
|
+
<role id="warning-foreground">
|
|
275
|
+
<ref>$ref.tokens.color.white</ref>
|
|
276
|
+
</role>
|
|
277
|
+
<role id="error">
|
|
278
|
+
<ref>$ref.tokens.color.error.600</ref>
|
|
279
|
+
</role>
|
|
280
|
+
<role id="error-foreground">
|
|
281
|
+
<ref>$ref.tokens.color.white</ref>
|
|
282
|
+
</role>
|
|
283
|
+
<role id="info">
|
|
284
|
+
<ref>$ref.tokens.color.info.600</ref>
|
|
285
|
+
</role>
|
|
286
|
+
<role id="info-foreground">
|
|
287
|
+
<ref>$ref.tokens.color.white</ref>
|
|
288
|
+
</role>
|
|
289
|
+
</roleMap>
|
|
290
|
+
</theme>
|
|
291
|
+
<theme id="spring-dark" mode="dark" variant="spring">
|
|
292
|
+
<roleMap>
|
|
293
|
+
<role id="background">
|
|
294
|
+
<ref>$ref.tokens.color.success.950</ref>
|
|
295
|
+
</role>
|
|
296
|
+
<role id="foreground">
|
|
297
|
+
<ref>$ref.tokens.color.success.50</ref>
|
|
298
|
+
</role>
|
|
299
|
+
<role id="card">
|
|
300
|
+
<ref>$ref.tokens.color.success.900</ref>
|
|
301
|
+
</role>
|
|
302
|
+
<role id="card-foreground">
|
|
303
|
+
<ref>$ref.tokens.color.success.50</ref>
|
|
304
|
+
</role>
|
|
305
|
+
<role id="popover">
|
|
306
|
+
<ref>$ref.tokens.color.success.900</ref>
|
|
307
|
+
</role>
|
|
308
|
+
<role id="popover-foreground">
|
|
309
|
+
<ref>$ref.tokens.color.success.50</ref>
|
|
310
|
+
</role>
|
|
311
|
+
<role id="primary">
|
|
312
|
+
<ref>$ref.tokens.color.success.400</ref>
|
|
313
|
+
</role>
|
|
314
|
+
<role id="primary-foreground">
|
|
315
|
+
<ref>$ref.tokens.color.success.950</ref>
|
|
316
|
+
</role>
|
|
317
|
+
<role id="secondary">
|
|
318
|
+
<ref>$ref.tokens.color.success.300</ref>
|
|
319
|
+
</role>
|
|
320
|
+
<role id="secondary-foreground">
|
|
321
|
+
<ref>$ref.tokens.color.success.950</ref>
|
|
322
|
+
</role>
|
|
323
|
+
<role id="muted">
|
|
324
|
+
<ref>$ref.tokens.color.success.900</ref>
|
|
325
|
+
</role>
|
|
326
|
+
<role id="muted-foreground">
|
|
327
|
+
<ref>$ref.tokens.color.success.200</ref>
|
|
328
|
+
</role>
|
|
329
|
+
<role id="accent">
|
|
330
|
+
<ref>$ref.tokens.color.success.800</ref>
|
|
331
|
+
</role>
|
|
332
|
+
<role id="accent-foreground">
|
|
333
|
+
<ref>$ref.tokens.color.success.50</ref>
|
|
334
|
+
</role>
|
|
335
|
+
<role id="destructive">
|
|
336
|
+
<ref>$ref.tokens.color.error.500</ref>
|
|
337
|
+
</role>
|
|
338
|
+
<role id="destructive-foreground">
|
|
339
|
+
<ref>$ref.tokens.color.white</ref>
|
|
340
|
+
</role>
|
|
341
|
+
<role id="border">
|
|
342
|
+
<ref>$ref.tokens.color.success.800</ref>
|
|
343
|
+
</role>
|
|
344
|
+
<role id="input">
|
|
345
|
+
<ref>$ref.tokens.color.success.800</ref>
|
|
346
|
+
</role>
|
|
347
|
+
<role id="ring">
|
|
348
|
+
<ref>$ref.tokens.color.success.300</ref>
|
|
349
|
+
</role>
|
|
350
|
+
<role id="success">
|
|
351
|
+
<ref>$ref.tokens.color.success.400</ref>
|
|
352
|
+
</role>
|
|
353
|
+
<role id="success-foreground">
|
|
354
|
+
<ref>$ref.tokens.color.success.950</ref>
|
|
355
|
+
</role>
|
|
356
|
+
<role id="warning">
|
|
357
|
+
<ref>$ref.tokens.color.warning.400</ref>
|
|
358
|
+
</role>
|
|
359
|
+
<role id="warning-foreground">
|
|
360
|
+
<ref>$ref.tokens.color.success.950</ref>
|
|
361
|
+
</role>
|
|
362
|
+
<role id="error">
|
|
363
|
+
<ref>$ref.tokens.color.error.400</ref>
|
|
364
|
+
</role>
|
|
365
|
+
<role id="error-foreground">
|
|
366
|
+
<ref>$ref.tokens.color.success.950</ref>
|
|
367
|
+
</role>
|
|
368
|
+
<role id="info">
|
|
369
|
+
<ref>$ref.tokens.color.info.400</ref>
|
|
370
|
+
</role>
|
|
371
|
+
<role id="info-foreground">
|
|
372
|
+
<ref>$ref.tokens.color.success.950</ref>
|
|
373
|
+
</role>
|
|
374
|
+
</roleMap>
|
|
375
|
+
</theme>
|
|
203
376
|
</items>
|
|
204
377
|
</themes>
|
package/design/tools/design.js
CHANGED
|
@@ -83,8 +83,7 @@ const TARGETS = {
|
|
|
83
83
|
},
|
|
84
84
|
doc: {
|
|
85
85
|
script: 'docgen.py',
|
|
86
|
-
args: ['--manifest', MANIFEST, '--documentation', DOCUMENTATION,
|
|
87
|
-
'--root', REPO_ROOT, '--out', DOCS_OUT],
|
|
86
|
+
args: ['--manifest', MANIFEST, '--documentation', DOCUMENTATION, '--root', REPO_ROOT, '--out', DOCS_OUT],
|
|
88
87
|
},
|
|
89
88
|
pipeline: {
|
|
90
89
|
script: null,
|
|
@@ -111,22 +110,23 @@ function findPython() {
|
|
|
111
110
|
if (REPO_ROOT !== DESIGN_DIR) venvDirs.push(path.join(REPO_ROOT, 'design', 'tools', '.venv'));
|
|
112
111
|
|
|
113
112
|
for (const dir of venvDirs) {
|
|
114
|
-
const candidates =
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
const candidates =
|
|
114
|
+
process.platform === 'win32'
|
|
115
|
+
? [path.join(dir, 'Scripts', 'python.exe')]
|
|
116
|
+
: [path.join(dir, 'bin', 'python3'), path.join(dir, 'bin', 'python')];
|
|
117
117
|
for (const candidate of candidates) {
|
|
118
118
|
if (fs.existsSync(candidate)) return candidate;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
const pathExes = process.platform === 'win32'
|
|
123
|
-
? ['python.exe', 'python3.exe']
|
|
124
|
-
: ['python3', 'python'];
|
|
122
|
+
const pathExes = process.platform === 'win32' ? ['python.exe', 'python3.exe'] : ['python3', 'python'];
|
|
125
123
|
for (const exe of pathExes) {
|
|
126
124
|
try {
|
|
127
125
|
const probe = spawnSync(exe, ['-c', 'import lxml.etree'], { stdio: 'ignore' });
|
|
128
126
|
if (probe.status === 0) return exe;
|
|
129
|
-
} catch (_) {
|
|
127
|
+
} catch (_) {
|
|
128
|
+
/* not on PATH */
|
|
129
|
+
}
|
|
130
130
|
}
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
@@ -136,8 +136,10 @@ function main() {
|
|
|
136
136
|
const spec = TARGETS[target];
|
|
137
137
|
if (!spec) {
|
|
138
138
|
process.stderr.write(
|
|
139
|
-
'Unknown target: %s\nAvailable targets: %s\n'
|
|
140
|
-
.replace('%s',
|
|
139
|
+
'Unknown target: %s\nAvailable targets: %s\n'
|
|
140
|
+
.replace('%s', String(target))
|
|
141
|
+
.replace('%s', Object.keys(TARGETS).join(', ')),
|
|
142
|
+
);
|
|
141
143
|
process.exit(2);
|
|
142
144
|
}
|
|
143
145
|
|
|
@@ -170,7 +172,8 @@ function main() {
|
|
|
170
172
|
if (!python) {
|
|
171
173
|
process.stderr.write(
|
|
172
174
|
'No suitable Python found. Create the project venv or set FOUNDATION_PYTHON.\n' +
|
|
173
|
-
|
|
175
|
+
' C:/opt/Python38-32/python3.exe -m venv --without-pip --system-site-packages design/tools/.venv\n',
|
|
176
|
+
);
|
|
174
177
|
process.exit(2);
|
|
175
178
|
}
|
|
176
179
|
|
package/design/tools/npm.js
CHANGED
|
@@ -273,7 +273,7 @@ function adopt(force) {
|
|
|
273
273
|
process.stdout.write('\nNext steps:\n');
|
|
274
274
|
process.stdout.write(' 1. edit design/tokens.xml and design/themes.xml - that is now your design system\n');
|
|
275
275
|
process.stdout.write(' 2. npm run design:gen -> theme/config.ts + theme/tokens.js\n');
|
|
276
|
-
process.stdout.write(
|
|
276
|
+
process.stdout.write(" 3. tailwind.config.js -> require('./theme/tokens')\n");
|
|
277
277
|
process.stdout.write(' 4. wrap the app in <AppThemeProvider mode="system"> from ./theme/provider\n');
|
|
278
278
|
process.stdout.write(' 5. npm run design:verify -> the registries are in step with the artifacts\n');
|
|
279
279
|
}
|
|
@@ -335,10 +335,11 @@ function main() {
|
|
|
335
335
|
}
|
|
336
336
|
if (command === undefined) {
|
|
337
337
|
process.stderr.write(
|
|
338
|
-
'Usage: npx flipova-design <init|inject|adopt|where|gen|check|verify|canonical|lint|doc|edit|run|pipeline>\n'
|
|
338
|
+
'Usage: npx flipova-design <init|inject|adopt|where|gen|check|verify|canonical|lint|doc|edit|run|pipeline>\n',
|
|
339
|
+
);
|
|
339
340
|
process.exit(2);
|
|
340
341
|
}
|
|
341
342
|
runTool(command, args);
|
|
342
343
|
}
|
|
343
344
|
|
|
344
|
-
main();
|
|
345
|
+
main();
|
|
@@ -99,13 +99,65 @@ def theme_role_ids(man: ManifestModel) -> list[str]:
|
|
|
99
99
|
return reference
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
_JS_IDENT = re.compile(r"^[A-Za-z_$][A-Za-z0-9_$]*$")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _js_key(name: str) -> str:
|
|
106
|
+
"""Quote an object key unless it is a bare JS identifier.
|
|
107
|
+
|
|
108
|
+
A theme id is free-form ("spring-light", "high-contrast"), but `spring-light`
|
|
109
|
+
is not a valid unquoted object key: emitting it bare produces a syntax error.
|
|
110
|
+
"""
|
|
111
|
+
return name if _JS_IDENT.match(name) else "'" + name.replace("'", "\\'") + "'"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def theme_variants(man: ManifestModel) -> list[tuple[str, str, str]]:
|
|
115
|
+
"""[(variant, mode, theme_id), ...] in themes.xml order.
|
|
116
|
+
|
|
117
|
+
A variant is a light/dark PAIR, so the runtime can resolve a (variant, mode)
|
|
118
|
+
request to a theme id. The table is emitted rather than rebuilt at runtime so
|
|
119
|
+
a theme id never has to follow a naming convention: a variant may be spelled
|
|
120
|
+
`spring` with themes `spring-light`/`spring-dark`, or anything else at all.
|
|
121
|
+
"""
|
|
122
|
+
themes_path = man.ctx.catalog_files.get("themes")
|
|
123
|
+
if themes_path is None or not themes_path.exists():
|
|
124
|
+
raise SystemExit("manifest: no themes catalog file found")
|
|
125
|
+
root = etree.parse(str(themes_path)).getroot()
|
|
126
|
+
out: list[tuple[str, str, str]] = []
|
|
127
|
+
for theme in root.findall(q("items") + "/" + q("theme")):
|
|
128
|
+
tid = (theme.get("id") or "").strip()
|
|
129
|
+
mode = (theme.get("mode") or "").strip()
|
|
130
|
+
variant = (theme.get("variant") or "default").strip() or "default"
|
|
131
|
+
out.append((variant, mode, tid))
|
|
132
|
+
return out
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _render_variant_table(variants: list[tuple[str, str, str]]) -> list[str]:
|
|
136
|
+
"""`export const variants = { spring: { light: 'spring-light', ... } }`."""
|
|
137
|
+
ordered: dict[str, list[tuple[str, str]]] = {}
|
|
138
|
+
for variant, mode, tid in variants:
|
|
139
|
+
entries = ordered.setdefault(variant, [])
|
|
140
|
+
if any(m == mode for m, _ in entries):
|
|
141
|
+
raise SystemExit(
|
|
142
|
+
f"theme variant {variant!r} declares the mode {mode!r} twice: "
|
|
143
|
+
"a variant is a light/dark pair, so it has exactly one theme per mode"
|
|
144
|
+
)
|
|
145
|
+
entries.append((mode, tid))
|
|
146
|
+
lines = ["export const variants = {"]
|
|
147
|
+
for variant in sorted(ordered):
|
|
148
|
+
pairs = ", ".join(f"{_js_key(mode)}: '{tid}'" for mode, tid in sorted(ordered[variant]))
|
|
149
|
+
lines.append(f" {_js_key(variant)}: {{ {pairs} }},")
|
|
150
|
+
lines.append("};")
|
|
151
|
+
return lines
|
|
152
|
+
|
|
153
|
+
|
|
102
154
|
def render_gluestack_config(man: ManifestModel) -> str:
|
|
103
155
|
themes = theme_role_colours(man)
|
|
104
156
|
lines = list(_HEADER)
|
|
105
157
|
lines.append("// Raw color values (space-separated RGB) - edit design/themes.xml and regenerate")
|
|
106
158
|
lines.append("export const colors = {")
|
|
107
159
|
for tid, roles in themes:
|
|
108
|
-
lines.append(f" {tid}: {{")
|
|
160
|
+
lines.append(f" {_js_key(tid)}: {{")
|
|
109
161
|
for rid, triplet in roles:
|
|
110
162
|
lines.append(f" '--{rid}': '{triplet}',")
|
|
111
163
|
lines.append(" },")
|
|
@@ -114,6 +166,12 @@ def render_gluestack_config(man: ManifestModel) -> str:
|
|
|
114
166
|
lines.append("// Config for nativewind vars() - used by the provider")
|
|
115
167
|
lines.append("export const config = {")
|
|
116
168
|
for tid, _ in themes:
|
|
117
|
-
|
|
169
|
+
# Bracket access, always: a quoted key ("spring-light") is not valid
|
|
170
|
+
# after a dot, so `colors.something` would only work by luck.
|
|
171
|
+
lines.append(f" {_js_key(tid)}: vars(colors['{tid}']),")
|
|
118
172
|
lines.append("};")
|
|
173
|
+
lines.append("")
|
|
174
|
+
lines.append("// Theme variants: variant -> mode -> theme id, from the `variant` attribute in")
|
|
175
|
+
lines.append("// design/themes.xml. `default` holds the base light/dark pair.")
|
|
176
|
+
lines.extend(_render_variant_table(theme_variants(man)))
|
|
119
177
|
return "\n".join(lines) + "\n"
|