@tamagui/themes 1.88.13 → 1.89.0-1706308641099

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.
@@ -0,0 +1,437 @@
1
+ import { createThemeBuilder } from "@tamagui/theme-builder";
2
+ import { blue, blueDark, gray, grayDark, green, greenDark, orange, orangeDark, pink, pinkDark, purple, purpleDark, red, redDark, yellow, yellowDark } from "@tamagui/colors";
3
+ import { createTokens } from "@tamagui/web";
4
+ import { masks } from "./masks.mjs";
5
+ import { masks as masks2 } from "./masks.mjs";
6
+ const colorTokens = {
7
+ light: {
8
+ blue,
9
+ gray,
10
+ green,
11
+ orange,
12
+ pink,
13
+ purple,
14
+ red,
15
+ yellow
16
+ },
17
+ dark: {
18
+ blue: blueDark,
19
+ gray: grayDark,
20
+ green: greenDark,
21
+ orange: orangeDark,
22
+ pink: pinkDark,
23
+ purple: purpleDark,
24
+ red: redDark,
25
+ yellow: yellowDark
26
+ }
27
+ },
28
+ palettes = (() => {
29
+ const lightTransparent = "rgba(255,255,255,0)",
30
+ darkTransparent = "rgba(10,10,10,0)",
31
+ transparent = (hsl, opacity = 0) => hsl.replace("%)", `%, ${opacity})`).replace("hsl(", "hsla("),
32
+ getColorPalette = (colors, color2 = colors[0]) => {
33
+ const colorPalette = Object.values(colors),
34
+ [head, tail] = [colorPalette.slice(0, 6), colorPalette.slice(colorPalette.length - 5)];
35
+ return [transparent(colorPalette[0]), ...head, ...tail, color2, transparent(colorPalette[colorPalette.length - 1])];
36
+ },
37
+ lightColor = "hsl(0, 0%, 9.0%)",
38
+ lightPalette = [lightTransparent, "#fff", "#f8f8f8", "hsl(0, 0%, 96.3%)", "hsl(0, 0%, 94.1%)", "hsl(0, 0%, 92.0%)", "hsl(0, 0%, 90.0%)", "hsl(0, 0%, 88.5%)", "hsl(0, 0%, 81.0%)", "hsl(0, 0%, 56.1%)", "hsl(0, 0%, 50.3%)", "hsl(0, 0%, 42.5%)", lightColor, darkTransparent],
39
+ darkColor = "#fff",
40
+ darkPalette = [darkTransparent, "#050505", "#151515", "#191919", "#232323", "#282828", "#323232", "#424242", "#494949", "#545454", "#626262", "#a5a5a5", darkColor, lightTransparent],
41
+ lightPalettes = objectFromEntries(objectKeys(colorTokens.light).map(key => [`light_${key}`, getColorPalette(colorTokens.light[key], lightColor)])),
42
+ darkPalettes = objectFromEntries(objectKeys(colorTokens.dark).map(key => [`dark_${key}`, getColorPalette(colorTokens.dark[key], darkColor)])),
43
+ colorPalettes = {
44
+ ...lightPalettes,
45
+ ...darkPalettes
46
+ };
47
+ return {
48
+ light: lightPalette,
49
+ dark: darkPalette,
50
+ ...colorPalettes
51
+ };
52
+ })(),
53
+ templateColorsSpecific = {
54
+ color1: 1,
55
+ color2: 2,
56
+ color3: 3,
57
+ color4: 4,
58
+ color5: 5,
59
+ color6: 6,
60
+ color7: 7,
61
+ color8: 8,
62
+ color9: 9,
63
+ color10: 10,
64
+ color11: 11,
65
+ color12: 12
66
+ },
67
+ templates = (() => {
68
+ const template = {
69
+ ...templateColorsSpecific,
70
+ // the background, color, etc keys here work like generics - they make it so you
71
+ // can publish components for others to use without mandating a specific color scale
72
+ // the @tamagui/button Button component looks for `$background`, so you set the
73
+ // dark_red_Button theme to have a stronger background than the dark_red theme.
74
+ background: 2,
75
+ backgroundHover: 3,
76
+ backgroundPress: 4,
77
+ backgroundFocus: 5,
78
+ backgroundStrong: 1,
79
+ backgroundTransparent: 0,
80
+ color: -1,
81
+ colorHover: -2,
82
+ colorPress: -1,
83
+ colorFocus: -2,
84
+ colorTransparent: -0,
85
+ borderColor: 5,
86
+ borderColorHover: 6,
87
+ borderColorFocus: 4,
88
+ borderColorPress: 5,
89
+ placeholderColor: -4,
90
+ // in the future this should be partially transparent
91
+ outlineColor: 5
92
+ };
93
+ return {
94
+ base: template,
95
+ colorLight: {
96
+ ...template,
97
+ // light color themes are a bit less sensitive
98
+ borderColor: 4,
99
+ borderColorHover: 5,
100
+ borderColorFocus: 4,
101
+ borderColorPress: 4
102
+ }
103
+ };
104
+ })(),
105
+ maskOptions = (() => {
106
+ const shadows2 = {
107
+ shadowColor: 0,
108
+ shadowColorHover: 0,
109
+ shadowColorPress: 0,
110
+ shadowColorFocus: 0
111
+ },
112
+ colors = {
113
+ ...shadows2,
114
+ color: 0,
115
+ colorHover: 0,
116
+ colorFocus: 0,
117
+ colorPress: 0
118
+ },
119
+ baseMaskOptions = {
120
+ override: shadows2,
121
+ skip: shadows2,
122
+ // avoids the transparent ends
123
+ max: palettes.light.length - 2,
124
+ min: 1
125
+ },
126
+ skipShadowsAndSpecificColors = {
127
+ ...shadows2,
128
+ ...templateColorsSpecific
129
+ };
130
+ return {
131
+ component: {
132
+ ...baseMaskOptions,
133
+ override: colors,
134
+ skip: skipShadowsAndSpecificColors
135
+ },
136
+ alt: {
137
+ ...baseMaskOptions
138
+ },
139
+ button: {
140
+ ...baseMaskOptions,
141
+ override: {
142
+ ...colors,
143
+ borderColor: "transparent",
144
+ borderColorHover: "transparent"
145
+ },
146
+ skip: skipShadowsAndSpecificColors
147
+ }
148
+ };
149
+ })(),
150
+ lightShadowColor = "rgba(0,0,0,0.04)",
151
+ lightShadowColorStrong = "rgba(0,0,0,0.085)",
152
+ darkShadowColor = "rgba(0,0,0,0.2)",
153
+ darkShadowColorStrong = "rgba(0,0,0,0.3)",
154
+ size = {
155
+ $0: 0,
156
+ "$0.25": 2,
157
+ "$0.5": 4,
158
+ "$0.75": 8,
159
+ $1: 20,
160
+ "$1.5": 24,
161
+ $2: 28,
162
+ "$2.5": 32,
163
+ $3: 36,
164
+ "$3.5": 40,
165
+ $4: 44,
166
+ $true: 44,
167
+ "$4.5": 48,
168
+ $5: 52,
169
+ $6: 64,
170
+ $7: 74,
171
+ $8: 84,
172
+ $9: 94,
173
+ $10: 104,
174
+ $11: 124,
175
+ $12: 144,
176
+ $13: 164,
177
+ $14: 184,
178
+ $15: 204,
179
+ $16: 224,
180
+ $17: 224,
181
+ $18: 244,
182
+ $19: 264,
183
+ $20: 284
184
+ },
185
+ spaces = Object.entries(size).map(([k, v]) => [k, sizeToSpace(v)]),
186
+ spacesNegative = spaces.slice(1).map(([k, v]) => [`-${k.slice(1)}`, -v]),
187
+ space = {
188
+ ...Object.fromEntries(spaces),
189
+ ...Object.fromEntries(spacesNegative)
190
+ },
191
+ zIndex = {
192
+ 0: 0,
193
+ 1: 100,
194
+ 2: 200,
195
+ 3: 300,
196
+ 4: 400,
197
+ 5: 500
198
+ },
199
+ darkColors = {
200
+ ...colorTokens.dark.blue,
201
+ ...colorTokens.dark.gray,
202
+ ...colorTokens.dark.green,
203
+ ...colorTokens.dark.orange,
204
+ ...colorTokens.dark.pink,
205
+ ...colorTokens.dark.purple,
206
+ ...colorTokens.dark.red,
207
+ ...colorTokens.dark.yellow
208
+ },
209
+ lightColors = {
210
+ ...colorTokens.light.blue,
211
+ ...colorTokens.light.gray,
212
+ ...colorTokens.light.green,
213
+ ...colorTokens.light.orange,
214
+ ...colorTokens.light.pink,
215
+ ...colorTokens.light.purple,
216
+ ...colorTokens.light.red,
217
+ ...colorTokens.light.yellow
218
+ },
219
+ color = {
220
+ ...postfixObjKeys(lightColors, "Light"),
221
+ ...postfixObjKeys(darkColors, "Dark")
222
+ },
223
+ radius = {
224
+ 0: 0,
225
+ 1: 3,
226
+ 2: 5,
227
+ 3: 7,
228
+ 4: 9,
229
+ true: 9,
230
+ 5: 10,
231
+ 6: 16,
232
+ 7: 19,
233
+ 8: 22,
234
+ 9: 26,
235
+ 10: 34,
236
+ 11: 42,
237
+ 12: 50
238
+ },
239
+ tokens = createTokens({
240
+ color,
241
+ radius,
242
+ zIndex,
243
+ space,
244
+ size
245
+ }),
246
+ shadows = {
247
+ light: {
248
+ shadowColor: lightShadowColorStrong,
249
+ shadowColorHover: lightShadowColorStrong,
250
+ shadowColorPress: lightShadowColor,
251
+ shadowColorFocus: lightShadowColor
252
+ },
253
+ dark: {
254
+ shadowColor: darkShadowColorStrong,
255
+ shadowColorHover: darkShadowColorStrong,
256
+ shadowColorPress: darkShadowColor,
257
+ shadowColorFocus: darkShadowColor
258
+ }
259
+ },
260
+ colorThemeDefinition = colorName => [{
261
+ parent: "light",
262
+ palette: colorName,
263
+ template: "colorLight"
264
+ }, {
265
+ parent: "dark",
266
+ palette: colorName,
267
+ template: "base"
268
+ }],
269
+ nonInherited = {
270
+ light: {
271
+ ...lightColors,
272
+ ...shadows.light
273
+ },
274
+ dark: {
275
+ ...darkColors,
276
+ ...shadows.dark
277
+ }
278
+ },
279
+ overlayThemeDefinitions = [{
280
+ parent: "light",
281
+ theme: {
282
+ background: "rgba(0,0,0,0.5)"
283
+ }
284
+ }, {
285
+ parent: "dark",
286
+ theme: {
287
+ background: "rgba(0,0,0,0.9)"
288
+ }
289
+ }],
290
+ themeBuilder = createThemeBuilder().addPalettes(palettes).addTemplates(templates).addMasks(masks).addThemes({
291
+ light: {
292
+ template: "base",
293
+ palette: "light",
294
+ nonInheritedValues: nonInherited.light
295
+ },
296
+ dark: {
297
+ template: "base",
298
+ palette: "dark",
299
+ nonInheritedValues: nonInherited.dark
300
+ }
301
+ }).addChildThemes({
302
+ orange: colorThemeDefinition("orange"),
303
+ yellow: colorThemeDefinition("yellow"),
304
+ green: colorThemeDefinition("green"),
305
+ blue: colorThemeDefinition("blue"),
306
+ purple: colorThemeDefinition("purple"),
307
+ pink: colorThemeDefinition("pink"),
308
+ red: colorThemeDefinition("red"),
309
+ gray: colorThemeDefinition("gray")
310
+ }).addChildThemes({
311
+ alt1: {
312
+ mask: "soften",
313
+ ...maskOptions.alt
314
+ },
315
+ alt2: {
316
+ mask: "soften2Border1",
317
+ ...maskOptions.alt
318
+ },
319
+ active: {
320
+ mask: "soften3FlatBorder",
321
+ skip: {
322
+ color: 1
323
+ }
324
+ }
325
+ }).addChildThemes({
326
+ ListItem: [{
327
+ parent: "light",
328
+ avoidNestingWithin: ["active"],
329
+ mask: "identity",
330
+ ...maskOptions.component
331
+ }, {
332
+ parent: "dark",
333
+ avoidNestingWithin: ["active"],
334
+ mask: "identity",
335
+ ...maskOptions.component
336
+ }],
337
+ Card: {
338
+ mask: "soften",
339
+ avoidNestingWithin: ["active"],
340
+ ...maskOptions.component
341
+ },
342
+ Button: {
343
+ mask: "soften2Border1",
344
+ ...maskOptions.component
345
+ },
346
+ Checkbox: {
347
+ mask: "softenBorder2",
348
+ ...maskOptions.component
349
+ },
350
+ Switch: {
351
+ mask: "soften2Border1",
352
+ ...maskOptions.component
353
+ },
354
+ SwitchThumb: {
355
+ mask: "inverseStrengthen2",
356
+ avoidNestingWithin: ["active"],
357
+ ...maskOptions.component
358
+ },
359
+ TooltipContent: {
360
+ mask: "soften2Border1",
361
+ avoidNestingWithin: ["active"],
362
+ ...maskOptions.component
363
+ },
364
+ DrawerFrame: {
365
+ mask: "soften",
366
+ avoidNestingWithin: ["active"],
367
+ ...maskOptions.component
368
+ },
369
+ Progress: {
370
+ mask: "soften",
371
+ avoidNestingWithin: ["active"],
372
+ ...maskOptions.component
373
+ },
374
+ RadioGroupItem: {
375
+ mask: "softenBorder2",
376
+ avoidNestingWithin: ["active"],
377
+ ...maskOptions.component
378
+ },
379
+ TooltipArrow: {
380
+ mask: "soften",
381
+ avoidNestingWithin: ["active"],
382
+ ...maskOptions.component
383
+ },
384
+ SliderTrackActive: {
385
+ mask: "inverseSoften",
386
+ ...maskOptions.component
387
+ },
388
+ SliderTrack: {
389
+ mask: "soften2Border1",
390
+ avoidNestingWithin: ["active"],
391
+ ...maskOptions.component
392
+ },
393
+ SliderThumb: {
394
+ mask: "inverse",
395
+ avoidNestingWithin: ["active"],
396
+ ...maskOptions.component
397
+ },
398
+ Tooltip: {
399
+ mask: "inverse",
400
+ avoidNestingWithin: ["active"],
401
+ ...maskOptions.component
402
+ },
403
+ ProgressIndicator: {
404
+ mask: "inverse",
405
+ avoidNestingWithin: ["active"],
406
+ ...maskOptions.component
407
+ },
408
+ SheetOverlay: overlayThemeDefinitions,
409
+ DialogOverlay: overlayThemeDefinitions,
410
+ ModalOverlay: overlayThemeDefinitions,
411
+ Input: {
412
+ mask: "softenBorder2",
413
+ ...maskOptions.component
414
+ },
415
+ TextArea: {
416
+ mask: "softenBorder2",
417
+ ...maskOptions.component
418
+ }
419
+ }, {
420
+ // to save bundle size but make alt themes not work on components
421
+ // avoidNestingWithin: ['alt1', 'alt2'],
422
+ }),
423
+ themesIn = themeBuilder.build(),
424
+ themes = themesIn;
425
+ function postfixObjKeys(obj, postfix) {
426
+ return Object.fromEntries(Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v]));
427
+ }
428
+ function sizeToSpace(v) {
429
+ return v === 0 ? 0 : v === 2 ? 0.5 : v === 4 ? 1 : v === 8 ? 1.5 : v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12);
430
+ }
431
+ function objectFromEntries(arr) {
432
+ return Object.fromEntries(arr);
433
+ }
434
+ function objectKeys(obj) {
435
+ return Object.keys(obj);
436
+ }
437
+ export { maskOptions, masks2 as masks, palettes, templates, themes, tokens };
@@ -0,0 +1,12 @@
1
+ import * as generatedThemes from "./generated-v2.mjs";
2
+ import { tokens } from "./tokens.mjs";
3
+ import { blue, blueDark } from "@tamagui/colors";
4
+ import { green, greenDark } from "@tamagui/colors";
5
+ import { red, redDark } from "@tamagui/colors";
6
+ import { orange, orangeDark } from "@tamagui/colors";
7
+ import { yellow, yellowDark } from "@tamagui/colors";
8
+ import { pink, pinkDark } from "@tamagui/colors";
9
+ import { purple, purpleDark } from "@tamagui/colors";
10
+ import { gray, grayDark } from "@tamagui/colors";
11
+ const themes = generatedThemes;
12
+ export { blue, blueDark, gray, grayDark, green, greenDark, orange, orangeDark, pink, pinkDark, purple, purpleDark, red, redDark, themes, tokens, yellow, yellowDark };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/themes",
3
- "version": "1.88.13",
3
+ "version": "1.89.0-1706308641099",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -48,14 +48,14 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@tamagui/colors": "1.88.13",
52
- "@tamagui/create-theme": "1.88.13",
53
- "@tamagui/theme-builder": "1.88.13",
54
- "@tamagui/web": "1.88.13"
51
+ "@tamagui/colors": "1.89.0-1706308641099",
52
+ "@tamagui/create-theme": "1.89.0-1706308641099",
53
+ "@tamagui/theme-builder": "1.89.0-1706308641099",
54
+ "@tamagui/web": "1.89.0-1706308641099"
55
55
  },
56
56
  "devDependencies": {
57
- "@tamagui/build": "1.88.13",
58
- "@tamagui/cli": "1.88.13",
57
+ "@tamagui/build": "1.89.0-1706308641099",
58
+ "@tamagui/cli": "1.89.0-1706308641099",
59
59
  "vitest": "^0.34.3"
60
60
  },
61
61
  "publishConfig": {