@tamagui/themes 1.89.28 → 1.89.30

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.
Files changed (47) hide show
  1. package/dist/cjs/generated-v3.js +1857 -1819
  2. package/dist/cjs/generated-v3.js.map +1 -1
  3. package/dist/cjs/generated-v3.native.js +2593 -2447
  4. package/dist/cjs/generated-v3.native.js.map +1 -1
  5. package/dist/cjs/helpers.native.js.map +1 -1
  6. package/dist/cjs/themes-old.native.js +6 -1
  7. package/dist/cjs/themes-old.native.js.map +1 -1
  8. package/dist/cjs/v3-themes.js +96 -57
  9. package/dist/cjs/v3-themes.js.map +1 -1
  10. package/dist/cjs/v3-themes.native.js +82 -57
  11. package/dist/cjs/v3-themes.native.js.map +2 -2
  12. package/dist/esm/generated-v3.js +1857 -1819
  13. package/dist/esm/generated-v3.js.map +1 -1
  14. package/dist/esm/generated-v3.mjs +166 -166
  15. package/dist/esm/generated-v3.native.js +2593 -2447
  16. package/dist/esm/generated-v3.native.js.map +1 -1
  17. package/dist/esm/themes-old.native.js +6 -1
  18. package/dist/esm/themes-old.native.js.map +1 -1
  19. package/dist/esm/v3-themes.js +96 -57
  20. package/dist/esm/v3-themes.js.map +1 -1
  21. package/dist/esm/v3-themes.mjs +81 -53
  22. package/dist/esm/v3-themes.native.js +81 -56
  23. package/dist/esm/v3-themes.native.js.map +2 -2
  24. package/package.json +7 -20
  25. package/src/generated-v3.ts +1828 -1788
  26. package/src/v3-themes.ts +114 -61
  27. package/tsconfig.json +28 -0
  28. package/types/generated-v3.d.ts +3 -1
  29. package/types/v3-themes.d.ts +15776 -5718
  30. package/types/componentThemeDefinitions.d.ts.map +0 -1
  31. package/types/generated-new.d.ts.map +0 -1
  32. package/types/generated-v2.d.ts.map +0 -1
  33. package/types/generated-v3.d.ts.map +0 -1
  34. package/types/helpers.d.ts.map +0 -1
  35. package/types/index.d.ts.map +0 -1
  36. package/types/masks.d.ts.map +0 -1
  37. package/types/palettes.d.ts.map +0 -1
  38. package/types/shadows.d.ts.map +0 -1
  39. package/types/templates.d.ts.map +0 -1
  40. package/types/themes-new.d.ts.map +0 -1
  41. package/types/themes-old.d.ts.map +0 -1
  42. package/types/themes.d.ts.map +0 -1
  43. package/types/tokens.d.ts.map +0 -1
  44. package/types/v2-themes.d.ts.map +0 -1
  45. package/types/v2.d.ts.map +0 -1
  46. package/types/v3-themes.d.ts.map +0 -1
  47. package/types/v3.d.ts.map +0 -1
package/src/v3-themes.ts CHANGED
@@ -17,7 +17,6 @@ import {
17
17
  yellowDark,
18
18
  } from '@tamagui/colors'
19
19
  import { createThemeBuilder } from '@tamagui/theme-builder'
20
- import type { Variable } from '@tamagui/web'
21
20
  import { createTokens } from '@tamagui/web'
22
21
 
