@tamagui/themes 1.89.0-1706360676826 → 1.89.0
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/generated-v3.js +3498 -0
- package/dist/cjs/generated-v3.js.map +6 -0
- package/dist/cjs/generated-v3.native.js +5086 -0
- package/dist/cjs/generated-v3.native.js.map +6 -0
- package/dist/cjs/v3-themes.js +541 -0
- package/dist/cjs/v3-themes.js.map +6 -0
- package/dist/cjs/v3-themes.native.js +559 -0
- package/dist/cjs/v3-themes.native.js.map +6 -0
- package/dist/cjs/v3.js +47 -0
- package/dist/cjs/v3.js.map +6 -0
- package/dist/cjs/v3.native.js +69 -0
- package/dist/cjs/v3.native.js.map +6 -0
- package/dist/esm/componentThemeDefinitions.native.js +22 -44
- package/dist/esm/componentThemeDefinitions.native.js.map +1 -1
- package/dist/esm/generated-new.native.js +2 -1430
- package/dist/esm/generated-new.native.js.map +1 -1
- package/dist/esm/generated-v2.native.js +2 -1408
- package/dist/esm/generated-v2.native.js.map +1 -1
- package/dist/esm/generated-v3.js +3482 -0
- package/dist/esm/generated-v3.js.map +6 -0
- package/dist/esm/generated-v3.mjs +1708 -0
- package/dist/esm/generated-v3.native.js +3482 -0
- package/dist/esm/generated-v3.native.js.map +6 -0
- package/dist/esm/helpers.native.js +2 -25
- package/dist/esm/helpers.native.js.map +1 -1
- package/dist/esm/index.native.js +8 -33
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/masks.native.js +34 -47
- package/dist/esm/masks.native.js.map +1 -1
- package/dist/esm/palettes.native.js +10 -30
- package/dist/esm/palettes.native.js.map +1 -1
- package/dist/esm/shadows.native.js +2 -23
- package/dist/esm/shadows.native.js.map +1 -1
- package/dist/esm/templates.native.js +4 -26
- package/dist/esm/templates.native.js.map +1 -1
- package/dist/esm/themes-new.native.js +17 -32
- package/dist/esm/themes-new.native.js.map +1 -1
- package/dist/esm/themes-old.native.js +25 -38
- package/dist/esm/themes-old.native.js.map +1 -1
- package/dist/esm/themes.native.js +3 -32
- package/dist/esm/themes.native.js.map +1 -1
- package/dist/esm/tokens.native.js +38 -49
- package/dist/esm/tokens.native.js.map +1 -1
- package/dist/esm/v2-themes.native.js +43 -48
- package/dist/esm/v2-themes.native.js.map +2 -2
- package/dist/esm/v2.native.js +12 -49
- package/dist/esm/v2.native.js.map +2 -2
- package/dist/esm/v3-themes.js +544 -0
- package/dist/esm/v3-themes.js.map +6 -0
- package/dist/esm/v3-themes.mjs +474 -0
- package/dist/esm/v3-themes.native.js +544 -0
- package/dist/esm/v3-themes.native.js.map +6 -0
- package/dist/esm/v3.js +32 -0
- package/dist/esm/v3.js.map +6 -0
- package/dist/esm/v3.mjs +12 -0
- package/dist/esm/v3.native.js +32 -0
- package/dist/esm/v3.native.js.map +6 -0
- package/package.json +20 -7
- package/src/generated-v3.ts +3847 -0
- package/src/v3-themes.ts +703 -0
- package/src/v3.tsx +14 -0
- package/types/generated-v3.d.ts +1717 -0
- package/types/generated-v3.d.ts.map +1 -0
- package/types/v3-themes.d.ts +59730 -0
- package/types/v3-themes.d.ts.map +1 -0
- package/types/v3.d.ts +12 -0
- package/types/v3.d.ts.map +1 -0
package/src/v3-themes.ts
ADDED
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
import {
|
|
2
|
+
blue,
|
|
3
|
+
blueDark,
|
|
4
|
+
gray,
|
|
5
|
+
grayDark,
|
|
6
|
+
green,
|
|
7
|
+
greenDark,
|
|
8
|
+
orange,
|
|
9
|
+
orangeDark,
|
|
10
|
+
pink,
|
|
11
|
+
pinkDark,
|
|
12
|
+
purple,
|
|
13
|
+
purpleDark,
|
|
14
|
+
red,
|
|
15
|
+
redDark,
|
|
16
|
+
yellow,
|
|
17
|
+
yellowDark,
|
|
18
|
+
} from '@tamagui/colors'
|
|
19
|
+
import { createThemeBuilder } from '@tamagui/theme-builder'
|
|
20
|
+
import type { Variable } from '@tamagui/web'
|
|
21
|
+
import { createTokens } from '@tamagui/web'
|
|
22
|
+
|
|
23
|
+
const colorTokens = {
|
|
24
|
+
light: {
|
|
25
|
+
blue,
|
|
26
|
+
gray,
|
|
27
|
+
green,
|
|
28
|
+
orange,
|
|
29
|
+
pink,
|
|
30
|
+
purple,
|
|
31
|
+
red,
|
|
32
|
+
yellow,
|
|
33
|
+
},
|
|
34
|
+
dark: {
|
|
35
|
+
blue: blueDark,
|
|
36
|
+
gray: grayDark,
|
|
37
|
+
green: greenDark,
|
|
38
|
+
orange: orangeDark,
|
|
39
|
+
pink: pinkDark,
|
|
40
|
+
purple: purpleDark,
|
|
41
|
+
red: redDark,
|
|
42
|
+
yellow: yellowDark,
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const lightShadowColor = 'rgba(0,0,0,0.04)'
|
|
47
|
+
const lightShadowColorStrong = 'rgba(0,0,0,0.085)'
|
|
48
|
+
const darkShadowColor = 'rgba(0,0,0,0.2)'
|
|
49
|
+
const darkShadowColorStrong = 'rgba(0,0,0,0.3)'
|
|
50
|
+
|
|
51
|
+
const darkColors = {
|
|
52
|
+
...colorTokens.dark.blue,
|
|
53
|
+
...colorTokens.dark.gray,
|
|
54
|
+
...colorTokens.dark.green,
|
|
55
|
+
...colorTokens.dark.orange,
|
|
56
|
+
...colorTokens.dark.pink,
|
|
57
|
+
...colorTokens.dark.purple,
|
|
58
|
+
...colorTokens.dark.red,
|
|
59
|
+
...colorTokens.dark.yellow,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const lightColors = {
|
|
63
|
+
...colorTokens.light.blue,
|
|
64
|
+
...colorTokens.light.gray,
|
|
65
|
+
...colorTokens.light.green,
|
|
66
|
+
...colorTokens.light.orange,
|
|
67
|
+
...colorTokens.light.pink,
|
|
68
|
+
...colorTokens.light.purple,
|
|
69
|
+
...colorTokens.light.red,
|
|
70
|
+
...colorTokens.light.yellow,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const color = {
|
|
74
|
+
white0: 'rgba(255,255,255,0)',
|
|
75
|
+
white075: 'rgba(255,255,255,0.75)',
|
|
76
|
+
white05: 'rgba(255,255,255,0.5)',
|
|
77
|
+
white025: 'rgba(255,255,255,0.25)',
|
|
78
|
+
black0: 'rgba(10,10,10,0)',
|
|
79
|
+
black075: 'rgba(10,10,10,0.75)',
|
|
80
|
+
black05: 'rgba(10,10,10,0.5)',
|
|
81
|
+
black025: 'rgba(10,10,10,0.25)',
|
|
82
|
+
white1: '#fff',
|
|
83
|
+
white2: '#f8f8f8',
|
|
84
|
+
white3: 'hsl(0, 0%, 96.3%)',
|
|
85
|
+
white4: 'hsl(0, 0%, 94.1%)',
|
|
86
|
+
white5: 'hsl(0, 0%, 92.0%)',
|
|
87
|
+
white6: 'hsl(0, 0%, 90.0%)',
|
|
88
|
+
white7: 'hsl(0, 0%, 88.5%)',
|
|
89
|
+
white8: 'hsl(0, 0%, 81.0%)',
|
|
90
|
+
white9: 'hsl(0, 0%, 56.1%)',
|
|
91
|
+
white10: 'hsl(0, 0%, 50.3%)',
|
|
92
|
+
white11: 'hsl(0, 0%, 42.5%)',
|
|
93
|
+
white12: 'hsl(0, 0%, 9.0%)',
|
|
94
|
+
black1: '#050505',
|
|
95
|
+
black2: '#151515',
|
|
96
|
+
black3: '#191919',
|
|
97
|
+
black4: '#232323',
|
|
98
|
+
black5: '#282828',
|
|
99
|
+
black6: '#323232',
|
|
100
|
+
black7: '#424242',
|
|
101
|
+
black8: '#494949',
|
|
102
|
+
black9: '#545454',
|
|
103
|
+
black10: '#626262',
|
|
104
|
+
black11: '#a5a5a5',
|
|
105
|
+
black12: '#fff',
|
|
106
|
+
...postfixObjKeys(lightColors, 'Light'),
|
|
107
|
+
...postfixObjKeys(darkColors, 'Dark'),
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const palettes = (() => {
|
|
111
|
+
const transparent = (hsl: string, opacity = 0) =>
|
|
112
|
+
hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`)
|
|
113
|
+
|
|
114
|
+
const getColorPalette = (colors: Object): string[] => {
|
|
115
|
+
const colorPalette = Object.values(colors)
|
|
116
|
+
// make the transparent color vibrant and towards the middle
|
|
117
|
+
const colorI = colorPalette.length - 4
|
|
118
|
+
|
|
119
|
+
// add our transparent colors first/last
|
|
120
|
+
// and make sure the last (foreground) color is white/black rather than colorful
|
|
121
|
+
// this is mostly for consistency with the older theme-base
|
|
122
|
+
return [
|
|
123
|
+
transparent(colorPalette[0], 0),
|
|
124
|
+
transparent(colorPalette[0], 0.25),
|
|
125
|
+
transparent(colorPalette[0], 0.5),
|
|
126
|
+
transparent(colorPalette[0], 0.75),
|
|
127
|
+
...colorPalette,
|
|
128
|
+
transparent(colorPalette[colorI], 0.75),
|
|
129
|
+
transparent(colorPalette[colorI], 0.5),
|
|
130
|
+
transparent(colorPalette[colorI], 0.25),
|
|
131
|
+
transparent(colorPalette[colorI], 0),
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const lightPalette = [
|
|
136
|
+
color.white0,
|
|
137
|
+
color.white075,
|
|
138
|
+
color.white05,
|
|
139
|
+
color.white025,
|
|
140
|
+
color.white1,
|
|
141
|
+
color.white2,
|
|
142
|
+
color.white3,
|
|
143
|
+
color.white4,
|
|
144
|
+
color.white5,
|
|
145
|
+
color.white6,
|
|
146
|
+
color.white7,
|
|
147
|
+
color.white8,
|
|
148
|
+
color.white9,
|
|
149
|
+
color.white10,
|
|
150
|
+
color.white11,
|
|
151
|
+
color.white12,
|
|
152
|
+
color.black075,
|
|
153
|
+
color.black05,
|
|
154
|
+
color.black025,
|
|
155
|
+
color.black0,
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
const darkPalette = [
|
|
159
|
+
color.black0,
|
|
160
|
+
color.black075,
|
|
161
|
+
color.black05,
|
|
162
|
+
color.black025,
|
|
163
|
+
color.black1,
|
|
164
|
+
color.black2,
|
|
165
|
+
color.black3,
|
|
166
|
+
color.black4,
|
|
167
|
+
color.black5,
|
|
168
|
+
color.black6,
|
|
169
|
+
color.black7,
|
|
170
|
+
color.black8,
|
|
171
|
+
color.black9,
|
|
172
|
+
color.black10,
|
|
173
|
+
color.black11,
|
|
174
|
+
color.black12,
|
|
175
|
+
color.white075,
|
|
176
|
+
color.white05,
|
|
177
|
+
color.white025,
|
|
178
|
+
color.white0,
|
|
179
|
+
]
|
|
180
|
+
|
|
181
|
+
const lightPalettes = objectFromEntries(
|
|
182
|
+
objectKeys(colorTokens.light).map(
|
|
183
|
+
(key) => [`light_${key}`, getColorPalette(colorTokens.light[key])] as const
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
const darkPalettes = objectFromEntries(
|
|
188
|
+
objectKeys(colorTokens.dark).map(
|
|
189
|
+
(key) => [`dark_${key}`, getColorPalette(colorTokens.dark[key])] as const
|
|
190
|
+
)
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
const colorPalettes = {
|
|
194
|
+
...lightPalettes,
|
|
195
|
+
...darkPalettes,
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
light: lightPalette,
|
|
200
|
+
dark: darkPalette,
|
|
201
|
+
...colorPalettes,
|
|
202
|
+
}
|
|
203
|
+
})()
|
|
204
|
+
|
|
205
|
+
export const templates = (() => {
|
|
206
|
+
const transparencies = 3
|
|
207
|
+
|
|
208
|
+
// templates use the palette and specify index
|
|
209
|
+
// negative goes backwards from end so -1 is the last item
|
|
210
|
+
const base = {
|
|
211
|
+
background0: 0,
|
|
212
|
+
background025: 1,
|
|
213
|
+
background05: 2,
|
|
214
|
+
background075: 3,
|
|
215
|
+
color1: transparencies + 1,
|
|
216
|
+
color2: transparencies + 2,
|
|
217
|
+
color3: transparencies + 3,
|
|
218
|
+
color4: transparencies + 4,
|
|
219
|
+
color5: transparencies + 5,
|
|
220
|
+
color6: transparencies + 6,
|
|
221
|
+
color7: transparencies + 7,
|
|
222
|
+
color8: transparencies + 8,
|
|
223
|
+
color9: transparencies + 9,
|
|
224
|
+
color10: transparencies + 10,
|
|
225
|
+
color11: transparencies + 11,
|
|
226
|
+
color12: transparencies + 12,
|
|
227
|
+
color0: -0,
|
|
228
|
+
color025: -1,
|
|
229
|
+
color05: -2,
|
|
230
|
+
color075: -3,
|
|
231
|
+
// the background, color, etc keys here work like generics - they make it so you
|
|
232
|
+
// can publish components for others to use without mandating a specific color scale
|
|
233
|
+
// the @tamagui/button Button component looks for `$background`, so you set the
|
|
234
|
+
// dark_red_Button theme to have a stronger background than the dark_red theme.
|
|
235
|
+
background: transparencies + 1,
|
|
236
|
+
backgroundHover: transparencies + 2,
|
|
237
|
+
backgroundPress: transparencies + 3,
|
|
238
|
+
backgroundFocus: transparencies + 1,
|
|
239
|
+
borderColor: transparencies + 4,
|
|
240
|
+
borderColorHover: transparencies + 5,
|
|
241
|
+
borderColorFocus: transparencies + 2,
|
|
242
|
+
borderColorPress: transparencies + 4,
|
|
243
|
+
color: -transparencies - 1,
|
|
244
|
+
colorHover: -transparencies - 2,
|
|
245
|
+
colorPress: -transparencies - 1,
|
|
246
|
+
colorFocus: -transparencies - 2,
|
|
247
|
+
colorTransparent: -0,
|
|
248
|
+
placeholderColor: -transparencies - 4,
|
|
249
|
+
outlineColor: -1,
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const surface1 = {
|
|
253
|
+
background: base.background + 1,
|
|
254
|
+
backgroundHover: base.backgroundHover + 1,
|
|
255
|
+
backgroundPress: base.backgroundPress + 1,
|
|
256
|
+
backgroundFocus: base.backgroundFocus + 1,
|
|
257
|
+
borderColor: base.borderColor + 1,
|
|
258
|
+
borderColorHover: base.borderColorHover + 1,
|
|
259
|
+
borderColorFocus: base.borderColorFocus + 1,
|
|
260
|
+
borderColorPress: base.borderColorPress + 1,
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const surface2 = {
|
|
264
|
+
background: base.background + 2,
|
|
265
|
+
backgroundHover: base.backgroundHover + 2,
|
|
266
|
+
backgroundPress: base.backgroundPress + 2,
|
|
267
|
+
backgroundFocus: base.backgroundFocus + 2,
|
|
268
|
+
borderColor: base.borderColor + 2,
|
|
269
|
+
borderColorHover: base.borderColorHover + 2,
|
|
270
|
+
borderColorFocus: base.borderColorFocus + 2,
|
|
271
|
+
borderColorPress: base.borderColorPress + 2,
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const surface3 = {
|
|
275
|
+
background: base.background + 3,
|
|
276
|
+
backgroundHover: base.backgroundHover + 3,
|
|
277
|
+
backgroundPress: base.backgroundPress + 3,
|
|
278
|
+
backgroundFocus: base.backgroundFocus + 3,
|
|
279
|
+
borderColor: base.borderColor + 3,
|
|
280
|
+
borderColorHover: base.borderColorHover + 3,
|
|
281
|
+
borderColorFocus: base.borderColorFocus + 3,
|
|
282
|
+
borderColorPress: base.borderColorPress + 3,
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const surfaceActive = {
|
|
286
|
+
background: base.background + 5,
|
|
287
|
+
backgroundHover: base.background + 5,
|
|
288
|
+
backgroundPress: base.backgroundPress + 5,
|
|
289
|
+
backgroundFocus: base.backgroundFocus + 5,
|
|
290
|
+
borderColor: base.borderColor + 5,
|
|
291
|
+
borderColorHover: base.borderColor + 5,
|
|
292
|
+
borderColorFocus: base.borderColorFocus + 5,
|
|
293
|
+
borderColorPress: base.borderColorPress + 5,
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const inverseSurface1 = {
|
|
297
|
+
color: surface1.background,
|
|
298
|
+
colorHover: surface1.backgroundHover,
|
|
299
|
+
colorPress: surface1.backgroundPress,
|
|
300
|
+
colorFocus: surface1.backgroundFocus,
|
|
301
|
+
background: base.color,
|
|
302
|
+
backgroundHover: base.colorHover,
|
|
303
|
+
backgroundPress: base.colorPress,
|
|
304
|
+
backgroundFocus: base.colorFocus,
|
|
305
|
+
borderColor: base.color - 2,
|
|
306
|
+
borderColorHover: base.color - 3,
|
|
307
|
+
borderColorFocus: base.color - 4,
|
|
308
|
+
borderColorPress: base.color - 5,
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const inverseActive = {
|
|
312
|
+
...inverseSurface1,
|
|
313
|
+
background: base.color - 2,
|
|
314
|
+
backgroundHover: base.colorHover - 2,
|
|
315
|
+
backgroundPress: base.colorPress - 2,
|
|
316
|
+
backgroundFocus: base.colorFocus - 2,
|
|
317
|
+
borderColor: base.color - 2 - 2,
|
|
318
|
+
borderColorHover: base.color - 3 - 2,
|
|
319
|
+
borderColorFocus: base.color - 4 - 2,
|
|
320
|
+
borderColorPress: base.color - 5 - 2,
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const alt1 = {
|
|
324
|
+
color: base.color - 1,
|
|
325
|
+
colorHover: base.colorHover - 1,
|
|
326
|
+
colorPress: base.colorPress - 1,
|
|
327
|
+
colorFocus: base.colorFocus - 1,
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const alt2 = {
|
|
331
|
+
color: base.color - 2,
|
|
332
|
+
colorHover: base.colorHover - 2,
|
|
333
|
+
colorPress: base.colorPress - 2,
|
|
334
|
+
colorFocus: base.colorFocus - 2,
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
base,
|
|
339
|
+
alt1,
|
|
340
|
+
alt2,
|
|
341
|
+
surface1,
|
|
342
|
+
surface2,
|
|
343
|
+
surface3,
|
|
344
|
+
inverseSurface1,
|
|
345
|
+
inverseActive,
|
|
346
|
+
surfaceActive,
|
|
347
|
+
}
|
|
348
|
+
})()
|
|
349
|
+
|
|
350
|
+
const shadows = {
|
|
351
|
+
light: {
|
|
352
|
+
shadowColor: lightShadowColorStrong,
|
|
353
|
+
shadowColorHover: lightShadowColorStrong,
|
|
354
|
+
shadowColorPress: lightShadowColor,
|
|
355
|
+
shadowColorFocus: lightShadowColor,
|
|
356
|
+
},
|
|
357
|
+
dark: {
|
|
358
|
+
shadowColor: darkShadowColorStrong,
|
|
359
|
+
shadowColorHover: darkShadowColorStrong,
|
|
360
|
+
shadowColorPress: darkShadowColor,
|
|
361
|
+
shadowColorFocus: darkShadowColor,
|
|
362
|
+
},
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const nonInherited = {
|
|
366
|
+
light: {
|
|
367
|
+
...lightColors,
|
|
368
|
+
...shadows.light,
|
|
369
|
+
},
|
|
370
|
+
dark: {
|
|
371
|
+
...darkColors,
|
|
372
|
+
...shadows.dark,
|
|
373
|
+
},
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const overlayThemeDefinitions = [
|
|
377
|
+
{
|
|
378
|
+
parent: 'light',
|
|
379
|
+
theme: {
|
|
380
|
+
background: 'rgba(0,0,0,0.5)',
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
parent: 'dark',
|
|
385
|
+
theme: {
|
|
386
|
+
background: 'rgba(0,0,0,0.9)',
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
]
|
|
390
|
+
|
|
391
|
+
const inverseSurface1 = [
|
|
392
|
+
{
|
|
393
|
+
parent: 'active',
|
|
394
|
+
template: 'inverseActive',
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
parent: '',
|
|
398
|
+
template: 'inverseSurface1',
|
|
399
|
+
},
|
|
400
|
+
] as any
|
|
401
|
+
|
|
402
|
+
const surface1 = [
|
|
403
|
+
{
|
|
404
|
+
parent: 'active',
|
|
405
|
+
template: 'surfaceActive',
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
parent: '',
|
|
409
|
+
template: 'surface1',
|
|
410
|
+
},
|
|
411
|
+
] as any
|
|
412
|
+
|
|
413
|
+
const surface2 = [
|
|
414
|
+
{
|
|
415
|
+
parent: 'active',
|
|
416
|
+
template: 'surfaceActive',
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
parent: '',
|
|
420
|
+
template: 'surface2',
|
|
421
|
+
},
|
|
422
|
+
] as any
|
|
423
|
+
|
|
424
|
+
const surface3 = [
|
|
425
|
+
{
|
|
426
|
+
parent: 'active',
|
|
427
|
+
template: 'surfaceActive',
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
parent: '',
|
|
431
|
+
template: 'surface3',
|
|
432
|
+
},
|
|
433
|
+
] as any
|
|
434
|
+
|
|
435
|
+
// --- themeBuilder ---
|
|
436
|
+
|
|
437
|
+
const themeBuilder = createThemeBuilder()
|
|
438
|
+
.addPalettes(palettes)
|
|
439
|
+
.addTemplates(templates)
|
|
440
|
+
.addThemes({
|
|
441
|
+
light: {
|
|
442
|
+
template: 'base',
|
|
443
|
+
palette: 'light',
|
|
444
|
+
nonInheritedValues: nonInherited.light,
|
|
445
|
+
},
|
|
446
|
+
dark: {
|
|
447
|
+
template: 'base',
|
|
448
|
+
palette: 'dark',
|
|
449
|
+
nonInheritedValues: nonInherited.dark,
|
|
450
|
+
},
|
|
451
|
+
})
|
|
452
|
+
.addChildThemes({
|
|
453
|
+
orange: {
|
|
454
|
+
palette: 'orange',
|
|
455
|
+
template: 'base',
|
|
456
|
+
},
|
|
457
|
+
yellow: {
|
|
458
|
+
palette: 'yellow',
|
|
459
|
+
template: 'base',
|
|
460
|
+
},
|
|
461
|
+
green: {
|
|
462
|
+
palette: 'green',
|
|
463
|
+
template: 'base',
|
|
464
|
+
},
|
|
465
|
+
blue: {
|
|
466
|
+
palette: 'blue',
|
|
467
|
+
template: 'base',
|
|
468
|
+
},
|
|
469
|
+
purple: {
|
|
470
|
+
palette: 'purple',
|
|
471
|
+
template: 'base',
|
|
472
|
+
},
|
|
473
|
+
pink: {
|
|
474
|
+
palette: 'pink',
|
|
475
|
+
template: 'base',
|
|
476
|
+
},
|
|
477
|
+
red: {
|
|
478
|
+
palette: 'red',
|
|
479
|
+
template: 'base',
|
|
480
|
+
},
|
|
481
|
+
gray: {
|
|
482
|
+
palette: 'gray',
|
|
483
|
+
template: 'base',
|
|
484
|
+
},
|
|
485
|
+
})
|
|
486
|
+
.addChildThemes({
|
|
487
|
+
alt1: {
|
|
488
|
+
template: 'alt1',
|
|
489
|
+
},
|
|
490
|
+
alt2: {
|
|
491
|
+
template: 'alt2',
|
|
492
|
+
},
|
|
493
|
+
active: {
|
|
494
|
+
template: 'surface3',
|
|
495
|
+
},
|
|
496
|
+
})
|
|
497
|
+
.addChildThemes(
|
|
498
|
+
{
|
|
499
|
+
ListItem: {
|
|
500
|
+
template: 'surface1',
|
|
501
|
+
},
|
|
502
|
+
SelectTrigger: surface1,
|
|
503
|
+
Card: surface1,
|
|
504
|
+
Button: surface3,
|
|
505
|
+
Checkbox: surface2,
|
|
506
|
+
Switch: surface2,
|
|
507
|
+
SwitchThumb: inverseSurface1,
|
|
508
|
+
TooltipContent: surface2,
|
|
509
|
+
Progress: {
|
|
510
|
+
template: 'surface1',
|
|
511
|
+
},
|
|
512
|
+
RadioGroupItem: surface2,
|
|
513
|
+
TooltipArrow: {
|
|
514
|
+
template: 'surface1',
|
|
515
|
+
},
|
|
516
|
+
SliderTrackActive: {
|
|
517
|
+
template: 'surface3',
|
|
518
|
+
},
|
|
519
|
+
SliderTrack: {
|
|
520
|
+
template: 'surface1',
|
|
521
|
+
},
|
|
522
|
+
SliderThumb: inverseSurface1,
|
|
523
|
+
Tooltip: inverseSurface1,
|
|
524
|
+
ProgressIndicator: inverseSurface1,
|
|
525
|
+
SheetOverlay: overlayThemeDefinitions,
|
|
526
|
+
DialogOverlay: overlayThemeDefinitions,
|
|
527
|
+
ModalOverlay: overlayThemeDefinitions,
|
|
528
|
+
Input: surface1,
|
|
529
|
+
TextArea: surface1,
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
avoidNestingWithin: ['alt1', 'alt2'],
|
|
533
|
+
}
|
|
534
|
+
)
|
|
535
|
+
|
|
536
|
+
// --- themes ---
|
|
537
|
+
|
|
538
|
+
const themesIn = themeBuilder.build()
|
|
539
|
+
|
|
540
|
+
export type Theme = Record<keyof typeof templates.base, string> &
|
|
541
|
+
typeof nonInherited.light
|
|
542
|
+
export type ThemesOut = Record<keyof typeof themesIn, Theme>
|
|
543
|
+
export const themes = themesIn as ThemesOut
|
|
544
|
+
|
|
545
|
+
// --- tokens ---
|
|
546
|
+
|
|
547
|
+
// should roughly map to button/input etc height at each level
|
|
548
|
+
// fonts should match that height/lineHeight at each stop
|
|
549
|
+
// so these are really non-linear on purpose
|
|
550
|
+
// why?
|
|
551
|
+
// - at sizes <1, used for fine grained things (borders, smallest paddingY)
|
|
552
|
+
// - so smallest padY should be roughly 1-4px so it can join with lineHeight
|
|
553
|
+
// - at sizes >=1, have to consider "pressability" (jumps up)
|
|
554
|
+
// - after that it should go upwards somewhat naturally
|
|
555
|
+
// - H1 / headings top out at 10 naturally, so after 10 we can go upwards faster
|
|
556
|
+
// but also one more wrinkle...
|
|
557
|
+
// space is used in conjunction with size
|
|
558
|
+
// i'm setting space to generally just a fixed fraction of size (~1/3-2/3 still fine tuning)
|
|
559
|
+
export const size = {
|
|
560
|
+
$0: 0,
|
|
561
|
+
'$0.25': 2,
|
|
562
|
+
'$0.5': 4,
|
|
563
|
+
'$0.75': 8,
|
|
564
|
+
$1: 20,
|
|
565
|
+
'$1.5': 24,
|
|
566
|
+
$2: 28,
|
|
567
|
+
'$2.5': 32,
|
|
568
|
+
$3: 36,
|
|
569
|
+
'$3.5': 40,
|
|
570
|
+
$4: 44,
|
|
571
|
+
$true: 44,
|
|
572
|
+
'$4.5': 48,
|
|
573
|
+
$5: 52,
|
|
574
|
+
$6: 64,
|
|
575
|
+
$7: 74,
|
|
576
|
+
$8: 84,
|
|
577
|
+
$9: 94,
|
|
578
|
+
$10: 104,
|
|
579
|
+
$11: 124,
|
|
580
|
+
$12: 144,
|
|
581
|
+
$13: 164,
|
|
582
|
+
$14: 184,
|
|
583
|
+
$15: 204,
|
|
584
|
+
$16: 224,
|
|
585
|
+
$17: 224,
|
|
586
|
+
$18: 244,
|
|
587
|
+
$19: 264,
|
|
588
|
+
$20: 284,
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
type SizeKeysIn = keyof typeof size
|
|
592
|
+
type Sizes = {
|
|
593
|
+
[Key in SizeKeysIn extends `$${infer Key}` ? Key : SizeKeysIn]: number
|
|
594
|
+
}
|
|
595
|
+
type SizeKeys = `${keyof Sizes extends `${infer K}` ? K : never}`
|
|
596
|
+
|
|
597
|
+
export const spaces = Object.entries(size).map(([k, v]) => {
|
|
598
|
+
return [k, sizeToSpace(v)] as const
|
|
599
|
+
})
|
|
600
|
+
|
|
601
|
+
export const spacesNegative = spaces.slice(1).map(([k, v]) => [`-${k.slice(1)}`, -v])
|
|
602
|
+
|
|
603
|
+
type SizeKeysWithNegatives =
|
|
604
|
+
| Exclude<`-${SizeKeys extends `$${infer Key}` ? Key : SizeKeys}`, '-0'>
|
|
605
|
+
| SizeKeys
|
|
606
|
+
|
|
607
|
+
export const space: {
|
|
608
|
+
[Key in SizeKeysWithNegatives]: Key extends keyof Sizes ? Sizes[Key] : number
|
|
609
|
+
} = {
|
|
610
|
+
...Object.fromEntries(spaces),
|
|
611
|
+
...Object.fromEntries(spacesNegative),
|
|
612
|
+
} as any
|
|
613
|
+
|
|
614
|
+
export const zIndex = {
|
|
615
|
+
0: 0,
|
|
616
|
+
1: 100,
|
|
617
|
+
2: 200,
|
|
618
|
+
3: 300,
|
|
619
|
+
4: 400,
|
|
620
|
+
5: 500,
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export const radius = {
|
|
624
|
+
0: 0,
|
|
625
|
+
1: 3,
|
|
626
|
+
2: 5,
|
|
627
|
+
3: 7,
|
|
628
|
+
4: 9,
|
|
629
|
+
true: 9,
|
|
630
|
+
5: 10,
|
|
631
|
+
6: 16,
|
|
632
|
+
7: 19,
|
|
633
|
+
8: 22,
|
|
634
|
+
9: 26,
|
|
635
|
+
10: 34,
|
|
636
|
+
11: 42,
|
|
637
|
+
12: 50,
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
export const tokens = createTokens({
|
|
641
|
+
color,
|
|
642
|
+
radius,
|
|
643
|
+
zIndex,
|
|
644
|
+
space,
|
|
645
|
+
size,
|
|
646
|
+
})
|
|
647
|
+
|
|
648
|
+
// --- utils ---
|
|
649
|
+
|
|
650
|
+
export function postfixObjKeys<
|
|
651
|
+
A extends { [key: string]: Variable<string> | string },
|
|
652
|
+
B extends string,
|
|
653
|
+
>(
|
|
654
|
+
obj: A,
|
|
655
|
+
postfix: B
|
|
656
|
+
): {
|
|
657
|
+
[Key in `${keyof A extends string ? keyof A : never}${B}`]: Variable<string> | string
|
|
658
|
+
} {
|
|
659
|
+
return Object.fromEntries(
|
|
660
|
+
Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])
|
|
661
|
+
) as any
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// a bit odd but keeping backward compat for values >8 while fixing below
|
|
665
|
+
export function sizeToSpace(v: number) {
|
|
666
|
+
if (v === 0) return 0
|
|
667
|
+
if (v === 2) return 0.5
|
|
668
|
+
if (v === 4) return 1
|
|
669
|
+
if (v === 8) return 1.5
|
|
670
|
+
if (v <= 16) return Math.round(v * 0.333)
|
|
671
|
+
return Math.floor(v * 0.7 - 12)
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
export function objectFromEntries<ARR_T extends EntriesType>(
|
|
675
|
+
arr: ARR_T
|
|
676
|
+
): EntriesToObject<ARR_T> {
|
|
677
|
+
return Object.fromEntries(arr) as EntriesToObject<ARR_T>
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export type EntriesType =
|
|
681
|
+
| [PropertyKey, unknown][]
|
|
682
|
+
| ReadonlyArray<readonly [PropertyKey, unknown]>
|
|
683
|
+
|
|
684
|
+
export type DeepWritable<OBJ_T> = { -readonly [P in keyof OBJ_T]: DeepWritable<OBJ_T[P]> }
|
|
685
|
+
export type UnionToIntersection<UNION_T> = // From https://stackoverflow.com/a/50375286
|
|
686
|
+
(UNION_T extends any ? (k: UNION_T) => void : never) extends (k: infer I) => void
|
|
687
|
+
? I
|
|
688
|
+
: never
|
|
689
|
+
|
|
690
|
+
export type UnionObjectFromArrayOfPairs<ARR_T extends EntriesType> =
|
|
691
|
+
DeepWritable<ARR_T> extends (infer R)[]
|
|
692
|
+
? R extends [infer key, infer val]
|
|
693
|
+
? { [prop in key & PropertyKey]: val }
|
|
694
|
+
: never
|
|
695
|
+
: never
|
|
696
|
+
export type MergeIntersectingObjects<ObjT> = { [key in keyof ObjT]: ObjT[key] }
|
|
697
|
+
export type EntriesToObject<ARR_T extends EntriesType> = MergeIntersectingObjects<
|
|
698
|
+
UnionToIntersection<UnionObjectFromArrayOfPairs<ARR_T>>
|
|
699
|
+
>
|
|
700
|
+
|
|
701
|
+
export function objectKeys<O extends Object>(obj: O) {
|
|
702
|
+
return Object.keys(obj) as Array<keyof O>
|
|
703
|
+
}
|
package/src/v3.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as generatedThemes from './generated-v3'
|
|
2
|
+
export const themes = generatedThemes
|
|
3
|
+
|
|
4
|
+
export { tokens } from './tokens'
|
|
5
|
+
|
|
6
|
+
// specific colors since we have cjs here
|
|
7
|
+
export { blue, blueDark } from '@tamagui/colors'
|
|
8
|
+
export { green, greenDark } from '@tamagui/colors'
|
|
9
|
+
export { red, redDark } from '@tamagui/colors'
|
|
10
|
+
export { orange, orangeDark } from '@tamagui/colors'
|
|
11
|
+
export { yellow, yellowDark } from '@tamagui/colors'
|
|
12
|
+
export { pink, pinkDark } from '@tamagui/colors'
|
|
13
|
+
export { purple, purpleDark } from '@tamagui/colors'
|
|
14
|
+
export { gray, grayDark } from '@tamagui/colors'
|