@tamagui/themes 1.31.4 → 1.32.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/dist/cjs/componentThemeDefinitions.js +7 -6
- package/dist/cjs/componentThemeDefinitions.js.map +1 -1
- package/dist/cjs/generated-new.js +171 -460
- package/dist/cjs/generated-new.js.map +1 -1
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/masks.js +4 -1
- package/dist/cjs/masks.js.map +1 -1
- package/dist/cjs/shadows.js +46 -0
- package/dist/cjs/shadows.js.map +6 -0
- package/dist/cjs/themes-new.js +3 -19
- package/dist/cjs/themes-new.js.map +1 -1
- package/dist/cjs/themes.js +11 -301
- package/dist/cjs/themes.js.map +1 -1
- package/dist/esm/componentThemeDefinitions.js +7 -6
- package/dist/esm/componentThemeDefinitions.js.map +1 -1
- package/dist/esm/generated-new.js +171 -460
- package/dist/esm/generated-new.js.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/masks.js +4 -1
- package/dist/esm/masks.js.map +1 -1
- package/dist/esm/shadows.js +22 -0
- package/dist/esm/shadows.js.map +6 -0
- package/dist/esm/themes-new.js +3 -19
- package/dist/esm/themes-new.js.map +1 -1
- package/dist/esm/themes.js +1 -308
- package/dist/esm/themes.js.map +1 -1
- package/package.json +10 -8
- package/src/componentThemeDefinitions.tsx +137 -0
- package/src/generated-new.ts +4313 -0
- package/src/helpers.ts +44 -0
- package/src/index.tsx +3 -9
- package/src/masks.tsx +45 -0
- package/src/palettes.tsx +91 -0
- package/src/shadows.tsx +19 -0
- package/src/templates.tsx +111 -0
- package/src/themes-new.tsx +74 -0
- package/src/{themes.outlined.tsx → themes-old.tsx} +108 -17
- package/src/themes.tsx +4 -378
- package/types/componentThemeDefinitions.d.ts +628 -0
- package/types/componentThemeDefinitions.d.ts.map +1 -1
- package/types/generated-new.d.ts +516 -0
- package/types/generated-new.d.ts.map +1 -1
- package/types/helpers.d.ts +24 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -1
- package/types/masks.d.ts +13 -0
- package/types/masks.d.ts.map +1 -1
- package/types/palettes.d.ts +21 -0
- package/types/shadows.d.ts +15 -0
- package/types/shadows.d.ts.map +1 -0
- package/types/templates.d.ts +142 -0
- package/types/themes-new.d.ts +40323 -0
- package/types/themes-new.d.ts.map +1 -1
- package/types/themes-old.d.ts +51411 -0
- package/types/themes.d.ts +2 -51602
- package/types/themes.d.ts.map +1 -1
- package/types/tokens.d.ts +2 -2
- package/dist/cjs/generated-old.js +0 -13599
- package/dist/cjs/generated-old.js.map +0 -6
- package/dist/esm/generated-old.js +0 -12064
- package/dist/esm/generated-old.js.map +0 -6
- package/src/generate.ts +0 -25
- package/src/generated.js +0 -23954
- package/types/generate.d.ts +0 -2
- package/types/themes.outlined.d.ts +0 -2643
package/src/themes.tsx
CHANGED
|
@@ -1,381 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
MaskOptions,
|
|
3
|
-
addChildren,
|
|
4
|
-
applyMask,
|
|
5
|
-
createStrengthenMask,
|
|
6
|
-
createTheme,
|
|
7
|
-
createWeakenMask,
|
|
8
|
-
skipMask,
|
|
9
|
-
} from '@tamagui/create-theme'
|
|
1
|
+
// TODO automate generating with a watch command
|
|
10
2
|
|
|
11
|
-
import
|
|
3
|
+
import * as themes from './generated-new'
|
|
12
4
|
|
|
13
|
-
|
|
5
|
+
export { themes }
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
const darkTransparent = 'rgba(10,10,10,0)'
|
|
17
|
-
|
|
18
|
-
// background => foreground
|
|
19
|
-
const palettes = {
|
|
20
|
-
dark: [
|
|
21
|
-
darkTransparent,
|
|
22
|
-
'#050505',
|
|
23
|
-
'#151515',
|
|
24
|
-
'#191919',
|
|
25
|
-
'#232323',
|
|
26
|
-
'#282828',
|
|
27
|
-
'#323232',
|
|
28
|
-
'#424242',
|
|
29
|
-
'#494949',
|
|
30
|
-
'#545454',
|
|
31
|
-
'#626262',
|
|
32
|
-
'#a5a5a5',
|
|
33
|
-
'#fff',
|
|
34
|
-
lightTransparent,
|
|
35
|
-
],
|
|
36
|
-
light: [
|
|
37
|
-
lightTransparent,
|
|
38
|
-
'#fff',
|
|
39
|
-
'#f9f9f9',
|
|
40
|
-
'hsl(0, 0%, 97.3%)',
|
|
41
|
-
'hsl(0, 0%, 95.1%)',
|
|
42
|
-
'hsl(0, 0%, 94.0%)',
|
|
43
|
-
'hsl(0, 0%, 92.0%)',
|
|
44
|
-
'hsl(0, 0%, 89.5%)',
|
|
45
|
-
'hsl(0, 0%, 81.0%)',
|
|
46
|
-
'hsl(0, 0%, 56.1%)',
|
|
47
|
-
'hsl(0, 0%, 50.3%)',
|
|
48
|
-
'hsl(0, 0%, 42.5%)',
|
|
49
|
-
'hsl(0, 0%, 9.0%)',
|
|
50
|
-
darkTransparent,
|
|
51
|
-
],
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const templateColors = {
|
|
55
|
-
color1: 1,
|
|
56
|
-
color2: 2,
|
|
57
|
-
color3: 3,
|
|
58
|
-
color4: 4,
|
|
59
|
-
color5: 5,
|
|
60
|
-
color6: 6,
|
|
61
|
-
color7: 7,
|
|
62
|
-
color8: 8,
|
|
63
|
-
color9: 9,
|
|
64
|
-
color10: 10,
|
|
65
|
-
color11: 11,
|
|
66
|
-
color12: 12,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const templateShadows = {
|
|
70
|
-
shadowColor: 1,
|
|
71
|
-
shadowColorHover: 1,
|
|
72
|
-
shadowColorPress: 2,
|
|
73
|
-
shadowColorFocus: 2,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// we can use subset of our template as a "override" so it doesn't get adjusted with masks
|
|
77
|
-
// we want to skip over templateColor + templateShadows
|
|
78
|
-
const toSkip = {
|
|
79
|
-
...templateShadows,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const override = Object.fromEntries(Object.entries(toSkip).map(([k]) => [k, 0]))
|
|
83
|
-
const overrideShadows = Object.fromEntries(
|
|
84
|
-
Object.entries(templateShadows).map(([k]) => [k, 0])
|
|
85
|
-
)
|
|
86
|
-
const overrideWithColors = {
|
|
87
|
-
...override,
|
|
88
|
-
color: 0,
|
|
89
|
-
colorHover: 0,
|
|
90
|
-
colorFocus: 0,
|
|
91
|
-
colorPress: 0,
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// templates use the palette and specify index
|
|
95
|
-
// negative goes backwards from end so -1 is the last item
|
|
96
|
-
const template = {
|
|
97
|
-
...templateColors,
|
|
98
|
-
...toSkip,
|
|
99
|
-
// the background, color, etc keys here work like generics - they make it so you
|
|
100
|
-
// can publish components for others to use without mandating a specific color scale
|
|
101
|
-
// the @tamagui/button Button component looks for `$background`, so you set the
|
|
102
|
-
// dark_red_Button theme to have a stronger background than the dark_red theme.
|
|
103
|
-
background: 2,
|
|
104
|
-
backgroundHover: 3,
|
|
105
|
-
backgroundPress: 4,
|
|
106
|
-
backgroundFocus: 5,
|
|
107
|
-
backgroundStrong: 1,
|
|
108
|
-
backgroundTransparent: 0,
|
|
109
|
-
color: -1,
|
|
110
|
-
colorHover: -2,
|
|
111
|
-
colorPress: -1,
|
|
112
|
-
colorFocus: -2,
|
|
113
|
-
colorTransparent: -0,
|
|
114
|
-
borderColor: 4,
|
|
115
|
-
borderColorHover: 5,
|
|
116
|
-
borderColorPress: 3,
|
|
117
|
-
borderColorFocus: 4,
|
|
118
|
-
placeholderColor: -4,
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const lightShadowColor = 'rgba(0,0,0,0.02)'
|
|
122
|
-
const lightShadowColorStrong = 'rgba(0,0,0,0.066)'
|
|
123
|
-
const darkShadowColor = 'rgba(0,0,0,0.2)'
|
|
124
|
-
const darkShadowColorStrong = 'rgba(0,0,0,0.3)'
|
|
125
|
-
|
|
126
|
-
const lightShadows = {
|
|
127
|
-
shadowColor: lightShadowColorStrong,
|
|
128
|
-
shadowColorHover: lightShadowColorStrong,
|
|
129
|
-
shadowColorPress: lightShadowColor,
|
|
130
|
-
shadowColorFocus: lightShadowColor,
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const darkShadows = {
|
|
134
|
-
shadowColor: darkShadowColorStrong,
|
|
135
|
-
shadowColorHover: darkShadowColorStrong,
|
|
136
|
-
shadowColorPress: darkShadowColor,
|
|
137
|
-
shadowColorFocus: darkShadowColor,
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const lightTemplate = {
|
|
141
|
-
...template,
|
|
142
|
-
|
|
143
|
-
background: 2,
|
|
144
|
-
backgroundHover: 3,
|
|
145
|
-
backgroundPress: 4,
|
|
146
|
-
|
|
147
|
-
// our light color palette is... a bit unique
|
|
148
|
-
borderColor: 6,
|
|
149
|
-
borderColorHover: 7,
|
|
150
|
-
borderColorFocus: 5,
|
|
151
|
-
borderColorPress: 6,
|
|
152
|
-
...lightShadows,
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const darkTemplate = { ...template, ...darkShadows }
|
|
156
|
-
|
|
157
|
-
const light = createTheme(palettes.light, lightTemplate)
|
|
158
|
-
const dark = createTheme(palettes.dark, darkTemplate)
|
|
159
|
-
|
|
160
|
-
type SubTheme = typeof light
|
|
161
|
-
|
|
162
|
-
const baseThemes: {
|
|
163
|
-
light: SubTheme
|
|
164
|
-
dark: SubTheme
|
|
165
|
-
} = {
|
|
166
|
-
light,
|
|
167
|
-
dark,
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const masks = {
|
|
171
|
-
skip: skipMask,
|
|
172
|
-
weaker: createWeakenMask(),
|
|
173
|
-
stronger: createStrengthenMask(),
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// default mask options for most uses
|
|
177
|
-
const maskOptions: MaskOptions = {
|
|
178
|
-
override,
|
|
179
|
-
skip: toSkip,
|
|
180
|
-
// avoids the transparent ends
|
|
181
|
-
max: palettes.light.length - 2,
|
|
182
|
-
min: 1,
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const transparent = (hsl: string, opacity = 0) =>
|
|
186
|
-
hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`)
|
|
187
|
-
|
|
188
|
-
// setup colorThemes and their inverses
|
|
189
|
-
const [lightColorThemes, darkColorThemes] = [colorTokens.light, colorTokens.dark].map(
|
|
190
|
-
(colorSet, i) => {
|
|
191
|
-
const isLight = i === 0
|
|
192
|
-
const theme = baseThemes[isLight ? 'light' : 'dark']
|
|
193
|
-
|
|
194
|
-
return Object.fromEntries(
|
|
195
|
-
Object.keys(colorSet).map((color) => {
|
|
196
|
-
const colorPalette = Object.values(colorSet[color]) as string[]
|
|
197
|
-
// were re-ordering these
|
|
198
|
-
const [head, tail] = [
|
|
199
|
-
colorPalette.slice(0, 6),
|
|
200
|
-
colorPalette.slice(colorPalette.length - 5),
|
|
201
|
-
]
|
|
202
|
-
// add our transparent colors first/last
|
|
203
|
-
// and make sure the last (foreground) color is white/black rather than colorful
|
|
204
|
-
// this is mostly for consistency with the older theme-base
|
|
205
|
-
const palette = [
|
|
206
|
-
transparent(colorPalette[0]),
|
|
207
|
-
...head,
|
|
208
|
-
...tail,
|
|
209
|
-
theme.color,
|
|
210
|
-
transparent(colorPalette[colorPalette.length - 1]),
|
|
211
|
-
]
|
|
212
|
-
|
|
213
|
-
const colorTheme = createTheme(
|
|
214
|
-
palette,
|
|
215
|
-
isLight
|
|
216
|
-
? {
|
|
217
|
-
...lightTemplate,
|
|
218
|
-
// light color themes are a bit less sensitive
|
|
219
|
-
borderColor: 4,
|
|
220
|
-
borderColorHover: 5,
|
|
221
|
-
borderColorFocus: 4,
|
|
222
|
-
borderColorPress: 4,
|
|
223
|
-
}
|
|
224
|
-
: darkTemplate
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
return [color, colorTheme]
|
|
228
|
-
})
|
|
229
|
-
) as Record<ColorName, SubTheme>
|
|
230
|
-
}
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
const allThemes = addChildren(baseThemes, (name, theme) => {
|
|
234
|
-
const isLight = name === 'light'
|
|
235
|
-
const inverseName = isLight ? 'dark' : 'light'
|
|
236
|
-
const inverseTheme = baseThemes[inverseName]
|
|
237
|
-
const colorThemes = isLight ? lightColorThemes : darkColorThemes
|
|
238
|
-
const inverseColorThemes = isLight ? darkColorThemes : lightColorThemes
|
|
239
|
-
|
|
240
|
-
const allColorThemes = addChildren(colorThemes, (colorName, colorTheme) => {
|
|
241
|
-
const inverse = inverseColorThemes[colorName]
|
|
242
|
-
return {
|
|
243
|
-
...getAltThemes({
|
|
244
|
-
theme: colorTheme,
|
|
245
|
-
inverse,
|
|
246
|
-
isLight,
|
|
247
|
-
}),
|
|
248
|
-
...getComponentThemes(colorTheme, inverse, isLight),
|
|
249
|
-
}
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
const baseSubThemes = {
|
|
253
|
-
...getAltThemes({ theme, inverse: inverseTheme, isLight }),
|
|
254
|
-
...getComponentThemes(theme, inverseTheme, isLight),
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
...baseSubThemes,
|
|
259
|
-
...allColorThemes,
|
|
260
|
-
}
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
function getAltThemes({
|
|
264
|
-
theme,
|
|
265
|
-
inverse,
|
|
266
|
-
isLight,
|
|
267
|
-
activeTheme,
|
|
268
|
-
}: {
|
|
269
|
-
theme: SubTheme
|
|
270
|
-
inverse: SubTheme
|
|
271
|
-
isLight: boolean
|
|
272
|
-
activeTheme?: SubTheme
|
|
273
|
-
}) {
|
|
274
|
-
const maskOptionsAlt = {
|
|
275
|
-
...maskOptions,
|
|
276
|
-
override: overrideShadows,
|
|
277
|
-
}
|
|
278
|
-
const alt1 = applyMask(theme, masks.weaker, maskOptionsAlt)
|
|
279
|
-
const alt2 = applyMask(alt1, masks.weaker, maskOptionsAlt)
|
|
280
|
-
|
|
281
|
-
const active =
|
|
282
|
-
activeTheme ??
|
|
283
|
-
(process.env.ACTIVE_THEME_INVERSE
|
|
284
|
-
? inverse
|
|
285
|
-
: (() => {
|
|
286
|
-
return applyMask(theme, masks.weaker, {
|
|
287
|
-
...maskOptions,
|
|
288
|
-
strength: 3,
|
|
289
|
-
skip: {
|
|
290
|
-
...maskOptions.skip,
|
|
291
|
-
color: 1,
|
|
292
|
-
},
|
|
293
|
-
})
|
|
294
|
-
})())
|
|
295
|
-
|
|
296
|
-
return addChildren({ alt1, alt2, active }, (_, subTheme) => {
|
|
297
|
-
return getComponentThemes(subTheme, subTheme === inverse ? theme : inverse, isLight)
|
|
298
|
-
})
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function getComponentThemes(theme: SubTheme, inverse: SubTheme, isLight: boolean) {
|
|
302
|
-
const componentMaskOptions: MaskOptions = {
|
|
303
|
-
...maskOptions,
|
|
304
|
-
override: overrideWithColors,
|
|
305
|
-
skip: {
|
|
306
|
-
...maskOptions.skip,
|
|
307
|
-
// skip colors too just for component sub themes
|
|
308
|
-
...templateColors,
|
|
309
|
-
},
|
|
310
|
-
}
|
|
311
|
-
const weaker1 = applyMask(theme, masks.weaker, componentMaskOptions)
|
|
312
|
-
const base = applyMask(weaker1, masks.stronger, componentMaskOptions)
|
|
313
|
-
const weaker2 = applyMask(weaker1, masks.weaker, {
|
|
314
|
-
...componentMaskOptions,
|
|
315
|
-
override: overrideWithColors,
|
|
316
|
-
})
|
|
317
|
-
const stronger1 = applyMask(theme, masks.stronger, componentMaskOptions)
|
|
318
|
-
const inverse1 = applyMask(inverse, masks.weaker, componentMaskOptions)
|
|
319
|
-
const inverse2 = applyMask(inverse1, masks.weaker, componentMaskOptions)
|
|
320
|
-
const strongerBorderLighterBackground: SubTheme = isLight
|
|
321
|
-
? {
|
|
322
|
-
...stronger1,
|
|
323
|
-
borderColor: weaker1.borderColor,
|
|
324
|
-
borderColorHover: weaker1.borderColorHover,
|
|
325
|
-
borderColorPress: weaker1.borderColorPress,
|
|
326
|
-
borderColorFocus: weaker1.borderColorFocus,
|
|
327
|
-
}
|
|
328
|
-
: {
|
|
329
|
-
...applyMask(theme, masks.skip, componentMaskOptions),
|
|
330
|
-
borderColor: weaker1.borderColor,
|
|
331
|
-
borderColorHover: weaker1.borderColorHover,
|
|
332
|
-
borderColorPress: weaker1.borderColorPress,
|
|
333
|
-
borderColorFocus: weaker1.borderColorFocus,
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const overlayTheme = {
|
|
337
|
-
background: isLight ? 'rgba(0,0,0,0.5)' : 'rgba(0,0,0,0.9)',
|
|
338
|
-
} as SubTheme
|
|
339
|
-
|
|
340
|
-
const weaker2WithoutBorder = {
|
|
341
|
-
...weaker2,
|
|
342
|
-
borderColor: 'transparent',
|
|
343
|
-
borderColorHover: 'transparent',
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return {
|
|
347
|
-
ListItem: isLight ? stronger1 : base,
|
|
348
|
-
Card: weaker1,
|
|
349
|
-
Button: weaker2WithoutBorder,
|
|
350
|
-
Checkbox: weaker2,
|
|
351
|
-
DrawerFrame: weaker1,
|
|
352
|
-
SliderTrack: stronger1,
|
|
353
|
-
SliderTrackActive: weaker2,
|
|
354
|
-
SliderThumb: inverse1,
|
|
355
|
-
Progress: weaker1,
|
|
356
|
-
ProgressIndicator: inverse,
|
|
357
|
-
Switch: weaker2,
|
|
358
|
-
SwitchThumb: inverse2,
|
|
359
|
-
TooltipArrow: weaker1,
|
|
360
|
-
TooltipContent: weaker2,
|
|
361
|
-
Input: strongerBorderLighterBackground,
|
|
362
|
-
TextArea: strongerBorderLighterBackground,
|
|
363
|
-
Tooltip: inverse1,
|
|
364
|
-
// make overlays always dark
|
|
365
|
-
SheetOverlay: overlayTheme,
|
|
366
|
-
DialogOverlay: overlayTheme,
|
|
367
|
-
ModalOverlay: overlayTheme,
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export const themes = {
|
|
372
|
-
...allThemes,
|
|
373
|
-
// bring back the full type, the rest use a subset to avoid clogging up ts,
|
|
374
|
-
// tamagui will be smart and use the top level themes as the type for useTheme() etc
|
|
375
|
-
light: createTheme(palettes.light, lightTemplate, { nonInheritedValues: lightColors }),
|
|
376
|
-
dark: createTheme(palettes.dark, darkTemplate, { nonInheritedValues: darkColors }),
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// if (process.env.NODE_ENV === 'development') {
|
|
380
|
-
// console.log(JSON.stringify(themes).length)
|
|
381
|
-
// }
|
|
7
|
+
// export { themes } from './themes-new'
|