23
22
  const colorTokens = {
@@ -111,15 +110,21 @@ export const palettes = (() => {
111
110
  const transparent = (hsl: string, opacity = 0) =>
112
111
  hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`)
113
112
 
114
- const getColorPalette = (colors: Object): string[] => {
113
+ const getColorPalette = (colors: Object, accentColors: Object): string[] => {
115
114
  const colorPalette = Object.values(colors)
116
115
  // make the transparent color vibrant and towards the middle
117
116
  const colorI = colorPalette.length - 4
118
117
 
118
+ // accents!
119
+ const accentPalette = Object.values(accentColors)
120
+ const accentBackground = accentPalette[0]
121
+ const accentColor = accentPalette[accentPalette.length - 1]
122
+
119
123
  // add our transparent colors first/last
120
124
  // and make sure the last (foreground) color is white/black rather than colorful
121
125
  // this is mostly for consistency with the older theme-base
122
126
  return [
127
+ accentBackground,
123
128
  transparent(colorPalette[0], 0),
124
129
  transparent(colorPalette[0], 0.25),
125
130
  transparent(colorPalette[0], 0.5),
@@ -129,15 +134,17 @@ export const palettes = (() => {
129
134
  transparent(colorPalette[colorI], 0.5),
130
135
  transparent(colorPalette[colorI], 0.25),
131
136
  transparent(colorPalette[colorI], 0),
137
+ accentColor,
132
138
  ]
133
139
  }
134
140
 
135
- // const brandColor = {
136
- // light: color.blue8Light,
137
- // dark: color.blue8Dark
138
- // }
141
+ const brandColor = {
142
+ light: color.blue4Light,
143
+ dark: color.blue4Dark,
144
+ }
139
145
 
140
146
  const lightPalette = [
147
+ brandColor.light,
141
148
  color.white0,
142
149
  color.white025,
143
150
  color.white05,
@@ -158,9 +165,11 @@ export const palettes = (() => {
158
165
  color.black05,
159
166
  color.black025,
160
167
  color.black0,
168
+ brandColor.dark,
161
169
  ]
162
170
 
163
171
  const darkPalette = [
172
+ brandColor.dark,
164
173
  color.black0,
165
174
  color.black025,
166
175
  color.black05,
@@ -181,17 +190,34 @@ export const palettes = (() => {
181
190
  color.white05,
182
191
  color.white025,
183
192
  color.white0,
193
+ brandColor.light,
184
194
  ]
185
195
 
196
+ const lightColorNames = objectKeys(colorTokens.light)
186
197
  const lightPalettes = objectFromEntries(
187
- objectKeys(colorTokens.light).map(
188
- (key) => [`light_${key}`, getColorPalette(colorTokens.light[key])] as const
198
+ lightColorNames.map(
199
+ (key, index) =>
200
+ [
201
+ `light_${key}`,
202
+ getColorPalette(
203
+ colorTokens.light[key],
204
+ colorTokens.light[lightColorNames[(index + 1) % lightColorNames.length]]
205
+ ),
206
+ ] as const
189
207
  )
190
208
  )
191
209
 
210
+ const darkColorNames = objectKeys(colorTokens.dark)
192
211
  const darkPalettes = objectFromEntries(
193
- objectKeys(colorTokens.dark).map(
194
- (key) => [`dark_${key}`, getColorPalette(colorTokens.dark[key])] as const
212
+ darkColorNames.map(
213
+ (key, index) =>
214
+ [
215
+ `dark_${key}`,
216
+ getColorPalette(
217
+ colorTokens.dark[key],
218
+ colorTokens.light[darkColorNames[(index + 1) % darkColorNames.length]]
219
+ ),
220
+ ] as const
195
221
  )
196
222
  )
197
223
 
@@ -207,51 +233,61 @@ export const palettes = (() => {
207
233
  }
208
234
  })()
209
235
 
210
- export const templates = (() => {
211
- const transparencies = 3
236
+ export const getTemplates = (scheme: 'dark' | 'light') => {
237
+ const isLight = scheme === 'light'
238
+
239
+ // our palettes have 4 things padding each end until you get to bg/color:
240
+ // [accentBg, transparent1, transparent2, transparent3, transparent4, background, ...]
241
+ const bgIndex = 5
242
+ const lighten = isLight ? -1 : 1
243
+ const darken = -lighten
244
+ const borderColor = bgIndex + 3
212
245
 
213
246
  // templates use the palette and specify index
214
247
  // negative goes backwards from end so -1 is the last item
215
248
  const base = {
216
- background0: 0,
217
- background025: 1,
218
- background05: 2,
219
- background075: 3,
220
- color1: transparencies + 1,
221
- color2: transparencies + 2,
222
- color3: transparencies + 3,
223
- color4: transparencies + 4,
224
- color5: transparencies + 5,
225
- color6: transparencies + 6,
226
- color7: transparencies + 7,
227
- color8: transparencies + 8,
228
- color9: transparencies + 9,
229
- color10: transparencies + 10,
230
- color11: transparencies + 11,
231
- color12: transparencies + 12,
232
- color0: -0,
233
- color025: -1,
234
- color05: -2,
235
- color075: -3,
249
+ accentBackground: 0,
250
+ accentColor: -0,
251
+
252
+ background0: 1,
253
+ background025: 2,
254
+ background05: 3,
255
+ background075: 4,
256
+ color1: bgIndex,
257
+ color2: bgIndex + 1,
258
+ color3: bgIndex + 2,
259
+ color4: bgIndex + 3,
260
+ color5: bgIndex + 4,
261
+ color6: bgIndex + 5,
262
+ color7: bgIndex + 6,
263
+ color8: bgIndex + 7,
264
+ color9: bgIndex + 8,
265
+ color10: bgIndex + 9,
266
+ color11: bgIndex + 10,
267
+ color12: bgIndex + 11,
268
+ color0: -1,
269
+ color025: -2,
270
+ color05: -3,
271
+ color075: -4,
236
272
  // the background, color, etc keys here work like generics - they make it so you
237
273
  // can publish components for others to use without mandating a specific color scale
238
274
  // the @tamagui/button Button component looks for `$background`, so you set the
239
275
  // dark_red_Button theme to have a stronger background than the dark_red theme.
240
- background: transparencies + 1,
241
- backgroundHover: transparencies + 2,
242
- backgroundPress: transparencies + 3,
243
- backgroundFocus: transparencies + 1,
244
- borderColor: transparencies + 4,
245
- borderColorHover: transparencies + 5,
246
- borderColorFocus: transparencies + 2,
247
- borderColorPress: transparencies + 4,
248
- color: -transparencies - 1,
249
- colorHover: -transparencies - 2,
250
- colorPress: -transparencies - 1,
251
- colorFocus: -transparencies - 2,
252
- colorTransparent: -0,
253
- placeholderColor: -transparencies - 4,
254
- outlineColor: -1,
276
+ background: bgIndex,
277
+ backgroundHover: bgIndex + lighten, // always lighten on hover no matter the scheme
278
+ backgroundPress: bgIndex + darken, // always darken on press no matter the theme
279
+ backgroundFocus: bgIndex + darken,
280
+ borderColor,
281
+ borderColorHover: borderColor + lighten,
282
+ borderColorPress: borderColor + darken,
283
+ borderColorFocus: borderColor,
284
+ color: -bgIndex,
285
+ colorHover: -bgIndex - 1,
286
+ colorPress: -bgIndex,
287
+ colorFocus: -bgIndex - 1,
288
+ colorTransparent: -1,
289
+ placeholderColor: -bgIndex - 3,
290
+ outlineColor: -2,
255
291
  }
256
292
 
257
293
  const surface1 = {
@@ -287,15 +323,20 @@ export const templates = (() => {
287
323
  borderColorPress: base.borderColorPress + 3,
288
324
  }
289
325
 
290
- const surfaceActive = {
326
+ const surfaceActiveBg = {
291
327
  background: base.background + 5,
292
328
  backgroundHover: base.background + 5,
293
329
  backgroundPress: base.backgroundPress + 5,
294
330
  backgroundFocus: base.backgroundFocus + 5,
295
- borderColor: base.borderColor + 5,
296
- borderColorHover: base.borderColor + 5,
297
- borderColorFocus: base.borderColorFocus + 5,
298
- borderColorPress: base.borderColorPress + 5,
331
+ }
332
+
333
+ const surfaceActive = {
334
+ ...surfaceActiveBg,
335
+ // match border to background when active
336
+ borderColor: surfaceActiveBg.background,
337
+ borderColorHover: surfaceActiveBg.backgroundHover,
338
+ borderColorFocus: surfaceActiveBg.backgroundFocus,
339
+ borderColorPress: surfaceActiveBg.backgroundPress,
299
340
  }
300
341
 
301
342
  const inverseSurface1 = {
@@ -350,7 +391,22 @@ export const templates = (() => {
350
391
  inverseActive,
351
392
  surfaceActive,
352
393
  }
353
- })()
394
+ }
395
+
396
+ const lightTemplates = getTemplates('light')
397
+ const darkTemplates = getTemplates('dark')
398
+ const templates = {
399
+ ...objectFromEntries(
400
+ objectKeys(lightTemplates).map(
401
+ (name) => [`light_${name}`, lightTemplates[name]] as const
402
+ )
403
+ ),
404
+ ...objectFromEntries(
405
+ objectKeys(darkTemplates).map(
406
+ (name) => [`dark_${name}`, darkTemplates[name]] as const
407
+ )
408
+ ),
409
+ }
354
410
 
355
411
  const shadows = {
356
412
  light: {
@@ -388,7 +444,7 @@ const overlayThemeDefinitions = [
388
444
  {
389
445
  parent: 'dark',
390
446
  theme: {
391
- background: 'rgba(0,0,0,0.9)',
447
+ background: 'rgba(0,0,0,0.8)',
392
448
  },
393
449
  },
394
450
  ]
@@ -561,12 +617,12 @@ const themeBuilder = createThemeBuilder()
561
617
 
562
618
  const themesIn = themeBuilder.build()
563
619
 
564
- export type Theme = Record<keyof typeof templates.base, string> &
620
+ export type Theme = Record<keyof typeof lightTemplates.base, string> &
565
621
  typeof nonInherited.light
566
622
 
567
623
  export type ThemesOut = Record<keyof typeof themesIn, Theme>
568
624
 
569
- export const themes = themesIn as ThemesOut
625
+ export const themes = themesIn as any as ThemesOut
570
626
 
571
627
  // --- tokens ---
572
628
 
@@ -673,14 +729,11 @@ export const tokens = createTokens({
673
729
 
674
730
  // --- utils ---
675
731
 
676
- export function postfixObjKeys<
677
- A extends { [key: string]: Variable<string> | string },
678
- B extends string,
679
- >(
732
+ export function postfixObjKeys<A extends { [key: string]: string }, B extends string>(
680
733
  obj: A,
681
734
  postfix: B
682
735
  ): {
683
- [Key in `${keyof A extends string ? keyof A : never}${B}`]: Variable<string> | string
736
+ [Key in `${keyof A extends string ? keyof A : never}${B}`]: string
684
737
  } {
685
738
  return Object.fromEntries(
686
739
  Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "composite": true
5
+ },
6
+ "exclude": [
7
+ "generate.ts",
8
+ "types",
9
+ "v2.d.ts",
10
+ "v2.js",
11
+ "v2-themes.js",
12
+ "v2-themes.d.ts",
13
+ "v3.d.ts",
14
+ "v3.js",
15
+ "v3-themes.js",
16
+ "v3-themes.d.ts",
17
+ "dist",
18
+ "**/__tests__"
19
+ ],
20
+ "references": [
21
+ {
22
+ "path": "../colors"
23
+ },
24
+ {
25
+ "path": "../core"
26
+ }
27
+ ]
28
+ }
@@ -1,4 +1,6 @@
1
1
  type Theme = {
2
+ accentBackground: string;
3
+ accentColor: string;
2
4
  background0: string;
3
5
  background025: string;
4
6
  background05: string;
@@ -25,8 +27,8 @@ type Theme = {
25
27
  backgroundFocus: string;
26
28
  borderColor: string;
27
29
  borderColorHover: string;
28
- borderColorFocus: string;
29
30
  borderColorPress: string;
31
+ borderColorFocus: string;
30
32
  color: string;
31
33
  colorHover: string;
32
34
  colorPress: string;