@tamagui/themes 1.4.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.
@@ -0,0 +1,202 @@
1
+ import {
2
+ addChildren,
3
+ applyMask,
4
+ createStrengthenMask,
5
+ createTheme,
6
+ createWeakenMask
7
+ } from "@tamagui/create-theme";
8
+ import { colorTokens, darkColors, lightColors } from "./tokens";
9
+ const lightTransparent = "rgba(255,255,255,0)";
10
+ const darkTransparent = "rgba(10,10,10,0)";
11
+ const palettes = {
12
+ dark: [
13
+ darkTransparent,
14
+ "#090909",
15
+ "#151515",
16
+ "#191919",
17
+ "#232323",
18
+ "#282828",
19
+ "#323232",
20
+ "#424242",
21
+ "#494949",
22
+ "#545454",
23
+ "#626262",
24
+ "#a5a5a5",
25
+ "#fff",
26
+ lightTransparent
27
+ ],
28
+ light: [
29
+ lightTransparent,
30
+ "#fff",
31
+ "#f4f4f4",
32
+ "hsl(0, 0%, 99.0%)",
33
+ "hsl(0, 0%, 97.3%)",
34
+ "hsl(0, 0%, 95.1%)",
35
+ "hsl(0, 0%, 93.0%)",
36
+ "hsl(0, 0%, 90.9%)",
37
+ "hsl(0, 0%, 80.0%)",
38
+ "hsl(0, 0%, 56.1%)",
39
+ "hsl(0, 0%, 52.3%)",
40
+ "hsl(0, 0%, 43.5%)",
41
+ "hsl(0, 0%, 9.0%)",
42
+ darkTransparent
43
+ ]
44
+ };
45
+ const colorScale = {
46
+ color1: 1,
47
+ color2: 2,
48
+ color3: 3,
49
+ color4: 4,
50
+ color5: 5,
51
+ color6: 6,
52
+ color7: 7,
53
+ color8: 8,
54
+ color9: 9,
55
+ color10: 10,
56
+ color11: 11,
57
+ color12: 12
58
+ };
59
+ const skip = {
60
+ ...colorScale,
61
+ shadowColor: 1,
62
+ shadowColorHover: 1,
63
+ shadowColorPress: 2,
64
+ shadowColorFocus: 2
65
+ };
66
+ const template = {
67
+ ...skip,
68
+ // the background, color, etc keys here work like generics - they make it so you
69
+ // can publish components for others to use without mandating a specific color scale
70
+ // the @tamagui/button Button component looks for `$background`, so you set the
71
+ // dark_red_Button theme to have a stronger background than the dark_red theme.
72
+ background: 2,
73
+ backgroundHover: 3,
74
+ backgroundPress: 1,
75
+ backgroundFocus: 2,
76
+ backgroundStrong: 1,
77
+ backgroundTransparent: 0,
78
+ color: -1,
79
+ colorHover: -2,
80
+ colorPress: -1,
81
+ colorFocus: -2,
82
+ colorTransparent: -0,
83
+ borderColor: 3,
84
+ borderColorHover: 4,
85
+ borderColorPress: 2,
86
+ borderColorFocus: 3,
87
+ placeholderColor: -4
88
+ };
89
+ const lightShadowColor = "rgba(0,0,0,0.15)";
90
+ const lightShadowColorStrong = "rgba(0,0,0,0.2)";
91
+ const darkShadowColor = "rgba(0,0,0,0.5)";
92
+ const darkShadowColorStrong = "rgba(0,0,0,0.7)";
93
+ const lightShadows = {
94
+ shadowColor: lightShadowColorStrong,
95
+ shadowColorHover: lightShadowColorStrong,
96
+ shadowColorPress: lightShadowColor,
97
+ shadowColorFocus: lightShadowColor
98
+ };
99
+ const darkShadows = {
100
+ shadowColor: darkShadowColorStrong,
101
+ shadowColorHover: darkShadowColorStrong,
102
+ shadowColorPress: darkShadowColor,
103
+ shadowColorFocus: darkShadowColor
104
+ };
105
+ const lightTemplate = {
106
+ ...template,
107
+ ...lightShadows
108
+ };
109
+ const darkTemplate = { ...template, ...darkShadows };
110
+ const light = createTheme(palettes.light, lightTemplate, {
111
+ nonInheritedValues: lightColors
112
+ });
113
+ const dark = createTheme(palettes.dark, darkTemplate, { nonInheritedValues: darkColors });
114
+ const baseThemes = {
115
+ light,
116
+ dark
117
+ };
118
+ const max = palettes.dark.length - 1;
119
+ const masks = {
120
+ weaker: createWeakenMask({
121
+ by: 1,
122
+ min: 1,
123
+ max
124
+ }),
125
+ stronger: createStrengthenMask({
126
+ by: 1,
127
+ min: 1,
128
+ max
129
+ })
130
+ };
131
+ const themes = addChildren(baseThemes, (name, themeIn) => {
132
+ const theme = themeIn;
133
+ const inverseName = name === "light" ? "dark" : "light";
134
+ const inverseTheme = baseThemes[inverseName];
135
+ const transparent = (hsl, opacity = 0) => hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`);
136
+ const [colorThemes, inverseColorThemes] = [
137
+ colorTokens[name],
138
+ colorTokens[inverseName]
139
+ ].map((colorSet) => {
140
+ return Object.fromEntries(
141
+ Object.keys(colorSet).map((color) => {
142
+ const colorPalette = Object.values(colorSet[color]);
143
+ const first6 = colorPalette.slice(0, 6);
144
+ const last5 = colorPalette.slice(colorPalette.length - 5);
145
+ return [
146
+ color,
147
+ createTheme(
148
+ [
149
+ transparent(colorPalette[0]),
150
+ ...first6,
151
+ ...last5,
152
+ theme.color,
153
+ transparent(colorPalette[colorPalette.length - 1])
154
+ ],
155
+ template
156
+ )
157
+ ];
158
+ })
159
+ );
160
+ });
161
+ return {
162
+ ...getAltThemes(theme, inverseTheme),
163
+ ...getComponentThemes(theme, inverseTheme),
164
+ ...addChildren(colorThemes, (colorName, colorTheme) => {
165
+ const inverse = inverseColorThemes[colorName];
166
+ return {
167
+ ...getAltThemes(colorTheme, inverse),
168
+ ...getComponentThemes(colorTheme, inverse)
169
+ };
170
+ })
171
+ };
172
+ function getComponentThemes(theme2, inverse) {
173
+ const stronger1 = applyMask(theme2, masks.stronger, { skip });
174
+ const stronger2 = applyMask(stronger1, masks.stronger, { skip });
175
+ const inverse1 = applyMask(inverse, masks.weaker, { skip });
176
+ const inverse2 = applyMask(inverse1, masks.weaker, { skip });
177
+ return {
178
+ Button: stronger2,
179
+ DrawerFrame: stronger1,
180
+ SliderTrack: theme2,
181
+ SliderTrackActive: stronger2,
182
+ SliderThumb: inverse1,
183
+ Progress: stronger1,
184
+ ProgressIndicator: inverse,
185
+ Switch: stronger2,
186
+ SwitchThumb: inverse2,
187
+ TooltipArrow: stronger1,
188
+ TooltipContent: stronger2
189
+ };
190
+ }
191
+ function getAltThemes(theme2, inverse) {
192
+ const alt1 = applyMask(theme2, masks.weaker, { skip });
193
+ const alt2 = applyMask(alt1, masks.weaker, { skip });
194
+ return addChildren({ alt1, alt2 }, (name2, theme3) => {
195
+ return getComponentThemes(theme3, inverse);
196
+ });
197
+ }
198
+ });
199
+ export {
200
+ themes
201
+ };
202
+ //# sourceMappingURL=themes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themes.tsx"],
4
+ "sourcesContent": ["import {\n addChildren,\n applyMask,\n createStrengthenMask,\n createTheme,\n createWeakenMask,\n} from '@tamagui/create-theme'\n\nimport { colorTokens, darkColors, lightColors } from './tokens'\n\ntype ColorName = keyof typeof colorTokens.dark\n\nconst lightTransparent = 'rgba(255,255,255,0)'\nconst darkTransparent = 'rgba(10,10,10,0)'\n\n// background => foreground\nconst palettes = {\n dark: [\n darkTransparent,\n '#090909',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#a5a5a5',\n '#fff',\n lightTransparent,\n ],\n light: [\n lightTransparent,\n '#fff',\n '#f4f4f4',\n 'hsl(0, 0%, 99.0%)',\n 'hsl(0, 0%, 97.3%)',\n 'hsl(0, 0%, 95.1%)',\n 'hsl(0, 0%, 93.0%)',\n 'hsl(0, 0%, 90.9%)',\n 'hsl(0, 0%, 80.0%)',\n 'hsl(0, 0%, 56.1%)',\n 'hsl(0, 0%, 52.3%)',\n 'hsl(0, 0%, 43.5%)',\n 'hsl(0, 0%, 9.0%)',\n darkTransparent,\n ],\n}\n\nconst colorScale = {\n color1: 1,\n color2: 2,\n color3: 3,\n color4: 4,\n color5: 5,\n color6: 6,\n color7: 7,\n color8: 8,\n color9: 9,\n color10: 10,\n color11: 11,\n color12: 12,\n}\n\n// we can use subset of our template as a \"skip\" so it doesn't get adjusted with masks\nconst skip = {\n ...colorScale,\n shadowColor: 1,\n shadowColorHover: 1,\n shadowColorPress: 2,\n shadowColorFocus: 2,\n}\n\n// templates use the palette and specify index\n// negative goes backwards from end so -1 is the last item\nconst template = {\n ...skip,\n // the background, color, etc keys here work like generics - they make it so you\n // can publish components for others to use without mandating a specific color scale\n // the @tamagui/button Button component looks for `$background`, so you set the\n // dark_red_Button theme to have a stronger background than the dark_red theme.\n background: 2,\n backgroundHover: 3,\n backgroundPress: 1,\n backgroundFocus: 2,\n backgroundStrong: 1,\n backgroundTransparent: 0,\n color: -1,\n colorHover: -2,\n colorPress: -1,\n colorFocus: -2,\n colorTransparent: -0,\n borderColor: 3,\n borderColorHover: 4,\n borderColorPress: 2,\n borderColorFocus: 3,\n placeholderColor: -4,\n}\n\nconst lightShadowColor = 'rgba(0,0,0,0.15)'\nconst lightShadowColorStrong = 'rgba(0,0,0,0.2)'\nconst darkShadowColor = 'rgba(0,0,0,0.5)'\nconst darkShadowColorStrong = 'rgba(0,0,0,0.7)'\n\nconst lightShadows = {\n shadowColor: lightShadowColorStrong,\n shadowColorHover: lightShadowColorStrong,\n shadowColorPress: lightShadowColor,\n shadowColorFocus: lightShadowColor,\n}\n\nconst darkShadows = {\n shadowColor: darkShadowColorStrong,\n shadowColorHover: darkShadowColorStrong,\n shadowColorPress: darkShadowColor,\n shadowColorFocus: darkShadowColor,\n}\n\nconst lightTemplate = {\n ...template,\n ...lightShadows,\n}\n\nconst darkTemplate = { ...template, ...darkShadows }\n\nconst light = createTheme(palettes.light, lightTemplate, {\n nonInheritedValues: lightColors,\n})\n\nconst dark = createTheme(palettes.dark, darkTemplate, { nonInheritedValues: darkColors })\n\nconst baseThemes = {\n light,\n dark,\n}\n\ntype Theme = typeof light\n\n// avoid transparent ends\nconst max = palettes.dark.length - 1\nconst masks = {\n weaker: createWeakenMask({\n by: 1,\n min: 1,\n max,\n }),\n stronger: createStrengthenMask({\n by: 1,\n min: 1,\n max,\n }),\n}\n\nexport const themes = addChildren(baseThemes, (name, themeIn) => {\n const theme = themeIn as Theme\n const inverseName = name === 'light' ? 'dark' : 'light'\n const inverseTheme = baseThemes[inverseName]\n const transparent = (hsl: string, opacity = 0) =>\n hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`)\n\n // setup colorThemes and their inverses\n const [colorThemes, inverseColorThemes] = [\n colorTokens[name],\n colorTokens[inverseName],\n ].map((colorSet) => {\n return Object.fromEntries(\n Object.keys(colorSet).map((color) => {\n const colorPalette = Object.values(colorSet[color as ColorName])\n // we want a much lighter text color by default so swap them around a bit\n const first6 = colorPalette.slice(0, 6)\n const last5 = colorPalette.slice(colorPalette.length - 5)\n return [\n color,\n createTheme(\n [\n transparent(colorPalette[0]),\n ...first6,\n ...last5,\n theme.color,\n transparent(colorPalette[colorPalette.length - 1]),\n ],\n template\n ),\n ]\n })\n ) as Record<ColorName, Theme>\n })\n\n return {\n ...getAltThemes(theme, inverseTheme),\n ...getComponentThemes(theme, inverseTheme),\n ...addChildren(colorThemes, (colorName, colorTheme) => {\n const inverse = inverseColorThemes[colorName]\n return {\n ...getAltThemes(colorTheme as any, inverse as any),\n ...getComponentThemes(colorTheme as any, inverse as any),\n }\n }),\n }\n\n function getComponentThemes(theme: Theme, inverse: Theme) {\n const stronger1 = applyMask(theme, masks.stronger, { skip })\n const stronger2 = applyMask(stronger1, masks.stronger, { skip })\n const inverse1 = applyMask(inverse, masks.weaker, { skip })\n const inverse2 = applyMask(inverse1, masks.weaker, { skip })\n return {\n Button: stronger2,\n DrawerFrame: stronger1,\n SliderTrack: theme,\n SliderTrackActive: stronger2,\n SliderThumb: inverse1,\n Progress: stronger1,\n ProgressIndicator: inverse,\n Switch: stronger2,\n SwitchThumb: inverse2,\n TooltipArrow: stronger1,\n TooltipContent: stronger2,\n }\n }\n\n function getAltThemes(theme: Theme, inverse: Theme) {\n const alt1 = applyMask(theme, masks.weaker, { skip })\n const alt2 = applyMask(alt1, masks.weaker, { skip })\n return addChildren({ alt1, alt2 }, (name, theme) => {\n return getComponentThemes(theme as any, inverse)\n })\n }\n})\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA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ClB;AAAA,EACF;AAEA,WAAS,aAAaA,QAAc,SAAgB;AAClD,UAAM,OAAO,UAAUA,QAAO,MAAM,QAAQ,EAAE,KAAK,CAAC;AACpD,UAAM,OAAO,UAAU,MAAM,MAAM,QAAQ,EAAE,KAAK,CAAC;AACnD,WAAO,YAAY,EAAE,MAAM,KAAK,GAAG,CAACC,OAAMD,WAAU;AAClD,aAAO,mBAAmBA,QAAc,OAAO;AAAA,IACjD,CAAC;AAAA,EACH;AACF,CAAC;",
6
+ "names": ["theme", "name"]
7
+ }
@@ -0,0 +1,202 @@
1
+ import {
2
+ addChildren,
3
+ applyMask,
4
+ createStrengthenMask,
5
+ createTheme,
6
+ createWeakenMask
7
+ } from "@tamagui/create-theme";
8
+ import { colorTokens, darkColors, lightColors } from "./tokens";
9
+ const lightTransparent = "rgba(255,255,255,0)";
10
+ const darkTransparent = "rgba(10,10,10,0)";
11
+ const palettes = {
12
+ dark: [
13
+ darkTransparent,
14
+ "#090909",
15
+ "#151515",
16
+ "#191919",
17
+ "#232323",
18
+ "#282828",
19
+ "#323232",
20
+ "#424242",
21
+ "#494949",
22
+ "#545454",
23
+ "#626262",
24
+ "#a5a5a5",
25
+ "#fff",
26
+ lightTransparent
27
+ ],
28
+ light: [
29
+ lightTransparent,
30
+ "#fff",
31
+ "#f4f4f4",
32
+ "hsl(0, 0%, 99.0%)",
33
+ "hsl(0, 0%, 97.3%)",
34
+ "hsl(0, 0%, 95.1%)",
35
+ "hsl(0, 0%, 93.0%)",
36
+ "hsl(0, 0%, 90.9%)",
37
+ "hsl(0, 0%, 80.0%)",
38
+ "hsl(0, 0%, 56.1%)",
39
+ "hsl(0, 0%, 52.3%)",
40
+ "hsl(0, 0%, 43.5%)",
41
+ "hsl(0, 0%, 9.0%)",
42
+ darkTransparent
43
+ ]
44
+ };
45
+ const colorScale = {
46
+ color1: 1,
47
+ color2: 2,
48
+ color3: 3,
49
+ color4: 4,
50
+ color5: 5,
51
+ color6: 6,
52
+ color7: 7,
53
+ color8: 8,
54
+ color9: 9,
55
+ color10: 10,
56
+ color11: 11,
57
+ color12: 12
58
+ };
59
+ const skip = {
60
+ ...colorScale,
61
+ shadowColor: 1,
62
+ shadowColorHover: 1,
63
+ shadowColorPress: 2,
64
+ shadowColorFocus: 2
65
+ };
66
+ const template = {
67
+ ...skip,
68
+ // the background, color, etc keys here work like generics - they make it so you
69
+ // can publish components for others to use without mandating a specific color scale
70
+ // the @tamagui/button Button component looks for `$background`, so you set the
71
+ // dark_red_Button theme to have a stronger background than the dark_red theme.
72
+ background: 2,
73
+ backgroundHover: 3,
74
+ backgroundPress: 1,
75
+ backgroundFocus: 2,
76
+ backgroundStrong: 1,
77
+ backgroundTransparent: 0,
78
+ color: -1,
79
+ colorHover: -2,
80
+ colorPress: -1,
81
+ colorFocus: -2,
82
+ colorTransparent: -0,
83
+ borderColor: 3,
84
+ borderColorHover: 4,
85
+ borderColorPress: 2,
86
+ borderColorFocus: 3,
87
+ placeholderColor: -4
88
+ };
89
+ const lightShadowColor = "rgba(0,0,0,0.15)";
90
+ const lightShadowColorStrong = "rgba(0,0,0,0.2)";
91
+ const darkShadowColor = "rgba(0,0,0,0.5)";
92
+ const darkShadowColorStrong = "rgba(0,0,0,0.7)";
93
+ const lightShadows = {
94
+ shadowColor: lightShadowColorStrong,
95
+ shadowColorHover: lightShadowColorStrong,
96
+ shadowColorPress: lightShadowColor,
97
+ shadowColorFocus: lightShadowColor
98
+ };
99
+ const darkShadows = {
100
+ shadowColor: darkShadowColorStrong,
101
+ shadowColorHover: darkShadowColorStrong,
102
+ shadowColorPress: darkShadowColor,
103
+ shadowColorFocus: darkShadowColor
104
+ };
105
+ const lightTemplate = {
106
+ ...template,
107
+ ...lightShadows
108
+ };
109
+ const darkTemplate = { ...template, ...darkShadows };
110
+ const light = createTheme(palettes.light, lightTemplate, {
111
+ nonInheritedValues: lightColors
112
+ });
113
+ const dark = createTheme(palettes.dark, darkTemplate, { nonInheritedValues: darkColors });
114
+ const baseThemes = {
115
+ light,
116
+ dark
117
+ };
118
+ const max = palettes.dark.length - 1;
119
+ const masks = {
120
+ weaker: createWeakenMask({
121
+ by: 1,
122
+ min: 1,
123
+ max
124
+ }),
125
+ stronger: createStrengthenMask({
126
+ by: 1,
127
+ min: 1,
128
+ max
129
+ })
130
+ };
131
+ const themes = addChildren(baseThemes, (name, themeIn) => {
132
+ const theme = themeIn;
133
+ const inverseName = name === "light" ? "dark" : "light";
134
+ const inverseTheme = baseThemes[inverseName];
135
+ const transparent = (hsl, opacity = 0) => hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`);
136
+ const [colorThemes, inverseColorThemes] = [
137
+ colorTokens[name],
138
+ colorTokens[inverseName]
139
+ ].map((colorSet) => {
140
+ return Object.fromEntries(
141
+ Object.keys(colorSet).map((color) => {
142
+ const colorPalette = Object.values(colorSet[color]);
143
+ const first6 = colorPalette.slice(0, 6);
144
+ const last5 = colorPalette.slice(colorPalette.length - 5);
145
+ return [
146
+ color,
147
+ createTheme(
148
+ [
149
+ transparent(colorPalette[0]),
150
+ ...first6,
151
+ ...last5,
152
+ theme.color,
153
+ transparent(colorPalette[colorPalette.length - 1])
154
+ ],
155
+ template
156
+ )
157
+ ];
158
+ })
159
+ );
160
+ });
161
+ return {
162
+ ...getAltThemes(theme, inverseTheme),
163
+ ...getComponentThemes(theme, inverseTheme),
164
+ ...addChildren(colorThemes, (colorName, colorTheme) => {
165
+ const inverse = inverseColorThemes[colorName];
166
+ return {
167
+ ...getAltThemes(colorTheme, inverse),
168
+ ...getComponentThemes(colorTheme, inverse)
169
+ };
170
+ })
171
+ };
172
+ function getComponentThemes(theme2, inverse) {
173
+ const stronger1 = applyMask(theme2, masks.stronger, { skip });
174
+ const stronger2 = applyMask(stronger1, masks.stronger, { skip });
175
+ const inverse1 = applyMask(inverse, masks.weaker, { skip });
176
+ const inverse2 = applyMask(inverse1, masks.weaker, { skip });
177
+ return {
178
+ Button: stronger2,
179
+ DrawerFrame: stronger1,
180
+ SliderTrack: theme2,
181
+ SliderTrackActive: stronger2,
182
+ SliderThumb: inverse1,
183
+ Progress: stronger1,
184
+ ProgressIndicator: inverse,
185
+ Switch: stronger2,
186
+ SwitchThumb: inverse2,
187
+ TooltipArrow: stronger1,
188
+ TooltipContent: stronger2
189
+ };
190
+ }
191
+ function getAltThemes(theme2, inverse) {
192
+ const alt1 = applyMask(theme2, masks.weaker, { skip });
193
+ const alt2 = applyMask(alt1, masks.weaker, { skip });
194
+ return addChildren({ alt1, alt2 }, (name2, theme3) => {
195
+ return getComponentThemes(theme3, inverse);
196
+ });
197
+ }
198
+ });
199
+ export {
200
+ themes
201
+ };
202
+ //# sourceMappingURL=themes.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themes.tsx"],
4
+ "sourcesContent": ["import {\n addChildren,\n applyMask,\n createStrengthenMask,\n createTheme,\n createWeakenMask,\n} from '@tamagui/create-theme'\n\nimport { colorTokens, darkColors, lightColors } from './tokens'\n\ntype ColorName = keyof typeof colorTokens.dark\n\nconst lightTransparent = 'rgba(255,255,255,0)'\nconst darkTransparent = 'rgba(10,10,10,0)'\n\n// background => foreground\nconst palettes = {\n dark: [\n darkTransparent,\n '#090909',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#a5a5a5',\n '#fff',\n lightTransparent,\n ],\n light: [\n lightTransparent,\n '#fff',\n '#f4f4f4',\n 'hsl(0, 0%, 99.0%)',\n 'hsl(0, 0%, 97.3%)',\n 'hsl(0, 0%, 95.1%)',\n 'hsl(0, 0%, 93.0%)',\n 'hsl(0, 0%, 90.9%)',\n 'hsl(0, 0%, 80.0%)',\n 'hsl(0, 0%, 56.1%)',\n 'hsl(0, 0%, 52.3%)',\n 'hsl(0, 0%, 43.5%)',\n 'hsl(0, 0%, 9.0%)',\n darkTransparent,\n ],\n}\n\nconst colorScale = {\n color1: 1,\n color2: 2,\n color3: 3,\n color4: 4,\n color5: 5,\n color6: 6,\n color7: 7,\n color8: 8,\n color9: 9,\n color10: 10,\n color11: 11,\n color12: 12,\n}\n\n// we can use subset of our template as a \"skip\" so it doesn't get adjusted with masks\nconst skip = {\n ...colorScale,\n shadowColor: 1,\n shadowColorHover: 1,\n shadowColorPress: 2,\n shadowColorFocus: 2,\n}\n\n// templates use the palette and specify index\n// negative goes backwards from end so -1 is the last item\nconst template = {\n ...skip,\n // the background, color, etc keys here work like generics - they make it so you\n // can publish components for others to use without mandating a specific color scale\n // the @tamagui/button Button component looks for `$background`, so you set the\n // dark_red_Button theme to have a stronger background than the dark_red theme.\n background: 2,\n backgroundHover: 3,\n backgroundPress: 1,\n backgroundFocus: 2,\n backgroundStrong: 1,\n backgroundTransparent: 0,\n color: -1,\n colorHover: -2,\n colorPress: -1,\n colorFocus: -2,\n colorTransparent: -0,\n borderColor: 3,\n borderColorHover: 4,\n borderColorPress: 2,\n borderColorFocus: 3,\n placeholderColor: -4,\n}\n\nconst lightShadowColor = 'rgba(0,0,0,0.15)'\nconst lightShadowColorStrong = 'rgba(0,0,0,0.2)'\nconst darkShadowColor = 'rgba(0,0,0,0.5)'\nconst darkShadowColorStrong = 'rgba(0,0,0,0.7)'\n\nconst lightShadows = {\n shadowColor: lightShadowColorStrong,\n shadowColorHover: lightShadowColorStrong,\n shadowColorPress: lightShadowColor,\n shadowColorFocus: lightShadowColor,\n}\n\nconst darkShadows = {\n shadowColor: darkShadowColorStrong,\n shadowColorHover: darkShadowColorStrong,\n shadowColorPress: darkShadowColor,\n shadowColorFocus: darkShadowColor,\n}\n\nconst lightTemplate = {\n ...template,\n ...lightShadows,\n}\n\nconst darkTemplate = { ...template, ...darkShadows }\n\nconst light = createTheme(palettes.light, lightTemplate, {\n nonInheritedValues: lightColors,\n})\n\nconst dark = createTheme(palettes.dark, darkTemplate, { nonInheritedValues: darkColors })\n\nconst baseThemes = {\n light,\n dark,\n}\n\ntype Theme = typeof light\n\n// avoid transparent ends\nconst max = palettes.dark.length - 1\nconst masks = {\n weaker: createWeakenMask({\n by: 1,\n min: 1,\n max,\n }),\n stronger: createStrengthenMask({\n by: 1,\n min: 1,\n max,\n }),\n}\n\nexport const themes = addChildren(baseThemes, (name, themeIn) => {\n const theme = themeIn as Theme\n const inverseName = name === 'light' ? 'dark' : 'light'\n const inverseTheme = baseThemes[inverseName]\n const transparent = (hsl: string, opacity = 0) =>\n hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`)\n\n // setup colorThemes and their inverses\n const [colorThemes, inverseColorThemes] = [\n colorTokens[name],\n colorTokens[inverseName],\n ].map((colorSet) => {\n return Object.fromEntries(\n Object.keys(colorSet).map((color) => {\n const colorPalette = Object.values(colorSet[color as ColorName])\n // we want a much lighter text color by default so swap them around a bit\n const first6 = colorPalette.slice(0, 6)\n const last5 = colorPalette.slice(colorPalette.length - 5)\n return [\n color,\n createTheme(\n [\n transparent(colorPalette[0]),\n ...first6,\n ...last5,\n theme.color,\n transparent(colorPalette[colorPalette.length - 1]),\n ],\n template\n ),\n ]\n })\n ) as Record<ColorName, Theme>\n })\n\n return {\n ...getAltThemes(theme, inverseTheme),\n ...getComponentThemes(theme, inverseTheme),\n ...addChildren(colorThemes, (colorName, colorTheme) => {\n const inverse = inverseColorThemes[colorName]\n return {\n ...getAltThemes(colorTheme as any, inverse as any),\n ...getComponentThemes(colorTheme as any, inverse as any),\n }\n }),\n }\n\n function getComponentThemes(theme: Theme, inverse: Theme) {\n const stronger1 = applyMask(theme, masks.stronger, { skip })\n const stronger2 = applyMask(stronger1, masks.stronger, { skip })\n const inverse1 = applyMask(inverse, masks.weaker, { skip })\n const inverse2 = applyMask(inverse1, masks.weaker, { skip })\n return {\n Button: stronger2,\n DrawerFrame: stronger1,\n SliderTrack: theme,\n SliderTrackActive: stronger2,\n SliderThumb: inverse1,\n Progress: stronger1,\n ProgressIndicator: inverse,\n Switch: stronger2,\n SwitchThumb: inverse2,\n TooltipArrow: stronger1,\n TooltipContent: stronger2,\n }\n }\n\n function getAltThemes(theme: Theme, inverse: Theme) {\n const alt1 = applyMask(theme, masks.weaker, { skip })\n const alt2 = applyMask(alt1, masks.weaker, { skip })\n return addChildren({ alt1, alt2 }, (name, theme) => {\n return getComponentThemes(theme as any, inverse)\n })\n }\n})\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,aAAa,YAAY,mBAAmB;AAIrD,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AAGxB,MAAM,WAAW;AAAA,EACf,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,aAAa;AAAA,EACjB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX;AAGA,MAAM,OAAO;AAAA,EACX,GAAG;AAAA,EACH,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,kBAAkB;AACpB;AAIA,MAAM,WAAW;AAAA,EACf,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA,EAKH,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,iBAAiB;AAAA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AAE,KAAK,CAAC;AAC3D,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,aAAaA;AAAA,MACb,mBAAmB;AAAA,MACnB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,mBAAmB;AAAA,MACnB,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,cAAc;AAAA,MACd,gBAAgB;AAAA,IAClB;AAAA,EACF;AAEA,WAAS,aAAaA,QAAc,SAAgB;AAClD,UAAM,OAAO,UAAUA,QAAO,MAAM,QAAQ,EAAE,KAAK,CAAC;AACpD,UAAM,OAAO,UAAU,MAAM,MAAM,QAAQ,EAAE,KAAK,CAAC;AACnD,WAAO,YAAY,EAAE,MAAM,KAAK,GAAG,CAACC,OAAMD,WAAU;AAClD,aAAO,mBAAmBA,QAAc,OAAO;AAAA,IACjD,CAAC;AAAA,EACH;AACF,CAAC;",
6
+ "names": ["theme", "name"]
7
+ }
@@ -0,0 +1,165 @@
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 { createTokens } from "@tamagui/web";
20
+ const size = {
21
+ $0: 0,
22
+ "$0.25": 2,
23
+ "$0.5": 4,
24
+ "$0.75": 8,
25
+ $1: 20,
26
+ "$1.5": 24,
27
+ $2: 28,
28
+ "$2.5": 32,
29
+ $3: 36,
30
+ "$3.5": 40,
31
+ $4: 44,
32
+ $true: 44,
33
+ "$4.5": 48,
34
+ $5: 52,
35
+ $6: 64,
36
+ $7: 74,
37
+ $8: 84,
38
+ $9: 94,
39
+ $10: 104,
40
+ $11: 124,
41
+ $12: 144,
42
+ $13: 164,
43
+ $14: 184,
44
+ $15: 204,
45
+ $16: 224,
46
+ $17: 224,
47
+ $18: 244,
48
+ $19: 264,
49
+ $20: 284
50
+ };
51
+ const spaces = Object.entries(size).map(([k, v]) => {
52
+ return [k, sizeToSpace(v)];
53
+ });
54
+ function sizeToSpace(v) {
55
+ if (v === 0)
56
+ return 0;
57
+ if (v === 2)
58
+ return 0.5;
59
+ if (v === 4)
60
+ return 1;
61
+ if (v === 8)
62
+ return 1.5;
63
+ if (v <= 16)
64
+ return Math.round(v * 0.333);
65
+ return Math.floor(v * 0.7 - 12);
66
+ }
67
+ const spacesNegative = spaces.map(([k, v]) => [`-${k.slice(1)}`, -v]);
68
+ const space = {
69
+ ...Object.fromEntries(spaces),
70
+ ...Object.fromEntries(spacesNegative)
71
+ };
72
+ const zIndex = {
73
+ 0: 0,
74
+ 1: 100,
75
+ 2: 200,
76
+ 3: 300,
77
+ 4: 400,
78
+ 5: 500
79
+ };
80
+ const colorTokens = {
81
+ light: {
82
+ blue,
83
+ gray,
84
+ green,
85
+ orange,
86
+ pink,
87
+ purple,
88
+ red,
89
+ yellow
90
+ },
91
+ dark: {
92
+ blue: blueDark,
93
+ gray: grayDark,
94
+ green: greenDark,
95
+ orange: orangeDark,
96
+ pink: pinkDark,
97
+ purple: purpleDark,
98
+ red: redDark,
99
+ yellow: yellowDark
100
+ }
101
+ };
102
+ const darkColors = {
103
+ ...colorTokens.dark.blue,
104
+ ...colorTokens.dark.gray,
105
+ ...colorTokens.dark.green,
106
+ ...colorTokens.dark.orange,
107
+ ...colorTokens.dark.pink,
108
+ ...colorTokens.dark.purple,
109
+ ...colorTokens.dark.red,
110
+ ...colorTokens.dark.yellow
111
+ };
112
+ const lightColors = {
113
+ ...colorTokens.light.blue,
114
+ ...colorTokens.light.gray,
115
+ ...colorTokens.light.green,
116
+ ...colorTokens.light.orange,
117
+ ...colorTokens.light.pink,
118
+ ...colorTokens.light.purple,
119
+ ...colorTokens.light.red,
120
+ ...colorTokens.light.yellow
121
+ };
122
+ const color = {
123
+ ...postfixObjKeys(lightColors, "Light"),
124
+ ...postfixObjKeys(darkColors, "Dark")
125
+ };
126
+ function postfixObjKeys(obj, postfix) {
127
+ return Object.fromEntries(
128
+ Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])
129
+ );
130
+ }
131
+ const radius = {
132
+ 0: 0,
133
+ 1: 3,
134
+ 2: 5,
135
+ 3: 7,
136
+ 4: 9,
137
+ true: 9,
138
+ 5: 10,
139
+ 6: 16,
140
+ 7: 19,
141
+ 8: 22,
142
+ 9: 26,
143
+ 10: 34,
144
+ 11: 42,
145
+ 12: 50
146
+ };
147
+ const tokens = createTokens({
148
+ color,
149
+ radius,
150
+ zIndex,
151
+ space,
152
+ size
153
+ });
154
+ export {
155
+ color,
156
+ colorTokens,
157
+ darkColors,
158
+ lightColors,
159
+ radius,
160
+ size,
161
+ space,
162
+ tokens,
163
+ zIndex
164
+ };
165
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tokens.tsx"],
4
+ "sourcesContent": ["import {\n blue,\n blueDark,\n gray,\n grayDark,\n green,\n greenDark,\n orange,\n orangeDark,\n pink,\n pinkDark,\n purple,\n purpleDark,\n red,\n redDark,\n yellow,\n yellowDark,\n} from '@tamagui/colors'\nimport { Variable, createTokens } from '@tamagui/web'\n\n// should roughly map to button/input etc height at each level\n// fonts should match that height/lineHeight at each stop\n// so these are really non-linear on purpose\n// why?\n// - at sizes <1, used for fine grained things (borders, smallest paddingY)\n// - so smallest padY should be roughly 1-4px so it can join with lineHeight\n// - at sizes >=1, have to consider \"pressability\" (jumps up)\n// - after that it should go upwards somewhat naturally\n// - H1 / headings top out at 10 naturally, so after 10 we can go upwards faster\n// but also one more wrinkle...\n// space is used in conjunction with size\n// i'm setting space to generally just a fixed fraction of size (~1/3-2/3 still fine tuning)\nexport const size = {\n $0: 0,\n '$0.25': 2,\n '$0.5': 4,\n '$0.75': 8,\n $1: 20,\n '$1.5': 24,\n $2: 28,\n '$2.5': 32,\n $3: 36,\n '$3.5': 40,\n $4: 44,\n $true: 44,\n '$4.5': 48,\n $5: 52,\n $6: 64,\n $7: 74,\n $8: 84,\n $9: 94,\n $10: 104,\n $11: 124,\n $12: 144,\n $13: 164,\n $14: 184,\n $15: 204,\n $16: 224,\n $17: 224,\n $18: 244,\n $19: 264,\n $20: 284,\n}\n\ntype SizeKeysIn = keyof typeof size\ntype Sizes = {\n [Key in SizeKeysIn extends `$${infer Key}` ? Key : SizeKeysIn]: number\n}\ntype SizeKeys = `${keyof Sizes extends `${infer K}` ? K : never}`\n\nconst spaces = Object.entries(size).map(([k, v]) => {\n return [k, sizeToSpace(v)]\n})\n\n// a bit odd but keeping backward compat for values >8 while fixing below\nfunction sizeToSpace(v: number) {\n if (v === 0) return 0\n if (v === 2) return 0.5\n if (v === 4) return 1\n if (v === 8) return 1.5\n if (v <= 16) return Math.round(v * 0.333)\n return Math.floor(v * 0.7 - 12)\n}\n\nconst spacesNegative = spaces.map(([k, v]) => [`-${(k as string).slice(1)}`, -v])\n\ntype SizeKeysWithNegatives =\n | `-${SizeKeys extends `$${infer Key}` ? Key : SizeKeys}`\n | SizeKeys\n\nexport const space: {\n [Key in SizeKeysWithNegatives]: Key extends keyof Sizes ? Sizes[Key] : number\n} = {\n ...Object.fromEntries(spaces),\n ...Object.fromEntries(spacesNegative),\n} as any\n\nexport const zIndex = {\n 0: 0,\n 1: 100,\n 2: 200,\n 3: 300,\n 4: 400,\n 5: 500,\n}\n\nexport const colorTokens = {\n light: {\n blue: blue,\n gray: gray,\n green: green,\n orange: orange,\n pink: pink,\n purple: purple,\n red: red,\n yellow: yellow,\n },\n dark: {\n blue: blueDark,\n gray: grayDark,\n green: greenDark,\n orange: orangeDark,\n pink: pinkDark,\n purple: purpleDark,\n red: redDark,\n yellow: yellowDark,\n },\n}\n\nexport const darkColors = {\n ...colorTokens.dark.blue,\n ...colorTokens.dark.gray,\n ...colorTokens.dark.green,\n ...colorTokens.dark.orange,\n ...colorTokens.dark.pink,\n ...colorTokens.dark.purple,\n ...colorTokens.dark.red,\n ...colorTokens.dark.yellow,\n}\n\nexport const lightColors = {\n ...colorTokens.light.blue,\n ...colorTokens.light.gray,\n ...colorTokens.light.green,\n ...colorTokens.light.orange,\n ...colorTokens.light.pink,\n ...colorTokens.light.purple,\n ...colorTokens.light.red,\n ...colorTokens.light.yellow,\n}\n\nexport const color = {\n ...postfixObjKeys(lightColors, 'Light'),\n ...postfixObjKeys(darkColors, 'Dark'),\n}\n\nfunction postfixObjKeys<\n A extends { [key: string]: Variable<string> | string },\n B extends string\n>(\n obj: A,\n postfix: B\n): {\n [Key in `${keyof A extends string ? keyof A : never}${B}`]: Variable<string> | string\n} {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])\n ) as any\n}\n\nexport const radius = {\n 0: 0,\n 1: 3,\n 2: 5,\n 3: 7,\n 4: 9,\n true: 9,\n 5: 10,\n 6: 16,\n 7: 19,\n 8: 22,\n 9: 26,\n 10: 34,\n 11: 42,\n 12: 50,\n}\n\nexport const tokens = createTokens({\n color,\n radius,\n zIndex,\n space,\n size,\n})\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAmB,oBAAoB;AAchC,MAAM,OAAO;AAAA,EAClB,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA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