@react-native-styled-system/core 2.1.2 → 2.2.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.
@@ -1,8 +1,5 @@
1
1
  import type { ColorsValue, RadiiValue, SizesValue, SpaceValue, TypographyValue } from './Token';
2
2
 
3
- /*
4
- * Theme type from developer
5
- */
6
3
  export interface ThemedDict {
7
4
  space: Record<string | number, SpaceValue>;
8
5
  sizes: Record<string | number, SizesValue>;
@@ -11,6 +8,7 @@ export interface ThemedDict {
11
8
  typography: Record<string | number, TypographyValue>;
12
9
  breakpoints?: number[];
13
10
  }
11
+
14
12
  export const emptyThemedDict = {
15
13
  space: {},
16
14
  colors: {},
@@ -19,413 +17,3 @@ export const emptyThemedDict = {
19
17
  typography: {},
20
18
  breakpoints: [],
21
19
  } satisfies ThemedDict;
22
-
23
- const defaultSpace: Record<string, SpaceValue> = {
24
- '0': 0,
25
- 'px': 1,
26
- '0.5': 2,
27
- '1': 4,
28
- '2': 8,
29
- '3': 12,
30
- '4': 16,
31
- '5': 20,
32
- '6': 24,
33
- '7': 28,
34
- '8': 32,
35
- '9': 36,
36
- '10': 40,
37
- '12': 48,
38
- '14': 56,
39
- '16': 64,
40
- '20': 80,
41
- '24': 96,
42
- '32': 128,
43
- '40': 160,
44
- '48': 192,
45
- };
46
-
47
- const defaultColors: Record<string, ColorsValue> = {
48
- 'white': '#FFFFFF',
49
- 'black': '#000000',
50
- 'transparent': 'transparent',
51
-
52
- 'slate.50': '#f8fafc',
53
- 'slate.100': '#f1f5f9',
54
- 'slate.200': '#e2e8f0',
55
- 'slate.300': '#cad5e2',
56
- 'slate.400': '#90a1b9',
57
- 'slate.500': '#62748e',
58
- 'slate.600': '#45556c',
59
- 'slate.700': '#314158',
60
- 'slate.800': '#1d293d',
61
- 'slate.900': '#0f172b',
62
- 'slate.950': '#020618',
63
-
64
- 'gray.50': '#f9fafb',
65
- 'gray.100': '#f3f4f6',
66
- 'gray.200': '#e5e7eb',
67
- 'gray.300': '#d1d5dc',
68
- 'gray.400': '#99a1af',
69
- 'gray.500': '#6a7282',
70
- 'gray.600': '#4a5565',
71
- 'gray.700': '#364153',
72
- 'gray.800': '#1e2939',
73
- 'gray.900': '#101828',
74
- 'gray.950': '#030712',
75
-
76
- 'zinc.50': '#fafafa',
77
- 'zinc.100': '#f4f4f5',
78
- 'zinc.200': '#e4e4e7',
79
- 'zinc.300': '#d4d4d8',
80
- 'zinc.400': '#9f9fa9',
81
- 'zinc.500': '#71717b',
82
- 'zinc.600': '#52525c',
83
- 'zinc.700': '#3f3f46',
84
- 'zinc.800': '#27272a',
85
- 'zinc.900': '#18181b',
86
- 'zinc.950': '#09090b',
87
-
88
- 'neutral.50': '#fafafa',
89
- 'neutral.100': '#f5f5f5',
90
- 'neutral.200': '#e5e5e5',
91
- 'neutral.300': '#d4d4d4',
92
- 'neutral.400': '#a1a1a1',
93
- 'neutral.500': '#737373',
94
- 'neutral.600': '#525252',
95
- 'neutral.700': '#404040',
96
- 'neutral.800': '#262626',
97
- 'neutral.900': '#171717',
98
- 'neutral.950': '#0a0a0a',
99
-
100
- 'stone.50': '#fafaf9',
101
- 'stone.100': '#f5f5f4',
102
- 'stone.200': '#e7e5e4',
103
- 'stone.300': '#d7d3d1',
104
- 'stone.400': '#a6a09b',
105
- 'stone.500': '#79716b',
106
- 'stone.600': '#57534d',
107
- 'stone.700': '#44403b',
108
- 'stone.800': '#292524',
109
- 'stone.900': '#1c1917',
110
- 'stone.950': '#0c0a09',
111
-
112
- 'red.50': '#fef2f2',
113
- 'red.100': '#ffe2e2',
114
- 'red.200': '#ffc9c9',
115
- 'red.300': '#ffa2a2',
116
- 'red.400': '#ff6467',
117
- 'red.500': '#fb2c36',
118
- 'red.600': '#e7000b',
119
- 'red.700': '#c10007',
120
- 'red.800': '#9f0712',
121
- 'red.900': '#82181a',
122
- 'red.950': '#460809',
123
-
124
- 'orange.50': '#fff7ed',
125
- 'orange.100': '#ffedd4',
126
- 'orange.200': '#ffd6a7',
127
- 'orange.300': '#ffb869',
128
- 'orange.400': '#ff8903',
129
- 'orange.500': '#ff6900',
130
- 'orange.600': '#f54900',
131
- 'orange.700': '#ca3500',
132
- 'orange.800': '#9f2d00',
133
- 'orange.900': '#7e2a0c',
134
- 'orange.950': '#441306',
135
-
136
- 'amber.50': '#fffbeb',
137
- 'amber.100': '#fef3c6',
138
- 'amber.200': '#fee685',
139
- 'amber.300': '#ffd230',
140
- 'amber.400': '#ffb900',
141
- 'amber.500': '#fe9a00',
142
- 'amber.600': '#e17100',
143
- 'amber.700': '#bb4d00',
144
- 'amber.800': '#973c00',
145
- 'amber.900': '#7b3306',
146
- 'amber.950': '#461901',
147
-
148
- 'yellow.50': '#fefce8',
149
- 'yellow.100': '#fef9c2',
150
- 'yellow.200': '#fff085',
151
- 'yellow.300': '#ffdf20',
152
- 'yellow.400': '#fdc700',
153
- 'yellow.500': '#f0b100',
154
- 'yellow.600': '#d08700',
155
- 'yellow.700': '#a65f00',
156
- 'yellow.800': '#894b00',
157
- 'yellow.900': '#733e0a',
158
- 'yellow.950': '#432004',
159
-
160
- 'lime.50': '#f7fee7',
161
- 'lime.100': '#ecfcca',
162
- 'lime.200': '#d8f999',
163
- 'lime.300': '#bbf451',
164
- 'lime.400': '#9ae600',
165
- 'lime.500': '#7ccf00',
166
- 'lime.600': '#5ea500',
167
- 'lime.700': '#497d00',
168
- 'lime.800': '#3d6300',
169
- 'lime.900': '#35530e',
170
- 'lime.950': '#192e03',
171
-
172
- 'green.50': '#f0fdf4',
173
- 'green.100': '#dcfce7',
174
- 'green.200': '#b9f8cf',
175
- 'green.300': '#7bf1a7',
176
- 'green.400': '#06df72',
177
- 'green.500': '#00c950',
178
- 'green.600': '#00a63e',
179
- 'green.700': '#008235',
180
- 'green.800': '#026630',
181
- 'green.900': '#0d542b',
182
- 'green.950': '#032e15',
183
-
184
- 'emerald.50': '#ecfdf5',
185
- 'emerald.100': '#d0fae5',
186
- 'emerald.200': '#a4f4cf',
187
- 'emerald.300': '#5ee9b5',
188
- 'emerald.400': '#00d492',
189
- 'emerald.500': '#00bc7d',
190
- 'emerald.600': '#009966',
191
- 'emerald.700': '#007a55',
192
- 'emerald.800': '#006045',
193
- 'emerald.900': '#004f3b',
194
- 'emerald.950': '#002c22',
195
-
196
- 'teal.50': '#f0fdfa',
197
- 'teal.100': '#cbfbf1',
198
- 'teal.200': '#96f7e4',
199
- 'teal.300': '#46ecd4',
200
- 'teal.400': '#00d5bd',
201
- 'teal.500': '#00bba7',
202
- 'teal.600': '#009689',
203
- 'teal.700': '#00786f',
204
- 'teal.800': '#005f5a',
205
- 'teal.900': '#0b4f4a',
206
- 'teal.950': '#022f2e',
207
-
208
- 'cyan.50': '#ecfeff',
209
- 'cyan.100': '#cefafe',
210
- 'cyan.200': '#a2f4fd',
211
- 'cyan.300': '#53eafd',
212
- 'cyan.400': '#00d3f2',
213
- 'cyan.500': '#00b8db',
214
- 'cyan.600': '#0092b8',
215
- 'cyan.700': '#007595',
216
- 'cyan.800': '#005f78',
217
- 'cyan.900': '#104e64',
218
- 'cyan.950': '#053345',
219
-
220
- 'sky.50': '#f0f9ff',
221
- 'sky.100': '#dff2fe',
222
- 'sky.200': '#b8e6fe',
223
- 'sky.300': '#74d4ff',
224
- 'sky.400': '#00bcff',
225
- 'sky.500': '#00a6f4',
226
- 'sky.600': '#0084d1',
227
- 'sky.700': '#0069a8',
228
- 'sky.800': '#00598a',
229
- 'sky.900': '#024a70',
230
- 'sky.950': '#052f4a',
231
-
232
- 'blue.50': '#eff6ff',
233
- 'blue.100': '#dbeafe',
234
- 'blue.200': '#bedbff',
235
- 'blue.300': '#8ec5ff',
236
- 'blue.400': '#51a2ff',
237
- 'blue.500': '#2b7fff',
238
- 'blue.600': '#155dfb',
239
- 'blue.700': '#1447e6',
240
- 'blue.800': '#193cb8',
241
- 'blue.900': '#1c398e',
242
- 'blue.950': '#162556',
243
-
244
- 'indigo.50': '#eef2ff',
245
- 'indigo.100': '#e0e7ff',
246
- 'indigo.200': '#c7d2ff',
247
- 'indigo.300': '#a3b3ff',
248
- 'indigo.400': '#7c86ff',
249
- 'indigo.500': '#615fff',
250
- 'indigo.600': '#4f39f6',
251
- 'indigo.700': '#432dd7',
252
- 'indigo.800': '#372aac',
253
- 'indigo.900': '#312c85',
254
- 'indigo.950': '#1e1a4d',
255
-
256
- 'violet.50': '#f5f3ff',
257
- 'violet.100': '#ede9fe',
258
- 'violet.200': '#ddd6ff',
259
- 'violet.300': '#c4b4ff',
260
- 'violet.400': '#a684ff',
261
- 'violet.500': '#8e51ff',
262
- 'violet.600': '#7f22fe',
263
- 'violet.700': '#7008e7',
264
- 'violet.800': '#5d0ec0',
265
- 'violet.900': '#4d179a',
266
- 'violet.950': '#2f0d68',
267
-
268
- 'purple.50': '#faf5ff',
269
- 'purple.100': '#f3e8ff',
270
- 'purple.200': '#e9d4ff',
271
- 'purple.300': '#dab2ff',
272
- 'purple.400': '#c27aff',
273
- 'purple.500': '#ad46ff',
274
- 'purple.600': '#9810fa',
275
- 'purple.700': '#8200db',
276
- 'purple.800': '#6e11b0',
277
- 'purple.900': '#59168b',
278
- 'purple.950': '#3c0366',
279
-
280
- 'fuchsia.50': '#fdf4ff',
281
- 'fuchsia.100': '#fae8ff',
282
- 'fuchsia.200': '#f6cfff',
283
- 'fuchsia.300': '#f4a8ff',
284
- 'fuchsia.400': '#ed6aff',
285
- 'fuchsia.500': '#e12afb',
286
- 'fuchsia.600': '#c800de',
287
- 'fuchsia.700': '#a800b7',
288
- 'fuchsia.800': '#8a0194',
289
- 'fuchsia.900': '#721378',
290
- 'fuchsia.950': '#4b004f',
291
-
292
- 'pink.50': '#fdf2f8',
293
- 'pink.100': '#fce7f3',
294
- 'pink.200': '#fccee8',
295
- 'pink.300': '#fea5d5',
296
- 'pink.400': '#fb64b6',
297
- 'pink.500': '#f6339a',
298
- 'pink.600': '#e60076',
299
- 'pink.700': '#c6005b',
300
- 'pink.800': '#a3004c',
301
- 'pink.900': '#861043',
302
- 'pink.950': '#510424',
303
-
304
- 'rose.50': '#fff1f2',
305
- 'rose.100': '#ffe4e6',
306
- 'rose.200': '#ffccd2',
307
- 'rose.300': '#ffa1ad',
308
- 'rose.400': '#ff637e',
309
- 'rose.500': '#ff2056',
310
- 'rose.600': '#ec003f',
311
- 'rose.700': '#c70036',
312
- 'rose.800': '#a50036',
313
- 'rose.900': '#8b0836',
314
- 'rose.950': '#4d0218',
315
- };
316
-
317
- const defaultRadii: Record<string, RadiiValue> = {
318
- 'none': 0,
319
- 'sm': 4,
320
- 'md': 8,
321
- 'lg': 12,
322
- 'xl': 16,
323
- '2xl': 24,
324
- 'full': 9999,
325
- };
326
-
327
- const defaultTypography: Record<string, TypographyValue> = {
328
- h1: { fontSize: 32, fontWeight: 'bold', lineHeight: 40 },
329
- h2: { fontSize: 24, fontWeight: 'bold', lineHeight: 32 },
330
- h3: { fontSize: 20, fontWeight: '600', lineHeight: 28 },
331
- body: { fontSize: 16, lineHeight: 24 },
332
- caption: { fontSize: 14, lineHeight: 20 },
333
- small: { fontSize: 12, lineHeight: 16 },
334
- };
335
-
336
- const grayScales = ['slate', 'gray', 'zinc', 'neutral', 'stone'] as const;
337
-
338
- export type BaseColor = (typeof grayScales)[number];
339
-
340
- export type ThemeColor =
341
- | BaseColor
342
- | 'red'
343
- | 'orange'
344
- | 'amber'
345
- | 'yellow'
346
- | 'lime'
347
- | 'green'
348
- | 'emerald'
349
- | 'teal'
350
- | 'cyan'
351
- | 'sky'
352
- | 'blue'
353
- | 'indigo'
354
- | 'violet'
355
- | 'purple'
356
- | 'fuchsia'
357
- | 'pink'
358
- | 'rose';
359
-
360
- export const createThemeColors = ({ base, theme }: { base: BaseColor; theme: ThemeColor }) => {
361
- const b = (shade: number) => defaultColors[`${base}.${shade}`]!;
362
- const t = (shade: number) => defaultColors[`${theme}.${shade}`]!;
363
- const isGray = (grayScales as readonly string[]).includes(theme);
364
-
365
- const light: Record<string, ColorsValue> = {
366
- 'background': '#FFFFFF',
367
- 'foreground': b(950),
368
- 'card': '#FFFFFF',
369
- 'card-foreground': b(950),
370
- 'popover': '#FFFFFF',
371
- 'popover-foreground': b(950),
372
- 'primary': isGray ? t(900) : t(600),
373
- 'primary-foreground': isGray ? t(50) : '#FFFFFF',
374
- 'secondary': b(100),
375
- 'secondary-foreground': b(900),
376
- 'muted': b(100),
377
- 'muted-foreground': b(500),
378
- 'accent': b(100),
379
- 'accent-foreground': b(900),
380
- 'destructive': defaultColors['red.600']!,
381
- 'destructive-foreground': b(50),
382
- 'border': b(200),
383
- 'input': b(200),
384
- 'ring': isGray ? b(400) : t(400),
385
- 'chart-1': defaultColors['orange.600']!,
386
- 'chart-2': defaultColors['teal.600']!,
387
- 'chart-3': defaultColors['cyan.900']!,
388
- 'chart-4': defaultColors['amber.400']!,
389
- 'chart-5': defaultColors['amber.500']!,
390
- };
391
-
392
- const dark: Record<string, ColorsValue> = {
393
- 'background': b(950),
394
- 'foreground': b(50),
395
- 'card': b(900),
396
- 'card-foreground': b(50),
397
- 'popover': b(900),
398
- 'popover-foreground': b(50),
399
- 'primary': isGray ? t(200) : t(500),
400
- 'primary-foreground': isGray ? t(900) : '#FFFFFF',
401
- 'secondary': b(800),
402
- 'secondary-foreground': b(50),
403
- 'muted': b(800),
404
- 'muted-foreground': b(400),
405
- 'accent': b(800),
406
- 'accent-foreground': b(50),
407
- 'destructive': defaultColors['red.400']!,
408
- 'destructive-foreground': b(50),
409
- 'border': b(800),
410
- 'input': b(800),
411
- 'ring': isGray ? b(500) : t(500),
412
- 'chart-1': defaultColors['blue.700']!,
413
- 'chart-2': defaultColors['emerald.500']!,
414
- 'chart-3': defaultColors['amber.500']!,
415
- 'chart-4': defaultColors['purple.500']!,
416
- 'chart-5': defaultColors['rose.500']!,
417
- };
418
-
419
- return { light, dark };
420
- };
421
-
422
- const defaultSemanticColors = createThemeColors({ base: 'neutral', theme: 'neutral' });
423
-
424
- export const defaultTheme = {
425
- space: defaultSpace,
426
- sizes: { ...defaultSpace, full: '100%' as const, half: '50%' as const },
427
- colors: { ...defaultColors, ...defaultSemanticColors.light },
428
- radii: defaultRadii,
429
- typography: defaultTypography,
430
- breakpoints: [480, 768, 1024],
431
- } satisfies ThemedDict;
package/src/index.ts CHANGED
@@ -8,4 +8,3 @@ export * from './hook/useSxTokens';
8
8
  export * from './provider/StyledSystemProvider';
9
9
  export * from './util/propsToThemedStyle';
10
10
  export * from './util/createSxComponent';
11
- export * from './util/createTheme';
@@ -1,10 +1,10 @@
1
1
  import type { PropsWithChildren } from 'react';
2
2
  import React from 'react';
3
3
  import { useWindowDimensions } from 'react-native';
4
+ import { createTheme } from '@react-native-styled-system/util';
4
5
 
5
6
  import type { ThemedDict } from '../@types/ThemedDict';
6
7
  import { emptyThemedDict } from '../@types/ThemedDict';
7
- import { createTheme } from '../util/createTheme';
8
8
 
9
9
  export type StyledSystemContextValue = {
10
10
  theme: ThemedDict;
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createTheme = createTheme;
7
- function createTheme(baseOrConfig = {}, overrides) {
8
- if (overrides !== undefined) {
9
- return {
10
- colors: {
11
- ...baseOrConfig.colors,
12
- ...overrides.colors
13
- },
14
- space: {
15
- ...baseOrConfig.space,
16
- ...overrides.space
17
- },
18
- sizes: {
19
- ...baseOrConfig.sizes,
20
- ...overrides.sizes
21
- },
22
- radii: {
23
- ...baseOrConfig.radii,
24
- ...overrides.radii
25
- },
26
- typography: {
27
- ...baseOrConfig.typography,
28
- ...overrides.typography
29
- },
30
- breakpoints: overrides.breakpoints ?? baseOrConfig.breakpoints ?? []
31
- };
32
- }
33
- return {
34
- colors: {},
35
- space: {},
36
- sizes: {},
37
- radii: {},
38
- typography: {},
39
- breakpoints: [],
40
- ...baseOrConfig
41
- };
42
- }
43
- //# sourceMappingURL=createTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createTheme","baseOrConfig","overrides","undefined","colors","space","sizes","radii","typography","breakpoints"],"sourceRoot":"../../../src","sources":["util/createTheme.ts"],"mappings":";;;;;;AAIO,SAASA,WAAWA,CACzBC,YAAiC,GAAG,CAAC,CAAC,EACtCC,SAA+B,EACnB;EACZ,IAAIA,SAAS,KAAKC,SAAS,EAAE;IAC3B,OAAO;MACLC,MAAM,EAAE;QAAE,GAAGH,YAAY,CAACG,MAAM;QAAE,GAAGF,SAAS,CAACE;MAAO,CAAC;MACvDC,KAAK,EAAE;QAAE,GAAGJ,YAAY,CAACI,KAAK;QAAE,GAAGH,SAAS,CAACG;MAAM,CAAC;MACpDC,KAAK,EAAE;QAAE,GAAGL,YAAY,CAACK,KAAK;QAAE,GAAGJ,SAAS,CAACI;MAAM,CAAC;MACpDC,KAAK,EAAE;QAAE,GAAGN,YAAY,CAACM,KAAK;QAAE,GAAGL,SAAS,CAACK;MAAM,CAAC;MACpDC,UAAU,EAAE;QAAE,GAAGP,YAAY,CAACO,UAAU;QAAE,GAAGN,SAAS,CAACM;MAAW,CAAC;MACnEC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAIR,YAAY,CAACQ,WAAW,IAAI;IACpE,CAAC;EACH;EAEA,OAAO;IACLL,MAAM,EAAE,CAAC,CAAC;IACVC,KAAK,EAAE,CAAC,CAAC;IACTC,KAAK,EAAE,CAAC,CAAC;IACTC,KAAK,EAAE,CAAC,CAAC;IACTC,UAAU,EAAE,CAAC,CAAC;IACdC,WAAW,EAAE,EAAE;IACf,GAAGR;EACL,CAAC;AACH","ignoreList":[]}
@@ -1,37 +0,0 @@
1
- export function createTheme(baseOrConfig = {}, overrides) {
2
- if (overrides !== undefined) {
3
- return {
4
- colors: {
5
- ...baseOrConfig.colors,
6
- ...overrides.colors
7
- },
8
- space: {
9
- ...baseOrConfig.space,
10
- ...overrides.space
11
- },
12
- sizes: {
13
- ...baseOrConfig.sizes,
14
- ...overrides.sizes
15
- },
16
- radii: {
17
- ...baseOrConfig.radii,
18
- ...overrides.radii
19
- },
20
- typography: {
21
- ...baseOrConfig.typography,
22
- ...overrides.typography
23
- },
24
- breakpoints: overrides.breakpoints ?? baseOrConfig.breakpoints ?? []
25
- };
26
- }
27
- return {
28
- colors: {},
29
- space: {},
30
- sizes: {},
31
- radii: {},
32
- typography: {},
33
- breakpoints: [],
34
- ...baseOrConfig
35
- };
36
- }
37
- //# sourceMappingURL=createTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createTheme","baseOrConfig","overrides","undefined","colors","space","sizes","radii","typography","breakpoints"],"sourceRoot":"../../../src","sources":["util/createTheme.ts"],"mappings":"AAIA,OAAO,SAASA,WAAWA,CACzBC,YAAiC,GAAG,CAAC,CAAC,EACtCC,SAA+B,EACnB;EACZ,IAAIA,SAAS,KAAKC,SAAS,EAAE;IAC3B,OAAO;MACLC,MAAM,EAAE;QAAE,GAAGH,YAAY,CAACG,MAAM;QAAE,GAAGF,SAAS,CAACE;MAAO,CAAC;MACvDC,KAAK,EAAE;QAAE,GAAGJ,YAAY,CAACI,KAAK;QAAE,GAAGH,SAAS,CAACG;MAAM,CAAC;MACpDC,KAAK,EAAE;QAAE,GAAGL,YAAY,CAACK,KAAK;QAAE,GAAGJ,SAAS,CAACI;MAAM,CAAC;MACpDC,KAAK,EAAE;QAAE,GAAGN,YAAY,CAACM,KAAK;QAAE,GAAGL,SAAS,CAACK;MAAM,CAAC;MACpDC,UAAU,EAAE;QAAE,GAAGP,YAAY,CAACO,UAAU;QAAE,GAAGN,SAAS,CAACM;MAAW,CAAC;MACnEC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAIR,YAAY,CAACQ,WAAW,IAAI;IACpE,CAAC;EACH;EAEA,OAAO;IACLL,MAAM,EAAE,CAAC,CAAC;IACVC,KAAK,EAAE,CAAC,CAAC;IACTC,KAAK,EAAE,CAAC,CAAC;IACTC,KAAK,EAAE,CAAC,CAAC;IACTC,UAAU,EAAE,CAAC,CAAC;IACdC,WAAW,EAAE,EAAE;IACf,GAAGR;EACL,CAAC;AACH","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import type { ThemedDict } from '../@types/ThemedDict';
2
- export declare function createTheme(config?: Partial<ThemedDict>): ThemedDict;
3
- export declare function createTheme(base: ThemedDict, overrides: Partial<ThemedDict>): ThemedDict;
4
- //# sourceMappingURL=createTheme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../../../src/util/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACtE,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC"}
@@ -1,126 +0,0 @@
1
- import type { ThemedDict } from '../@types/ThemedDict';
2
- import { defaultTheme } from '../@types/ThemedDict';
3
-
4
- import { createTheme } from './createTheme';
5
-
6
- describe('createTheme', () => {
7
- describe('create mode (single argument)', () => {
8
- it('returns all empty defaults when called without arguments', () => {
9
- const theme = createTheme();
10
- expect(theme).toEqual({
11
- colors: {},
12
- space: {},
13
- sizes: {},
14
- radii: {},
15
- typography: {},
16
- breakpoints: [],
17
- });
18
- });
19
-
20
- it('returns all empty defaults when called with empty object', () => {
21
- const theme = createTheme({});
22
- expect(theme).toEqual({
23
- colors: {},
24
- space: {},
25
- sizes: {},
26
- radii: {},
27
- typography: {},
28
- breakpoints: [],
29
- });
30
- });
31
-
32
- it('keeps provided groups and fills missing ones with empty defaults', () => {
33
- const theme = createTheme({
34
- colors: { primary: '#000' },
35
- space: { '1': 4 },
36
- });
37
- expect(theme.colors).toEqual({ primary: '#000' });
38
- expect(theme.space).toEqual({ '1': 4 });
39
- expect(theme.sizes).toEqual({});
40
- expect(theme.radii).toEqual({});
41
- expect(theme.typography).toEqual({});
42
- expect(theme.breakpoints).toEqual([]);
43
- });
44
-
45
- it('keeps provided breakpoints', () => {
46
- const theme = createTheme({ breakpoints: [480, 768] });
47
- expect(theme.breakpoints).toEqual([480, 768]);
48
- });
49
- });
50
-
51
- describe('extend mode (two arguments)', () => {
52
- const base: ThemedDict = {
53
- colors: { red: '#FF0000', blue: '#0000FF' },
54
- space: { '1': 4, '2': 8 },
55
- sizes: { sm: 16 },
56
- radii: { md: 8 },
57
- typography: { body: { fontSize: 16, lineHeight: 24 } },
58
- breakpoints: [480, 768],
59
- };
60
-
61
- it('returns base as-is when overrides is empty', () => {
62
- const theme = createTheme(base, {});
63
- expect(theme).toEqual(base);
64
- });
65
-
66
- it('merges colors (keeps existing + adds new)', () => {
67
- const theme = createTheme(base, { colors: { brand: '#FF6600' } });
68
- expect(theme.colors).toEqual({ red: '#FF0000', blue: '#0000FF', brand: '#FF6600' });
69
- });
70
-
71
- it('overrides existing token values', () => {
72
- const theme = createTheme(base, { colors: { red: '#CC0000' } });
73
- expect(theme.colors.red).toBe('#CC0000');
74
- expect(theme.colors.blue).toBe('#0000FF');
75
- });
76
-
77
- it('merges each token group independently', () => {
78
- const theme = createTheme(base, {
79
- space: { '3': 12 },
80
- sizes: { lg: 32 },
81
- radii: { lg: 16 },
82
- typography: { h1: { fontSize: 32, fontWeight: 'bold', lineHeight: 40 } },
83
- });
84
- expect(theme.space).toEqual({ '1': 4, '2': 8, '3': 12 });
85
- expect(theme.sizes).toEqual({ sm: 16, lg: 32 });
86
- expect(theme.radii).toEqual({ md: 8, lg: 16 });
87
- expect(theme.typography).toEqual({
88
- body: { fontSize: 16, lineHeight: 24 },
89
- h1: { fontSize: 32, fontWeight: 'bold', lineHeight: 40 },
90
- });
91
- });
92
-
93
- it('replaces breakpoints when provided in overrides', () => {
94
- const theme = createTheme(base, { breakpoints: [500, 1024, 1440] });
95
- expect(theme.breakpoints).toEqual([500, 1024, 1440]);
96
- });
97
-
98
- it('falls back to base breakpoints when overrides omits breakpoints', () => {
99
- const theme = createTheme(base, { colors: { brand: '#000' } });
100
- expect(theme.breakpoints).toEqual([480, 768]);
101
- });
102
-
103
- it('does not mutate base or overrides', () => {
104
- const baseCopy = JSON.parse(JSON.stringify(base));
105
- const overrides = { colors: { brand: '#FF6600' } };
106
- const overridesCopy = JSON.parse(JSON.stringify(overrides));
107
-
108
- createTheme(base, overrides);
109
-
110
- expect(base).toEqual(baseCopy);
111
- expect(overrides).toEqual(overridesCopy);
112
- });
113
-
114
- it('works with defaultTheme as base', () => {
115
- const theme = createTheme(defaultTheme, {
116
- colors: { brand: '#FF6600' },
117
- space: { huge: 200 },
118
- });
119
- expect(theme.colors.brand).toBe('#FF6600');
120
- expect(theme.colors.white).toBe('#FFFFFF');
121
- expect(theme.space.huge).toBe(200);
122
- expect(theme.space['1']).toBe(4);
123
- expect(theme.breakpoints).toEqual(defaultTheme.breakpoints);
124
- });
125
- });
126
- });