@tamagui/themes 1.31.3 → 1.32.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/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/helpers.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type ObjectType = Record<PropertyKey, unknown>
|
|
2
|
+
|
|
3
|
+
type PickByValue<OBJ_T, VALUE_T> = // From https://stackoverflow.com/a/55153000
|
|
4
|
+
Pick<OBJ_T, { [K in keyof OBJ_T]: OBJ_T[K] extends VALUE_T ? K : never }[keyof OBJ_T]>
|
|
5
|
+
|
|
6
|
+
type ObjectEntries<OBJ_T> = // From https://stackoverflow.com/a/60142095
|
|
7
|
+
{ [K in keyof OBJ_T]: [keyof PickByValue<OBJ_T, OBJ_T[K]>, OBJ_T[K]] }[keyof OBJ_T][]
|
|
8
|
+
|
|
9
|
+
export const objectKeys = <O extends Object>(obj: O) => Object.keys(obj) as Array<keyof O>
|
|
10
|
+
|
|
11
|
+
export function objectEntries<OBJ_T extends ObjectType>(
|
|
12
|
+
obj: OBJ_T
|
|
13
|
+
): ObjectEntries<OBJ_T> {
|
|
14
|
+
return Object.entries(obj) as ObjectEntries<OBJ_T>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type EntriesType =
|
|
18
|
+
| [PropertyKey, unknown][]
|
|
19
|
+
| ReadonlyArray<readonly [PropertyKey, unknown]>
|
|
20
|
+
|
|
21
|
+
// Existing Utils
|
|
22
|
+
type DeepWritable<OBJ_T> = { -readonly [P in keyof OBJ_T]: DeepWritable<OBJ_T[P]> }
|
|
23
|
+
type UnionToIntersection<UNION_T> = // From https://stackoverflow.com/a/50375286
|
|
24
|
+
(UNION_T extends any ? (k: UNION_T) => void : never) extends (k: infer I) => void
|
|
25
|
+
? I
|
|
26
|
+
: never
|
|
27
|
+
|
|
28
|
+
// New Utils
|
|
29
|
+
type UnionObjectFromArrayOfPairs<ARR_T extends EntriesType> =
|
|
30
|
+
DeepWritable<ARR_T> extends (infer R)[]
|
|
31
|
+
? R extends [infer key, infer val]
|
|
32
|
+
? { [prop in key & PropertyKey]: val }
|
|
33
|
+
: never
|
|
34
|
+
: never
|
|
35
|
+
type MergeIntersectingObjects<ObjT> = { [key in keyof ObjT]: ObjT[key] }
|
|
36
|
+
type EntriesToObject<ARR_T extends EntriesType> = MergeIntersectingObjects<
|
|
37
|
+
UnionToIntersection<UnionObjectFromArrayOfPairs<ARR_T>>
|
|
38
|
+
>
|
|
39
|
+
|
|
40
|
+
export function objectFromEntries<ARR_T extends EntriesType>(
|
|
41
|
+
arr: ARR_T
|
|
42
|
+
): EntriesToObject<ARR_T> {
|
|
43
|
+
return Object.fromEntries(arr) as EntriesToObject<ARR_T>
|
|
44
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
// import generatedThemes from './generated'
|
|
2
|
-
// import { themes as runtimeThemes } from './themes'
|
|
3
|
-
|
|
4
|
-
// export const themes =
|
|
5
|
-
// process.env.NODE_ENV === 'development'
|
|
6
|
-
// ? runtimeThemes
|
|
7
|
-
// : (generatedThemes as typeof runtimeThemes)
|
|
8
|
-
|
|
9
|
-
// export * from './themes.outlined'
|
|
10
1
|
export * from './themes'
|
|
11
2
|
export * from './tokens'
|
|
3
|
+
export * from './masks'
|
|
4
|
+
export * from './componentThemeDefinitions'
|
|
5
|
+
export * from './palettes'
|
|
12
6
|
export * from '@tamagui/colors'
|
package/src/masks.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
combineMasks,
|
|
3
|
+
createIdentityMask,
|
|
4
|
+
createInverseMask,
|
|
5
|
+
createMask,
|
|
6
|
+
createSoftenMask,
|
|
7
|
+
createStrengthenMask,
|
|
8
|
+
skipMask,
|
|
9
|
+
} from '@tamagui/create-theme'
|
|
10
|
+
|
|
11
|
+
export const masks = {
|
|
12
|
+
identity: createIdentityMask(),
|
|
13
|
+
soften: createSoftenMask(),
|
|
14
|
+
soften2: createSoftenMask({ strength: 2 }),
|
|
15
|
+
soften3: createSoftenMask({ strength: 3 }),
|
|
16
|
+
strengthen: createStrengthenMask(),
|
|
17
|
+
inverse: createInverseMask(),
|
|
18
|
+
inverseSoften: combineMasks(createInverseMask(), createSoftenMask()),
|
|
19
|
+
inverseStrengthen2: combineMasks(
|
|
20
|
+
createInverseMask(),
|
|
21
|
+
createStrengthenMask({ strength: 2 })
|
|
22
|
+
),
|
|
23
|
+
strengthenButSoftenBorder: createMask((template, options) => {
|
|
24
|
+
const stronger = createStrengthenMask().mask(template, options)
|
|
25
|
+
const softer = createSoftenMask().mask(template, options)
|
|
26
|
+
return {
|
|
27
|
+
...stronger,
|
|
28
|
+
borderColor: softer.borderColor,
|
|
29
|
+
borderColorHover: softer.borderColorHover,
|
|
30
|
+
borderColorPress: softer.borderColorPress,
|
|
31
|
+
borderColorFocus: softer.borderColorFocus,
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
softenBorder: createMask((template, options) => {
|
|
35
|
+
const plain = skipMask.mask(template, options)
|
|
36
|
+
const softer = createSoftenMask().mask(template, options)
|
|
37
|
+
return {
|
|
38
|
+
...plain,
|
|
39
|
+
borderColor: softer.borderColor,
|
|
40
|
+
borderColorHover: softer.borderColorHover,
|
|
41
|
+
borderColorPress: softer.borderColorPress,
|
|
42
|
+
borderColorFocus: softer.borderColorFocus,
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
}
|
package/src/palettes.tsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { objectFromEntries, objectKeys } from './helpers'
|
|
2
|
+
import { colorTokens } from './tokens'
|
|
3
|
+
|
|
4
|
+
export const palettes = (() => {
|
|
5
|
+
const lightTransparent = 'rgba(255,255,255,0)'
|
|
6
|
+
const darkTransparent = 'rgba(10,10,10,0)'
|
|
7
|
+
|
|
8
|
+
const transparent = (hsl: string, opacity = 0) =>
|
|
9
|
+
hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`)
|
|
10
|
+
|
|
11
|
+
const getColorPalette = (colors: Object, color = colors[0]): string[] => {
|
|
12
|
+
const colorPalette = Object.values(colors)
|
|
13
|
+
|
|
14
|
+
// were re-ordering these
|
|
15
|
+
const [head, tail] = [
|
|
16
|
+
colorPalette.slice(0, 6),
|
|
17
|
+
colorPalette.slice(colorPalette.length - 5),
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
// add our transparent colors first/last
|
|
21
|
+
// and make sure the last (foreground) color is white/black rather than colorful
|
|
22
|
+
// this is mostly for consistency with the older theme-base
|
|
23
|
+
return [
|
|
24
|
+
transparent(colorPalette[0]),
|
|
25
|
+
...head,
|
|
26
|
+
...tail,
|
|
27
|
+
color,
|
|
28
|
+
transparent(colorPalette[colorPalette.length - 1]),
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const lightColor = 'hsl(0, 0%, 9.0%)'
|
|
33
|
+
const lightPalette = [
|
|
34
|
+
lightTransparent,
|
|
35
|
+
'#fff',
|
|
36
|
+
'#f9f9f9',
|
|
37
|
+
'hsl(0, 0%, 97.3%)',
|
|
38
|
+
'hsl(0, 0%, 95.1%)',
|
|
39
|
+
'hsl(0, 0%, 94.0%)',
|
|
40
|
+
'hsl(0, 0%, 92.0%)',
|
|
41
|
+
'hsl(0, 0%, 89.5%)',
|
|
42
|
+
'hsl(0, 0%, 81.0%)',
|
|
43
|
+
'hsl(0, 0%, 56.1%)',
|
|
44
|
+
'hsl(0, 0%, 50.3%)',
|
|
45
|
+
'hsl(0, 0%, 42.5%)',
|
|
46
|
+
lightColor,
|
|
47
|
+
darkTransparent,
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
const darkColor = '#fff'
|
|
51
|
+
const darkPalette = [
|
|
52
|
+
darkTransparent,
|
|
53
|
+
'#050505',
|
|
54
|
+
'#151515',
|
|
55
|
+
'#191919',
|
|
56
|
+
'#232323',
|
|
57
|
+
'#282828',
|
|
58
|
+
'#323232',
|
|
59
|
+
'#424242',
|
|
60
|
+
'#494949',
|
|
61
|
+
'#545454',
|
|
62
|
+
'#626262',
|
|
63
|
+
'#a5a5a5',
|
|
64
|
+
darkColor,
|
|
65
|
+
lightTransparent,
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
const lightPalettes = objectFromEntries(
|
|
69
|
+
objectKeys(colorTokens.light).map(
|
|
70
|
+
(key) =>
|
|
71
|
+
[`light_${key}`, getColorPalette(colorTokens.light[key], lightColor)] as const
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const darkPalettes = objectFromEntries(
|
|
76
|
+
objectKeys(colorTokens.dark).map(
|
|
77
|
+
(key) => [`dark_${key}`, getColorPalette(colorTokens.dark[key], darkColor)] as const
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
const colorPalettes = {
|
|
82
|
+
...lightPalettes,
|
|
83
|
+
...darkPalettes,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
light: lightPalette,
|
|
88
|
+
dark: darkPalette,
|
|
89
|
+
...colorPalettes,
|
|
90
|
+
}
|
|
91
|
+
})()
|
package/src/shadows.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const lightShadowColor = 'rgba(0,0,0,0.02)'
|
|
2
|
+
const lightShadowColorStrong = 'rgba(0,0,0,0.066)'
|
|
3
|
+
const darkShadowColor = 'rgba(0,0,0,0.2)'
|
|
4
|
+
const darkShadowColorStrong = 'rgba(0,0,0,0.3)'
|
|
5
|
+
|
|
6
|
+
export const shadows = {
|
|
7
|
+
light: {
|
|
8
|
+
shadowColor: lightShadowColorStrong,
|
|
9
|
+
shadowColorHover: lightShadowColorStrong,
|
|
10
|
+
shadowColorPress: lightShadowColor,
|
|
11
|
+
shadowColorFocus: lightShadowColor,
|
|
12
|
+
},
|
|
13
|
+
dark: {
|
|
14
|
+
shadowColor: darkShadowColorStrong,
|
|
15
|
+
shadowColorHover: darkShadowColorStrong,
|
|
16
|
+
shadowColorPress: darkShadowColor,
|
|
17
|
+
shadowColorFocus: darkShadowColor,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { MaskOptions } from '@tamagui/create-theme'
|
|
2
|
+
|
|
3
|
+
import { palettes } from './palettes'
|
|
4
|
+
|
|
5
|
+
export const { templates, maskOptions } = (() => {
|
|
6
|
+
const templateColors = {
|
|
7
|
+
color1: 1,
|
|
8
|
+
color2: 2,
|
|
9
|
+
color3: 3,
|
|
10
|
+
color4: 4,
|
|
11
|
+
color5: 5,
|
|
12
|
+
color6: 6,
|
|
13
|
+
color7: 7,
|
|
14
|
+
color8: 8,
|
|
15
|
+
color9: 9,
|
|
16
|
+
color10: 10,
|
|
17
|
+
color11: 11,
|
|
18
|
+
color12: 12,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// templates use the palette and specify index
|
|
22
|
+
// negative goes backwards from end so -1 is the last item
|
|
23
|
+
const template = {
|
|
24
|
+
...templateColors,
|
|
25
|
+
// the background, color, etc keys here work like generics - they make it so you
|
|
26
|
+
// can publish components for others to use without mandating a specific color scale
|
|
27
|
+
// the @tamagui/button Button component looks for `$background`, so you set the
|
|
28
|
+
// dark_red_Button theme to have a stronger background than the dark_red theme.
|
|
29
|
+
background: 2,
|
|
30
|
+
backgroundHover: 3,
|
|
31
|
+
backgroundPress: 4,
|
|
32
|
+
backgroundFocus: 5,
|
|
33
|
+
backgroundStrong: 1,
|
|
34
|
+
backgroundTransparent: 0,
|
|
35
|
+
color: -1,
|
|
36
|
+
colorHover: -2,
|
|
37
|
+
colorPress: -1,
|
|
38
|
+
colorFocus: -2,
|
|
39
|
+
colorTransparent: -0,
|
|
40
|
+
borderColor: 5,
|
|
41
|
+
borderColorHover: 6,
|
|
42
|
+
borderColorFocus: 4,
|
|
43
|
+
borderColorPress: 5,
|
|
44
|
+
placeholderColor: -4,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const templates = {
|
|
48
|
+
base: template,
|
|
49
|
+
colorLight: {
|
|
50
|
+
...template,
|
|
51
|
+
// light color themes are a bit less sensitive
|
|
52
|
+
borderColor: 4,
|
|
53
|
+
borderColorHover: 5,
|
|
54
|
+
borderColorFocus: 4,
|
|
55
|
+
borderColorPress: 4,
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const overrideShadows = {
|
|
60
|
+
shadowColor: 0,
|
|
61
|
+
shadowColorHover: 0,
|
|
62
|
+
shadowColorPress: 0,
|
|
63
|
+
shadowColorFocus: 0,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const overrideWithColors = {
|
|
67
|
+
...overrideShadows,
|
|
68
|
+
color: 0,
|
|
69
|
+
colorHover: 0,
|
|
70
|
+
colorFocus: 0,
|
|
71
|
+
colorPress: 0,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const baseMaskOptions: MaskOptions = {
|
|
75
|
+
override: overrideShadows,
|
|
76
|
+
skip: overrideShadows,
|
|
77
|
+
// avoids the transparent ends
|
|
78
|
+
max: palettes.light.length - 2,
|
|
79
|
+
min: 1,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const skipShadowsAndColors = {
|
|
83
|
+
...overrideShadows,
|
|
84
|
+
...templateColors,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const maskOptions = {
|
|
88
|
+
component: {
|
|
89
|
+
...baseMaskOptions,
|
|
90
|
+
override: overrideWithColors,
|
|
91
|
+
skip: skipShadowsAndColors,
|
|
92
|
+
},
|
|
93
|
+
alt: {
|
|
94
|
+
...baseMaskOptions,
|
|
95
|
+
},
|
|
96
|
+
button: {
|
|
97
|
+
...baseMaskOptions,
|
|
98
|
+
override: {
|
|
99
|
+
...overrideWithColors,
|
|
100
|
+
borderColor: 'transparent',
|
|
101
|
+
borderColorHover: 'transparent',
|
|
102
|
+
},
|
|
103
|
+
skip: skipShadowsAndColors,
|
|
104
|
+
},
|
|
105
|
+
} satisfies Record<string, MaskOptions>
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
templates,
|
|
109
|
+
maskOptions,
|
|
110
|
+
}
|
|
111
|
+
})()
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createThemeBuilder } from '@tamagui/create-theme'
|
|
2
|
+
|
|
3
|
+
import { componentThemeDefinitions } from './componentThemeDefinitions'
|
|
4
|
+
import { masks } from './masks'
|
|
5
|
+
import { palettes } from './palettes'
|
|
6
|
+
import { shadows } from './shadows'
|
|
7
|
+
import { maskOptions, templates } from './templates'
|
|
8
|
+
import { darkColors, lightColors } from './tokens'
|
|
9
|
+
|
|
10
|
+
const colorThemeDefinition = (colorName: string) => [
|
|
11
|
+
{
|
|
12
|
+
parent: 'light',
|
|
13
|
+
palette: colorName,
|
|
14
|
+
template: 'colorLight',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
parent: 'dark',
|
|
18
|
+
palette: colorName,
|
|
19
|
+
template: 'base',
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
const themesBuilder = createThemeBuilder()
|
|
24
|
+
.addPalettes(palettes)
|
|
25
|
+
.addTemplates(templates)
|
|
26
|
+
.addMasks(masks)
|
|
27
|
+
.addThemes({
|
|
28
|
+
light: {
|
|
29
|
+
template: 'base',
|
|
30
|
+
palette: 'light',
|
|
31
|
+
nonInheritedValues: {
|
|
32
|
+
...lightColors,
|
|
33
|
+
...shadows.light,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
dark: {
|
|
37
|
+
template: 'base',
|
|
38
|
+
palette: 'dark',
|
|
39
|
+
nonInheritedValues: {
|
|
40
|
+
...darkColors,
|
|
41
|
+
...shadows.dark,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
.addChildThemes({
|
|
46
|
+
orange: colorThemeDefinition('orange'),
|
|
47
|
+
yellow: colorThemeDefinition('yellow'),
|
|
48
|
+
green: colorThemeDefinition('green'),
|
|
49
|
+
blue: colorThemeDefinition('blue'),
|
|
50
|
+
purple: colorThemeDefinition('purple'),
|
|
51
|
+
pink: colorThemeDefinition('pink'),
|
|
52
|
+
red: colorThemeDefinition('red'),
|
|
53
|
+
})
|
|
54
|
+
.addChildThemes({
|
|
55
|
+
alt1: {
|
|
56
|
+
mask: 'soften',
|
|
57
|
+
...maskOptions.alt,
|
|
58
|
+
},
|
|
59
|
+
alt2: {
|
|
60
|
+
mask: 'soften2',
|
|
61
|
+
...maskOptions.alt,
|
|
62
|
+
},
|
|
63
|
+
active: {
|
|
64
|
+
mask: 'soften3',
|
|
65
|
+
skip: {
|
|
66
|
+
color: 1,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
.addChildThemes(componentThemeDefinitions, {
|
|
71
|
+
avoidNestingWithin: ['alt1', 'alt2', 'active'],
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
export const themes = themesBuilder.build()
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
skipMask,
|
|
9
9
|
} from '@tamagui/create-theme'
|
|
10
10
|
|
|
11
|
-
import { colorTokens, darkColors, lightColors
|
|
11
|
+
import { colorTokens, darkColors, lightColors } from './tokens'
|
|
12
12
|
|
|
13
13
|
type ColorName = keyof typeof colorTokens.dark
|
|
14
14
|
|
|
@@ -100,10 +100,10 @@ const template = {
|
|
|
100
100
|
// can publish components for others to use without mandating a specific color scale
|
|
101
101
|
// the @tamagui/button Button component looks for `$background`, so you set the
|
|
102
102
|
// dark_red_Button theme to have a stronger background than the dark_red theme.
|
|
103
|
-
background:
|
|
104
|
-
backgroundHover:
|
|
105
|
-
backgroundPress:
|
|
106
|
-
backgroundFocus:
|
|
103
|
+
background: 2,
|
|
104
|
+
backgroundHover: 3,
|
|
105
|
+
backgroundPress: 4,
|
|
106
|
+
backgroundFocus: 5,
|
|
107
107
|
backgroundStrong: 1,
|
|
108
108
|
backgroundTransparent: 0,
|
|
109
109
|
color: -1,
|
|
@@ -111,13 +111,32 @@ const template = {
|
|
|
111
111
|
colorPress: -1,
|
|
112
112
|
colorFocus: -2,
|
|
113
113
|
colorTransparent: -0,
|
|
114
|
-
borderColor:
|
|
115
|
-
borderColorHover:
|
|
116
|
-
borderColorPress:
|
|
117
|
-
borderColorFocus:
|
|
114
|
+
borderColor: 4,
|
|
115
|
+
borderColorHover: 5,
|
|
116
|
+
borderColorPress: 3,
|
|
117
|
+
borderColorFocus: 4,
|
|
118
118
|
placeholderColor: -4,
|
|
119
119
|
}
|
|
120
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
|
+
|
|
121
140
|
const lightTemplate = {
|
|
122
141
|
...template,
|
|
123
142
|
|
|
@@ -126,13 +145,14 @@ const lightTemplate = {
|
|
|
126
145
|
backgroundPress: 4,
|
|
127
146
|
|
|
128
147
|
// our light color palette is... a bit unique
|
|
129
|
-
borderColor:
|
|
130
|
-
borderColorHover:
|
|
131
|
-
borderColorFocus:
|
|
132
|
-
borderColorPress:
|
|
148
|
+
borderColor: 6,
|
|
149
|
+
borderColorHover: 7,
|
|
150
|
+
borderColorFocus: 5,
|
|
151
|
+
borderColorPress: 6,
|
|
152
|
+
...lightShadows,
|
|
133
153
|
}
|
|
134
154
|
|
|
135
|
-
const darkTemplate = { ...template }
|
|
155
|
+
const darkTemplate = { ...template, ...darkShadows }
|
|
136
156
|
|
|
137
157
|
const light = createTheme(palettes.light, lightTemplate)
|
|
138
158
|
const dark = createTheme(palettes.dark, darkTemplate)
|
|
@@ -176,8 +196,8 @@ const [lightColorThemes, darkColorThemes] = [colorTokens.light, colorTokens.dark
|
|
|
176
196
|
const colorPalette = Object.values(colorSet[color]) as string[]
|
|
177
197
|
// were re-ordering these
|
|
178
198
|
const [head, tail] = [
|
|
179
|
-
colorPalette.slice(0,
|
|
180
|
-
colorPalette.slice(colorPalette.length -
|
|
199
|
+
colorPalette.slice(0, 6),
|
|
200
|
+
colorPalette.slice(colorPalette.length - 5),
|
|
181
201
|
]
|
|
182
202
|
// add our transparent colors first/last
|
|
183
203
|
// and make sure the last (foreground) color is white/black rather than colorful
|
|
@@ -225,11 +245,13 @@ const allThemes = addChildren(baseThemes, (name, theme) => {
|
|
|
225
245
|
inverse,
|
|
226
246
|
isLight,
|
|
227
247
|
}),
|
|
248
|
+
...getComponentThemes(colorTheme, inverse, isLight),
|
|
228
249
|
}
|
|
229
250
|
})
|
|
230
251
|
|
|
231
252
|
const baseSubThemes = {
|
|
232
253
|
...getAltThemes({ theme, inverse: inverseTheme, isLight }),
|
|
254
|
+
...getComponentThemes(theme, inverseTheme, isLight),
|
|
233
255
|
}
|
|
234
256
|
|
|
235
257
|
return {
|
|
@@ -271,7 +293,76 @@ function getAltThemes({
|
|
|
271
293
|
})
|
|
272
294
|
})())
|
|
273
295
|
|
|
274
|
-
return { alt1, alt2, active }
|
|
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, componentMaskOptions)
|
|
314
|
+
const stronger1 = applyMask(theme, masks.stronger, componentMaskOptions)
|
|
315
|
+
const inverse1 = applyMask(inverse, masks.weaker, componentMaskOptions)
|
|
316
|
+
const inverse2 = applyMask(inverse1, masks.weaker, componentMaskOptions)
|
|
317
|
+
const strongerBorderLighterBackground: SubTheme = isLight
|
|
318
|
+
? {
|
|
319
|
+
...stronger1,
|
|
320
|
+
borderColor: weaker1.borderColor,
|
|
321
|
+
borderColorHover: weaker1.borderColorHover,
|
|
322
|
+
borderColorPress: weaker1.borderColorPress,
|
|
323
|
+
borderColorFocus: weaker1.borderColorFocus,
|
|
324
|
+
}
|
|
325
|
+
: {
|
|
326
|
+
...applyMask(theme, masks.skip, componentMaskOptions),
|
|
327
|
+
borderColor: weaker1.borderColor,
|
|
328
|
+
borderColorHover: weaker1.borderColorHover,
|
|
329
|
+
borderColorPress: weaker1.borderColorPress,
|
|
330
|
+
borderColorFocus: weaker1.borderColorFocus,
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const overlayTheme = {
|
|
334
|
+
background: isLight ? 'rgba(0,0,0,0.5)' : 'rgba(0,0,0,0.9)',
|
|
335
|
+
} as SubTheme
|
|
336
|
+
|
|
337
|
+
const weaker2WithoutBorder = {
|
|
338
|
+
...weaker2,
|
|
339
|
+
borderColor: 'transparent',
|
|
340
|
+
borderColorHover: 'transparent',
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return {
|
|
344
|
+
ListItem: isLight ? stronger1 : base,
|
|
345
|
+
Card: weaker1,
|
|
346
|
+
Button: weaker2WithoutBorder,
|
|
347
|
+
Checkbox: weaker2,
|
|
348
|
+
DrawerFrame: weaker1,
|
|
349
|
+
SliderTrack: stronger1,
|
|
350
|
+
SliderTrackActive: weaker2,
|
|
351
|
+
SliderThumb: inverse1,
|
|
352
|
+
Progress: weaker1,
|
|
353
|
+
ProgressIndicator: inverse,
|
|
354
|
+
Switch: weaker2,
|
|
355
|
+
SwitchThumb: inverse2,
|
|
356
|
+
TooltipArrow: weaker1,
|
|
357
|
+
TooltipContent: weaker2,
|
|
358
|
+
Input: strongerBorderLighterBackground,
|
|
359
|
+
TextArea: strongerBorderLighterBackground,
|
|
360
|
+
Tooltip: inverse1,
|
|
361
|
+
// make overlays always dark
|
|
362
|
+
SheetOverlay: overlayTheme,
|
|
363
|
+
DialogOverlay: overlayTheme,
|
|
364
|
+
ModalOverlay: overlayTheme,
|
|
365
|
+
}
|
|
275
366
|
}
|
|
276
367
|
|
|
277
368
|
export const themes = {
|