@tamagui/theme-base 1.0.1-beta.99 → 1.0.1-rc.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/colorUtils.js +2 -1
- package/dist/cjs/colorUtils.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/themes.js +19 -282
- package/dist/cjs/themes.js.map +2 -2
- package/dist/cjs/tokens.js +46 -34
- package/dist/cjs/tokens.js.map +2 -2
- package/dist/esm/colorUtils.js +1 -1
- package/dist/esm/colorUtils.js.map +2 -2
- package/dist/esm/index.js +0 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/themes.js +19 -283
- package/dist/esm/themes.js.map +2 -2
- package/dist/esm/tokens.js +38 -41
- package/dist/esm/tokens.js.map +2 -2
- package/package.json +15 -5
- package/src/colorUtils.tsx +1 -1
- package/src/themes.tsx +18 -380
- package/src/tokens.tsx +7 -30
- package/types/colorUtils.d.ts +0 -0
- package/types/index.d.ts +0 -0
- package/types/themes.d.ts +5925 -3218
- package/types/tokens.d.ts +782 -457
- package/dist/jsx/colorUtils.js +0 -41
- package/dist/jsx/colorUtils.js.map +0 -7
- package/dist/jsx/index.js +0 -4
- package/dist/jsx/index.js.map +0 -7
- package/dist/jsx/themes.js +0 -298
- package/dist/jsx/themes.js.map +0 -7
- package/dist/jsx/tokens.js +0 -167
- package/dist/jsx/tokens.js.map +0 -7
- package/types/colorUtils.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/themes.d.ts.map +0 -1
- package/types/tokens.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/colorUtils.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Variable, getVariableValue } from '@tamagui/core'\n\nexport const hexToRGBA = (hex: string, alpha = 1) => {\n if (!isValidHex(hex)) {\n throw new Error('Invalid HEX')\n }\n const chunkSize = Math.floor((hex.length - 1) / 3)\n const hexArr = getChunksFromString(hex.slice(1), chunkSize)\n const [r, g, b, a] = hexArr?.map(convertHexUnitTo256) ?? []\n return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`\n}\n\nexport const setColorAlpha = (colorIn: string | Variable, alpha = 1) => {\n
|
|
5
|
-
"mappings": "AAAA;
|
|
4
|
+
"sourcesContent": ["import { Variable, getVariableValue } from '@tamagui/core'\n\nexport const hexToRGBA = (hex: string, alpha = 1) => {\n if (!isValidHex(hex)) {\n throw new Error('Invalid HEX')\n }\n const chunkSize = Math.floor((hex.length - 1) / 3)\n const hexArr = getChunksFromString(hex.slice(1), chunkSize)\n const [r, g, b, a] = hexArr?.map(convertHexUnitTo256) ?? []\n return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`\n}\n\nexport const setColorAlpha = (colorIn: string | Variable, alpha = 1) => {\n const color = `${getVariableValue(colorIn)}`\n if (color.startsWith('hsl(')) {\n return color.replace('hsl', 'hsla').replace(')', `, ${alpha})`)\n }\n if (color.startsWith('#')) {\n return hexToRGBA(color, alpha)\n }\n if (color.startsWith('rgb(')) {\n return color.replace('rgb', 'rgba').replace(')', `, ${alpha})`)\n }\n return color\n}\n\nconst isValidHex = (hex: string) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex)\n\nconst getChunksFromString = (st: string, chunkSize = 0) =>\n st.match(new RegExp(`.{${chunkSize}}`, 'g'))\n\nconst convertHexUnitTo256 = (hexStr: string) => parseInt(hexStr.repeat(2 / hexStr.length), 16)\n\nconst getAlphaFloat = (a: any, alpha = 1) => {\n if (a !== undefined) {\n return a / 255\n }\n if (typeof alpha != 'number' || alpha < 0 || alpha > 1) {\n return 1\n }\n return alpha\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAmB,wBAAwB;AAEpC,MAAM,YAAY,CAAC,KAAa,QAAQ,MAAM;AACnD,MAAI,CAAC,WAAW,GA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CHANGED
package/dist/esm/themes.js
CHANGED
|
@@ -1,174 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { createTheme, getVariableValue, isWeb } from "@tamagui/core";
|
|
21
|
-
import { setColorAlpha } from "./colorUtils";
|
|
22
|
-
import { darkColors, lightColors, tokens } from "./tokens";
|
|
23
|
-
const { color } = tokens;
|
|
24
|
-
const alternates = [1, 2, 3, 4];
|
|
25
|
-
const alts = [1, 2, 3];
|
|
26
|
-
function createThemesFrom(name, getTheme, props) {
|
|
27
|
-
const { shift = 0 } = props;
|
|
28
|
-
const theme = getTheme(0 + shift, props);
|
|
29
|
-
let themeEntries = [[name, theme]];
|
|
30
|
-
const altThemes = alternates.map((alt) => [
|
|
31
|
-
`${name}_alt${alt}`,
|
|
32
|
-
getTheme(alt + (props.isLight ? 0 : 0) + shift, props)
|
|
33
|
-
]);
|
|
34
|
-
const altThemes2 = alternates.map((alt) => [
|
|
35
|
-
`${name}_alt${alt}`,
|
|
36
|
-
getTheme(alt + shift, props)
|
|
37
|
-
]);
|
|
38
|
-
const altButtonThemes = alternates.map((_, i) => {
|
|
39
|
-
const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]];
|
|
40
|
-
return [`${bName}_Button`, bTheme];
|
|
41
|
-
});
|
|
42
|
-
const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props);
|
|
43
|
-
const activeTheme = makeActiveTheme(theme);
|
|
44
|
-
const inverted = altThemes.map(([_name, theme2]) => {
|
|
45
|
-
return __spreadProps(__spreadValues({}, theme2), {
|
|
46
|
-
background: theme2.color,
|
|
47
|
-
backgroundHover: theme2.colorHover,
|
|
48
|
-
backgroundFocus: theme2.colorFocus,
|
|
49
|
-
backgroundPress: theme2.colorPress,
|
|
50
|
-
color: theme2.background,
|
|
51
|
-
colorHover: theme2.backgroundHover,
|
|
52
|
-
colorFocus: theme2.backgroundFocus,
|
|
53
|
-
colorPress: theme2.backgroundPress
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
themeEntries = [
|
|
57
|
-
...themeEntries,
|
|
58
|
-
...altThemes.slice(0, alts.length),
|
|
59
|
-
...altButtonThemes.slice(0, alts.length),
|
|
60
|
-
[`${name}_Button`, altThemes2[1][1]],
|
|
61
|
-
[`${name}_DrawerFrame`, altThemes2[1][1]],
|
|
62
|
-
[`${name}_SliderTrack`, altThemes[0][1]],
|
|
63
|
-
[`${name}_SliderTrackActive`, altThemes[3][1]],
|
|
64
|
-
[`${name}_SliderThumb`, inverted[2]],
|
|
65
|
-
[`${name}_Progress`, altThemes[2][1]],
|
|
66
|
-
[`${name}_ProgressIndicator`, inverted[2]],
|
|
67
|
-
[`${name}_Switch`, altThemes[0][1]],
|
|
68
|
-
[`${name}_SwitchThumb`, inverted[2]],
|
|
69
|
-
[`${name}_TooltipArrow`, altThemes[1][1]],
|
|
70
|
-
[`${name}_TooltipContent`, altThemes[1][1]],
|
|
71
|
-
[`${name}_darker`, darkerTheme],
|
|
72
|
-
[`${name}_active`, activeTheme]
|
|
73
|
-
];
|
|
74
|
-
const themes2 = Object.fromEntries(themeEntries);
|
|
75
|
-
return themes2;
|
|
76
|
-
}
|
|
77
|
-
const themeCreator = (str = 1, {
|
|
78
|
-
backgrounds,
|
|
79
|
-
isLight = true,
|
|
80
|
-
isBase = false,
|
|
81
|
-
colors = [...backgrounds].reverse(),
|
|
82
|
-
borderColors = isLight ? colors : backgrounds,
|
|
83
|
-
backgroundStrong,
|
|
84
|
-
offsets: offsetsProp
|
|
85
|
-
}) => {
|
|
86
|
-
const offsets = {
|
|
87
|
-
borderColor: (offsetsProp == null ? void 0 : offsetsProp.borderColor) ?? (offsetsProp == null ? void 0 : offsetsProp.background) ?? [0, 0, 0, 0],
|
|
88
|
-
background: (offsetsProp == null ? void 0 : offsetsProp.background) ?? [0, 0, 0, 0],
|
|
89
|
-
color: (offsetsProp == null ? void 0 : offsetsProp.color) ?? [0, 0, 0, 0]
|
|
90
|
-
};
|
|
91
|
-
const darkColors2 = isLight ? colors : backgrounds;
|
|
92
|
-
const lighterDir = isLight ? -1 : 1;
|
|
93
|
-
const darkerDir = -lighterDir;
|
|
94
|
-
const strongerDir = isLight ? darkerDir : lighterDir;
|
|
95
|
-
const softerDir = -strongerDir;
|
|
96
|
-
const get = (arr, index, name = "background") => {
|
|
97
|
-
return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))];
|
|
98
|
-
};
|
|
99
|
-
const colorTranslucent = setColorAlpha(getVariableValue(get(colors, 0 + str, "color")), 0.5);
|
|
100
|
-
let theme = {
|
|
101
|
-
background: get(backgrounds, str),
|
|
102
|
-
backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),
|
|
103
|
-
backgroundSoft: get(backgrounds, str + softerDir * 2),
|
|
104
|
-
backgroundHover: get(backgrounds, str + lighterDir),
|
|
105
|
-
backgroundPress: get(backgrounds, str + darkerDir),
|
|
106
|
-
backgroundFocus: get(backgrounds, str + darkerDir * 2),
|
|
107
|
-
backgroundTransparent: color.grayA1Light,
|
|
108
|
-
color: get(colors, 0 + str, "color"),
|
|
109
|
-
colorHover: get(colors, 1 + str, "color"),
|
|
110
|
-
colorPress: get(colors, 2 + str, "color"),
|
|
111
|
-
colorFocus: get(colors, 3 + str, "color"),
|
|
112
|
-
colorTranslucent,
|
|
113
|
-
colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],
|
|
114
|
-
shadowColor: isLight ? color.grayA2Light : color.grayA8Light,
|
|
115
|
-
shadowColorHover: darkColors2[!isLight ? 1 : 8],
|
|
116
|
-
shadowColorPress: darkColors2[!isLight ? 1 : 8],
|
|
117
|
-
shadowColorFocus: darkColors2[!isLight ? 1 : 8],
|
|
118
|
-
borderColor: null,
|
|
119
|
-
borderColorHover: null,
|
|
120
|
-
borderColorPress: null,
|
|
121
|
-
borderColorFocus: null
|
|
122
|
-
};
|
|
123
|
-
if (process.env.ENABLE_STEPS) {
|
|
124
|
-
Object.assign(theme, {
|
|
125
|
-
step1: backgrounds[0],
|
|
126
|
-
step2: backgrounds[1],
|
|
127
|
-
step3: backgrounds[2],
|
|
128
|
-
step4: backgrounds[3],
|
|
129
|
-
step5: backgrounds[4],
|
|
130
|
-
step6: backgrounds[5],
|
|
131
|
-
step7: backgrounds[6],
|
|
132
|
-
step8: backgrounds[7],
|
|
133
|
-
step9: backgrounds[8],
|
|
134
|
-
step10: backgrounds[9],
|
|
135
|
-
step11: backgrounds[10],
|
|
136
|
-
step12: backgrounds[11]
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
if (isBase) {
|
|
140
|
-
Object.assign(theme, {
|
|
141
|
-
borderColor: isLight ? get(colors, 8 - str, "borderColor") : get(backgrounds, 2 + str, "borderColor"),
|
|
142
|
-
borderColorHover: isLight ? get(colors, 6 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor"),
|
|
143
|
-
borderColorPress: isLight ? get(colors, 5 - str, "borderColor") : get(backgrounds, 1 + str, "borderColor"),
|
|
144
|
-
borderColorFocus: isLight ? get(colors, 4 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor")
|
|
145
|
-
});
|
|
146
|
-
} else {
|
|
147
|
-
Object.assign(theme, {
|
|
148
|
-
borderColor: get(borderColors, 1 + strongerDir, "borderColor"),
|
|
149
|
-
borderColorHover: get(borderColors, 2 + strongerDir, "borderColor"),
|
|
150
|
-
borderColorPress: get(borderColors, 3 + strongerDir, "borderColor"),
|
|
151
|
-
borderColorFocus: get(borderColors, 4 + strongerDir, "borderColor")
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return theme;
|
|
155
|
-
};
|
|
156
|
-
const themeColors = {
|
|
1
|
+
import { createThemes } from "@tamagui/create-themes";
|
|
2
|
+
import { colorTokens } from "./tokens";
|
|
3
|
+
const themes = createThemes({
|
|
4
|
+
activeColor: "blue",
|
|
157
5
|
light: [
|
|
158
6
|
"#fff",
|
|
159
7
|
"#f4f4f4",
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
8
|
+
"hsl(0, 0%, 99.0%)",
|
|
9
|
+
"hsl(0, 0%, 97.3%)",
|
|
10
|
+
"hsl(0, 0%, 95.1%)",
|
|
11
|
+
"hsl(0, 0%, 93.0%)",
|
|
12
|
+
"hsl(0, 0%, 90.9%)",
|
|
13
|
+
"hsl(0, 0%, 88.7%)",
|
|
14
|
+
"hsl(0, 0%, 85.8%)",
|
|
15
|
+
"hsl(0, 0%, 78.0%)",
|
|
16
|
+
"hsl(0, 0%, 56.1%)",
|
|
17
|
+
"hsl(0, 0%, 52.3%)",
|
|
18
|
+
"hsl(0, 0%, 43.5%)",
|
|
19
|
+
"hsl(0, 0%, 9.0%)"
|
|
172
20
|
],
|
|
173
21
|
dark: [
|
|
174
22
|
"#111111",
|
|
@@ -183,123 +31,11 @@ const themeColors = {
|
|
|
183
31
|
"#545454",
|
|
184
32
|
"#626262",
|
|
185
33
|
"#777777"
|
|
186
|
-
]
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
backgrounds: themeColors.light,
|
|
190
|
-
backgroundStrong: isWeb ? "#fefefe" : "#f2f2f2",
|
|
191
|
-
borderColors: themeColors.light.slice(2),
|
|
192
|
-
isLight: true,
|
|
193
|
-
offsets: {
|
|
194
|
-
background: [2, 2, 2, 2, 2, 2]
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
const darkThemes = createThemesFrom("dark", themeCreator, {
|
|
198
|
-
backgrounds: themeColors.dark,
|
|
199
|
-
colors: themeColors.light.slice(2),
|
|
200
|
-
backgroundStrong: "#070707",
|
|
201
|
-
isBase: true,
|
|
202
|
-
isLight: false,
|
|
203
|
-
shift: 1,
|
|
204
|
-
offsets: {
|
|
205
|
-
color: [0, 4, 5, 5, 5, 5]
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
darkThemes.dark_darker.background = "#030303";
|
|
209
|
-
darkThemes.dark_darker.backgroundStrong = "#000";
|
|
210
|
-
const light = createTheme(__spreadValues(__spreadValues({}, lightColors), lightThemes.light));
|
|
211
|
-
const dark = createTheme(__spreadValues(__spreadValues({}, darkColors), darkThemes.dark));
|
|
212
|
-
const baseThemes = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, lightThemes), {
|
|
213
|
-
light,
|
|
214
|
-
light_active: makeActiveTheme(lightThemes.light),
|
|
215
|
-
light_Card: lightThemes.light,
|
|
216
|
-
light_SliderTrack: lightThemes.light_alt2,
|
|
217
|
-
light_SliderTrackActive: lightThemes.light_alt3,
|
|
218
|
-
light_Switch: lightThemes.light_alt1,
|
|
219
|
-
light_SwitchThumb: darkThemes.dark,
|
|
220
|
-
light_DrawerFrame: lightThemes.light_alt1
|
|
221
|
-
}), darkThemes), {
|
|
222
|
-
dark,
|
|
223
|
-
dark_active: makeActiveTheme(darkThemes.dark),
|
|
224
|
-
dark_Card: darkThemes.dark,
|
|
225
|
-
dark_DrawerFrame: darkThemes.dark_alt2,
|
|
226
|
-
dark_SliderTrack: darkThemes.dark_darker,
|
|
227
|
-
dark_SliderTrackActive: darkThemes.dark_alt3,
|
|
228
|
-
dark_Switch: darkThemes.dark_darker,
|
|
229
|
-
dark_SwitchThumb: lightThemes.light_alt3,
|
|
230
|
-
dark_Button: darkThemes.dark_alt1
|
|
231
|
-
});
|
|
232
|
-
function makeActiveTheme(theme) {
|
|
233
|
-
const res = __spreadValues({}, theme);
|
|
234
|
-
res.backgroundHover = res.background;
|
|
235
|
-
res.colorHover = res.color;
|
|
236
|
-
res.backgroundPress = res.background;
|
|
237
|
-
res.colorPress = res.color;
|
|
238
|
-
return res;
|
|
239
|
-
}
|
|
240
|
-
const darkEntries = Object.entries(dark);
|
|
241
|
-
const lightEntries = Object.entries(light);
|
|
242
|
-
function findColors(prefix, dark2 = false) {
|
|
243
|
-
return Object.fromEntries((dark2 ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix)));
|
|
244
|
-
}
|
|
245
|
-
const colorSchemes = [
|
|
246
|
-
{ name: "blue", colors: findColors("blue"), darkColors: findColors("blue", true) },
|
|
247
|
-
{ name: "gray", colors: findColors("gray"), darkColors: findColors("gray", true) },
|
|
248
|
-
{ name: "green", colors: findColors("green"), darkColors: findColors("green", true) },
|
|
249
|
-
{ name: "orange", colors: findColors("orange"), darkColors: findColors("orange", true) },
|
|
250
|
-
{ name: "pink", colors: findColors("pink"), darkColors: findColors("pink", true) },
|
|
251
|
-
{ name: "purple", colors: findColors("purple"), darkColors: findColors("purple", true) },
|
|
252
|
-
{ name: "red", colors: findColors("red"), darkColors: findColors("red", true) },
|
|
253
|
-
{ name: "yellow", colors: findColors("yellow"), darkColors: findColors("yellow", true) },
|
|
254
|
-
{ name: "teal", colors: findColors("teal"), darkColors: findColors("teal", true) }
|
|
255
|
-
];
|
|
256
|
-
const colorNames = [
|
|
257
|
-
"blue",
|
|
258
|
-
"gray",
|
|
259
|
-
"green",
|
|
260
|
-
"orange",
|
|
261
|
-
"pink",
|
|
262
|
-
"purple",
|
|
263
|
-
"red",
|
|
264
|
-
"yellow",
|
|
265
|
-
"teal"
|
|
266
|
-
];
|
|
267
|
-
const colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors: darkColors2 }) => {
|
|
268
|
-
const [altLightThemes, altDarkThemes] = [
|
|
269
|
-
{ colors: darkColors2, backgrounds: colors },
|
|
270
|
-
{ colors, backgrounds: darkColors2 }
|
|
271
|
-
].map((props, i) => {
|
|
272
|
-
const isLight = i === 0;
|
|
273
|
-
const colorsBase = Object.values(props.colors).slice(2);
|
|
274
|
-
const [backgrounds, colors2] = [
|
|
275
|
-
Object.values(props.backgrounds),
|
|
276
|
-
isLight ? colorsBase : [colorsBase[0], "#ccc", ...colorsBase.slice(1)]
|
|
277
|
-
];
|
|
278
|
-
const scheme = isLight ? "light" : "dark";
|
|
279
|
-
const shift = isLight ? 0 : 1;
|
|
280
|
-
const themeWithAlts = createThemesFrom(name, themeCreator, {
|
|
281
|
-
colors: colors2,
|
|
282
|
-
backgrounds,
|
|
283
|
-
borderColors: backgrounds,
|
|
284
|
-
isLight,
|
|
285
|
-
shift,
|
|
286
|
-
isBase: false,
|
|
287
|
-
offsets: {
|
|
288
|
-
background: isLight ? [2, 2, 2, 2, 2, 2] : null,
|
|
289
|
-
borderColor: isLight ? [2, 2, 2, 3, 2] : null,
|
|
290
|
-
color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1]
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v]);
|
|
294
|
-
});
|
|
295
|
-
return [...altLightThemes, ...altDarkThemes];
|
|
34
|
+
],
|
|
35
|
+
colorsLight: colorTokens.light,
|
|
36
|
+
colorsDark: colorTokens.dark
|
|
296
37
|
});
|
|
297
|
-
const colorThemes = Object.fromEntries(colorThemeEntries);
|
|
298
|
-
const allThemes = __spreadValues(__spreadValues({}, baseThemes), colorThemes);
|
|
299
|
-
const themes = allThemes;
|
|
300
38
|
export {
|
|
301
|
-
colorNames,
|
|
302
|
-
colorSchemes,
|
|
303
39
|
themes
|
|
304
40
|
};
|
|
305
41
|
//# sourceMappingURL=themes.js.map
|
package/dist/esm/themes.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/themes.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Variable, createTheme, getVariableValue, isWeb } from '@tamagui/core'\n\nimport { setColorAlpha } from './colorUtils'\nimport { darkColors, lightColors, tokens } from './tokens'\n\nconst { color } = tokens\n\n// spaghetti ahead\n\ntype ThemeCreatorProps = {\n shift?: number\n backgrounds: (string | Variable)[]\n backgroundStrong?: string | Variable\n borderColors?: (string | Variable)[]\n colors?: (string | Variable)[]\n offsets?: {\n color?: number[] | null\n background?: number[] | null\n borderColor?: number[] | null\n }\n isLight?: boolean\n isBase?: boolean\n}\n\n// helpers\n\nconst alternates = [1, 2, 3, 4] as const\nconst alts = [1, 2, 3] as const\ntype AltKeys = 1 | 2 | 3\ntype AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`\ntype ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A\n\nfunction createThemesFrom<Name extends string, GetTheme extends ThemeCreator = ThemeCreator>(\n name: Name,\n getTheme: GetTheme,\n props: ThemeCreatorProps\n): {\n [key in `${Name}_alt${AltKeys}` | `${Name}` | `${Name}_darker`]: GetTheme extends ThemeCreator<\n infer Theme\n >\n ? Theme\n : never\n} {\n const { shift = 0 } = props\n const theme = getTheme(0 + shift, props)\n let themeEntries: any[] = [[name, theme]]\n\n // generate alternates (for use in other themes), but keep just alts\n const altThemes: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + (props.isLight ? 0 : 0) + shift, props),\n ])\n const altThemes2: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + shift, props),\n ])\n const altButtonThemes: any[] = alternates.map((_, i) => {\n const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]]\n return [`${bName}_Button` as any, bTheme]\n })\n // add these after alts since we rely on positioning\n const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)\n const activeTheme = makeActiveTheme(theme)\n\n // TODO can be de-duped\n const inverted = altThemes.map(([_name, theme]) => {\n return {\n ...theme,\n background: theme.color,\n backgroundHover: theme.colorHover,\n backgroundFocus: theme.colorFocus,\n backgroundPress: theme.colorPress,\n color: theme.background,\n colorHover: theme.backgroundHover,\n colorFocus: theme.backgroundFocus,\n colorPress: theme.backgroundPress,\n }\n })\n\n themeEntries = [\n ...themeEntries,\n // keep just alts\n ...altThemes.slice(0, alts.length),\n ...altButtonThemes.slice(0, alts.length),\n [`${name}_Button`, altThemes2[1][1]],\n [`${name}_DrawerFrame`, altThemes2[1][1]],\n [`${name}_SliderTrack`, altThemes[0][1]],\n [`${name}_SliderTrackActive`, altThemes[3][1]],\n [`${name}_SliderThumb`, inverted[2]],\n [`${name}_Progress`, altThemes[2][1]],\n [`${name}_ProgressIndicator`, inverted[2]],\n [`${name}_Switch`, altThemes[0][1]],\n [`${name}_SwitchThumb`, inverted[2]],\n [`${name}_TooltipArrow`, altThemes[1][1]],\n [`${name}_TooltipContent`, altThemes[1][1]],\n [`${name}_darker`, darkerTheme],\n [`${name}_active`, activeTheme],\n ]\n const themes = Object.fromEntries(themeEntries)\n // if (props.isLight) {\n // console.log('themes', themes)\n // }\n return themes as any\n}\n\nconst themeCreator = (\n str = 1,\n {\n backgrounds,\n isLight = true,\n isBase = false,\n colors = [...backgrounds].reverse(),\n borderColors = isLight ? colors : backgrounds,\n backgroundStrong,\n offsets: offsetsProp,\n }: ThemeCreatorProps\n) => {\n const offsets = {\n borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? [0, 0, 0, 0],\n background: offsetsProp?.background ?? [0, 0, 0, 0],\n color: offsetsProp?.color ?? [0, 0, 0, 0],\n }\n const darkColors = isLight ? colors : backgrounds\n const lighterDir = isLight ? -1 : 1\n const darkerDir = -lighterDir\n const strongerDir = isLight ? darkerDir : lighterDir\n const softerDir = -strongerDir\n const get = (arr: any[], index: number, name = 'background') => {\n return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]\n }\n\n const colorTranslucent = setColorAlpha(getVariableValue(get(colors, 0 + str, 'color')), 0.5)\n\n let theme = {\n background: get(backgrounds, str),\n backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),\n backgroundSoft: get(backgrounds, str + softerDir * 2),\n backgroundHover: get(backgrounds, str + lighterDir),\n backgroundPress: get(backgrounds, str + darkerDir),\n backgroundFocus: get(backgrounds, str + darkerDir * 2),\n backgroundTransparent: color.grayA1Light,\n color: get(colors, 0 + str, 'color'),\n colorHover: get(colors, 1 + str, 'color'),\n colorPress: get(colors, 2 + str, 'color'),\n colorFocus: get(colors, 3 + str, 'color'),\n colorTranslucent,\n colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],\n shadowColor: isLight ? color.grayA2Light : color.grayA8Light,\n shadowColorHover: darkColors[!isLight ? 1 : 8],\n shadowColorPress: darkColors[!isLight ? 1 : 8],\n shadowColorFocus: darkColors[!isLight ? 1 : 8],\n borderColor: null as any as string | Variable,\n borderColorHover: null as any as string | Variable,\n borderColorPress: null as any as string | Variable,\n borderColorFocus: null as any as string | Variable,\n }\n\n if (process.env.ENABLE_STEPS) {\n Object.assign(theme, {\n step1: backgrounds[0],\n step2: backgrounds[1],\n step3: backgrounds[2],\n step4: backgrounds[3],\n step5: backgrounds[4],\n step6: backgrounds[5],\n step7: backgrounds[6],\n step8: backgrounds[7],\n step9: backgrounds[8],\n step10: backgrounds[9],\n step11: backgrounds[10],\n step12: backgrounds[11],\n })\n }\n\n if (isBase) {\n Object.assign(theme, {\n borderColor: isLight\n ? get(colors, 8 - str, 'borderColor')\n : get(backgrounds, 2 + str, 'borderColor'),\n borderColorHover: isLight\n ? get(colors, 6 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n borderColorPress: isLight\n ? get(colors, 5 - str, 'borderColor')\n : get(backgrounds, 1 + str, 'borderColor'),\n borderColorFocus: isLight\n ? get(colors, 4 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n })\n } else {\n Object.assign(theme, {\n borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),\n borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),\n borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),\n borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),\n })\n }\n\n return theme\n}\n\nconst themeColors = {\n light: [\n '#fff',\n '#f4f4f4',\n color.gray1Light,\n color.gray2Light,\n color.gray3Light,\n color.gray4Light,\n color.gray5Light,\n color.gray6Light,\n color.gray7Light,\n color.gray8Light,\n color.gray9Light,\n color.gray10Light,\n color.gray11Light,\n color.gray12Light,\n ],\n dark: [\n '#111111',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#383838',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#777777',\n ],\n}\n\nconst lightThemes = createThemesFrom('light', themeCreator, {\n backgrounds: themeColors.light,\n // for now web non-ios style native is...\n backgroundStrong: isWeb ? '#fefefe' : '#f2f2f2',\n borderColors: themeColors.light.slice(2),\n isLight: true,\n offsets: {\n background: [2, 2, 2, 2, 2, 2],\n },\n})\n\nconst darkThemes = createThemesFrom('dark', themeCreator, {\n backgrounds: themeColors.dark,\n colors: themeColors.light.slice(2),\n backgroundStrong: '#070707',\n isBase: true,\n isLight: false,\n shift: 1,\n offsets: {\n color: [0, 4, 5, 5, 5, 5],\n },\n})\n\ndarkThemes.dark_darker.background = '#030303'\ndarkThemes.dark_darker.backgroundStrong = '#000'\n\nconst light = createTheme({\n ...lightColors,\n ...lightThemes.light,\n})\n\nconst dark = createTheme({\n ...darkColors,\n ...darkThemes.dark,\n})\n\ntype ThemeBase = {\n [Key in keyof typeof dark]: string\n}\n\nconst baseThemes = {\n // light\n ...lightThemes,\n light,\n light_active: makeActiveTheme(lightThemes.light),\n light_Card: lightThemes.light,\n light_SliderTrack: lightThemes.light_alt2,\n light_SliderTrackActive: lightThemes.light_alt3,\n light_Switch: lightThemes.light_alt1,\n light_SwitchThumb: darkThemes.dark,\n light_DrawerFrame: lightThemes.light_alt1,\n\n // dark\n ...darkThemes,\n dark,\n dark_active: makeActiveTheme(darkThemes.dark),\n dark_Card: darkThemes.dark,\n dark_DrawerFrame: darkThemes.dark_alt2,\n dark_SliderTrack: darkThemes.dark_darker,\n dark_SliderTrackActive: darkThemes.dark_alt3,\n dark_Switch: darkThemes.dark_darker,\n dark_SwitchThumb: lightThemes.light_alt3,\n dark_Button: darkThemes.dark_alt1,\n}\n\nfunction makeActiveTheme(theme: any) {\n const res = { ...theme }\n res.backgroundHover = res.background\n res.colorHover = res.color\n res.backgroundPress = res.background\n res.colorPress = res.color\n return res\n}\n\nconst darkEntries = Object.entries(dark)\nconst lightEntries = Object.entries(light)\nfunction findColors(prefix: string, dark = false): ThemeBase {\n return Object.fromEntries(\n (dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))\n ) as any\n}\n\nexport const colorSchemes = [\n { name: 'blue', colors: findColors('blue'), darkColors: findColors('blue', true) },\n { name: 'gray', colors: findColors('gray'), darkColors: findColors('gray', true) },\n { name: 'green', colors: findColors('green'), darkColors: findColors('green', true) },\n { name: 'orange', colors: findColors('orange'), darkColors: findColors('orange', true) },\n { name: 'pink', colors: findColors('pink'), darkColors: findColors('pink', true) },\n { name: 'purple', colors: findColors('purple'), darkColors: findColors('purple', true) },\n { name: 'red', colors: findColors('red'), darkColors: findColors('red', true) },\n { name: 'yellow', colors: findColors('yellow'), darkColors: findColors('yellow', true) },\n { name: 'teal', colors: findColors('teal'), darkColors: findColors('teal', true) },\n] as const\n\nexport type ColorNames = typeof colorSchemes[number]['name']\n\n// nice and flat\nexport const colorNames: ColorNames[] = [\n 'blue',\n 'gray',\n 'green',\n 'orange',\n 'pink',\n 'purple',\n 'red',\n 'yellow',\n 'teal',\n]\n\ntype ColorThemeNames =\n | ColorNames\n | AltName<`light_${ColorNames}`, AltKeys>\n | AltName<`dark_${ColorNames}`, AltKeys>\n\nconst colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {\n const [altLightThemes, altDarkThemes] = [\n { colors: darkColors, backgrounds: colors },\n { colors, backgrounds: darkColors },\n ].map((props, i) => {\n const isLight = i === 0\n const colorsBase = Object.values(props.colors).slice(2)\n const [backgrounds, colors] = [\n Object.values(props.backgrounds),\n isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],\n ] as const\n\n const scheme = isLight ? 'light' : 'dark'\n const shift = isLight ? 0 : 1\n\n // if (!isLight) {\n // const [_, h, sp, lp] = backgrounds[0].match(/hsl\\(([0-9\\.]+), ([0-9\\.]+)\\%, ([0-9\\.]+)\\%\\)/)!\n // backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)\n // }\n\n const themeWithAlts = createThemesFrom(name, themeCreator, {\n colors,\n backgrounds,\n borderColors: backgrounds,\n isLight,\n shift,\n isBase: false,\n offsets: {\n background: isLight ? [2, 2, 2, 2, 2, 2] : null,\n borderColor: isLight ? [2, 2, 2, 3, 2] : null,\n color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],\n },\n })\n\n return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])\n })\n return [...altLightThemes, ...altDarkThemes]\n})\n\ntype MyThemeBase = typeof baseThemes['light_alt1']\n\nconst colorThemes: {\n [key in ColorThemeNames]: MyThemeBase\n} = Object.fromEntries(colorThemeEntries) as any\n\nconst allThemes = {\n ...baseThemes,\n ...colorThemes,\n} as const\n\nexport const themes: {\n [key in keyof typeof allThemes]: typeof baseThemes['light']\n} = allThemes as any\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createThemes } from '@tamagui/create-themes'\n\nimport { colorTokens } from './tokens'\n\nexport const themes = createThemes<keyof typeof colorTokens.light>({\n activeColor: 'blue',\n light: [\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%, 88.7%)',\n 'hsl(0, 0%, 85.8%)',\n 'hsl(0, 0%, 78.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 ],\n dark: [\n '#111111',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#383838',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#777777',\n ],\n colorsLight: colorTokens.light,\n colorsDark: colorTokens.dark,\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB;AAErB,MAAM,SAAS,aAA6C;AAAA,EACjE,aAAa;AAAA,EACb,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;AAAA,EACA,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,EACF;AAAA,EACA,aAAa,YAAY;AAAA,EACzB,YAAY,YAAY;AAC1B,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/tokens.js
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
1
|
import {
|
|
18
2
|
blue,
|
|
19
3
|
blueDark,
|
|
20
4
|
gray,
|
|
21
|
-
grayA,
|
|
22
5
|
grayDark,
|
|
23
|
-
grayDarkA,
|
|
24
6
|
green,
|
|
25
7
|
greenDark,
|
|
26
8
|
orange,
|
|
@@ -31,10 +13,6 @@ import {
|
|
|
31
13
|
purpleDark,
|
|
32
14
|
red,
|
|
33
15
|
redDark,
|
|
34
|
-
teal,
|
|
35
|
-
tealDark,
|
|
36
|
-
violet,
|
|
37
|
-
violetDark,
|
|
38
16
|
yellow,
|
|
39
17
|
yellowDark
|
|
40
18
|
} from "@tamagui/colors";
|
|
@@ -54,15 +32,10 @@ const size = {
|
|
|
54
32
|
true: 44,
|
|
55
33
|
4.5: 48,
|
|
56
34
|
5: 52,
|
|
57
|
-
5.5: 59,
|
|
58
35
|
6: 64,
|
|
59
|
-
6.5: 69,
|
|
60
36
|
7: 74,
|
|
61
|
-
7.6: 79,
|
|
62
37
|
8: 84,
|
|
63
|
-
8.5: 89,
|
|
64
38
|
9: 94,
|
|
65
|
-
9.5: 99,
|
|
66
39
|
10: 104,
|
|
67
40
|
11: 124,
|
|
68
41
|
12: 144,
|
|
@@ -80,7 +53,10 @@ const spaces = Object.entries(size).map(([k, v]) => [
|
|
|
80
53
|
Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12))
|
|
81
54
|
]);
|
|
82
55
|
const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v]);
|
|
83
|
-
const space =
|
|
56
|
+
const space = {
|
|
57
|
+
...Object.fromEntries(spaces),
|
|
58
|
+
...Object.fromEntries(spacesNegative)
|
|
59
|
+
};
|
|
84
60
|
const zIndex = {
|
|
85
61
|
0: 0,
|
|
86
62
|
1: 100,
|
|
@@ -93,33 +69,48 @@ const colorTokens = {
|
|
|
93
69
|
light: {
|
|
94
70
|
blue,
|
|
95
71
|
gray,
|
|
96
|
-
grayA,
|
|
97
72
|
green,
|
|
98
73
|
orange,
|
|
99
74
|
pink,
|
|
100
75
|
purple,
|
|
101
76
|
red,
|
|
102
|
-
|
|
103
|
-
yellow,
|
|
104
|
-
teal
|
|
77
|
+
yellow
|
|
105
78
|
},
|
|
106
79
|
dark: {
|
|
107
80
|
blue: blueDark,
|
|
108
81
|
gray: grayDark,
|
|
109
|
-
grayA: grayDarkA,
|
|
110
82
|
green: greenDark,
|
|
111
83
|
orange: orangeDark,
|
|
112
84
|
pink: pinkDark,
|
|
113
85
|
purple: purpleDark,
|
|
114
86
|
red: redDark,
|
|
115
|
-
|
|
116
|
-
yellow: yellowDark,
|
|
117
|
-
teal: tealDark
|
|
87
|
+
yellow: yellowDark
|
|
118
88
|
}
|
|
119
89
|
};
|
|
120
|
-
const darkColors =
|
|
121
|
-
|
|
122
|
-
|
|
90
|
+
const darkColors = {
|
|
91
|
+
...colorTokens.dark.blue,
|
|
92
|
+
...colorTokens.dark.gray,
|
|
93
|
+
...colorTokens.dark.green,
|
|
94
|
+
...colorTokens.dark.orange,
|
|
95
|
+
...colorTokens.dark.pink,
|
|
96
|
+
...colorTokens.dark.purple,
|
|
97
|
+
...colorTokens.dark.red,
|
|
98
|
+
...colorTokens.dark.yellow
|
|
99
|
+
};
|
|
100
|
+
const lightColors = {
|
|
101
|
+
...colorTokens.light.blue,
|
|
102
|
+
...colorTokens.light.gray,
|
|
103
|
+
...colorTokens.light.green,
|
|
104
|
+
...colorTokens.light.orange,
|
|
105
|
+
...colorTokens.light.pink,
|
|
106
|
+
...colorTokens.light.purple,
|
|
107
|
+
...colorTokens.light.red,
|
|
108
|
+
...colorTokens.light.yellow
|
|
109
|
+
};
|
|
110
|
+
const color = {
|
|
111
|
+
...postfixObjKeys(lightColors, "Light"),
|
|
112
|
+
...postfixObjKeys(darkColors, "Dark")
|
|
113
|
+
};
|
|
123
114
|
function postfixObjKeys(obj, postfix) {
|
|
124
115
|
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v]));
|
|
125
116
|
}
|
|
@@ -139,15 +130,21 @@ const radius = {
|
|
|
139
130
|
12: 50
|
|
140
131
|
};
|
|
141
132
|
const tokens = createTokens({
|
|
142
|
-
color
|
|
133
|
+
color,
|
|
143
134
|
radius,
|
|
144
135
|
zIndex,
|
|
145
136
|
space,
|
|
146
137
|
size
|
|
147
138
|
});
|
|
148
139
|
export {
|
|
140
|
+
color,
|
|
141
|
+
colorTokens,
|
|
149
142
|
darkColors,
|
|
150
143
|
lightColors,
|
|
151
|
-
|
|
144
|
+
radius,
|
|
145
|
+
size,
|
|
146
|
+
space,
|
|
147
|
+
tokens,
|
|
148
|
+
zIndex
|
|
152
149
|
};
|
|
153
150
|
//# sourceMappingURL=tokens.js.map
|
package/dist/esm/tokens.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tokens.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n blue,\n blueDark,\n gray,\n
|
|
5
|
-
"mappings": "
|
|
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/core'\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 Sizes = typeof size\ntype SizeKeys = `${keyof Sizes}`\n\nconst spaces = Object.entries(size).map(([k, v]) => [\n k,\n Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12)),\n])\n\nconst spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v])\n\nexport const space: {\n [Key in `-${SizeKeys}` | SizeKeys]: 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<A extends { [key: string]: Variable<string> | string }, B extends string>(\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(Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])) as any\n}\n\nexport const radius = {\n 0: 0,\n 1: 3,\n 2: 5,\n 3: 7,\n 4: 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,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CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/theme-base",
|
|
3
|
-
"version": "1.0.1-
|
|
3
|
+
"version": "1.0.1-rc.0",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
7
|
-
"
|
|
7
|
+
"sideEffects": false,
|
|
8
8
|
"files": [
|
|
9
9
|
"src",
|
|
10
10
|
"types",
|
|
@@ -13,15 +13,25 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tamagui-build",
|
|
15
15
|
"watch": "tamagui-build --watch",
|
|
16
|
+
"lint": "eslint src",
|
|
17
|
+
"lint:fix": "yarn lint --fix",
|
|
16
18
|
"clean": "tamagui-build clean",
|
|
17
19
|
"clean:build": "tamagui-build clean:build"
|
|
18
20
|
},
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/esm/index.js",
|
|
25
|
+
"require": "./dist/cjs/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
19
28
|
"dependencies": {
|
|
20
|
-
"@tamagui/colors": "^1.0.1-
|
|
21
|
-
"@tamagui/core": "^1.0.1-
|
|
29
|
+
"@tamagui/colors": "^1.0.1-rc.0",
|
|
30
|
+
"@tamagui/core": "^1.0.1-rc.0",
|
|
31
|
+
"@tamagui/create-themes": "^1.0.1-rc.0"
|
|
22
32
|
},
|
|
23
33
|
"devDependencies": {
|
|
24
|
-
"@tamagui/build": "^1.0.1-
|
|
34
|
+
"@tamagui/build": "^1.0.1-rc.0"
|
|
25
35
|
},
|
|
26
36
|
"publishConfig": {
|
|
27
37
|
"access": "public"
|
package/src/colorUtils.tsx
CHANGED
|
@@ -11,7 +11,7 @@ export const hexToRGBA = (hex: string, alpha = 1) => {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const setColorAlpha = (colorIn: string | Variable, alpha = 1) => {
|
|
14
|
-
|
|
14
|
+
const color = `${getVariableValue(colorIn)}`
|
|
15
15
|
if (color.startsWith('hsl(')) {
|
|
16
16
|
return color.replace('hsl', 'hsla').replace(')', `, ${alpha})`)
|
|
17
17
|
}
|