@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
package/dist/cjs/colorUtils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -32,7 +33,7 @@ const hexToRGBA = (hex, alpha = 1) => {
|
|
|
32
33
|
return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`;
|
|
33
34
|
};
|
|
34
35
|
const setColorAlpha = (colorIn, alpha = 1) => {
|
|
35
|
-
|
|
36
|
+
const color = `${(0, import_core.getVariableValue)(colorIn)}`;
|
|
36
37
|
if (color.startsWith("hsl(")) {
|
|
37
38
|
return color.replace("hsl", "hsla").replace(")", `, ${alpha})`);
|
|
38
39
|
}
|
|
@@ -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": "
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2C;AAEpC,MAAM,YAAY,CAAC,KAAa,QAAQ,MAAM;AACnD,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,IAAI,MAAM,aAAa;AAAA,EAC/B;AACA,QAAM,YAAY,KAAK,OAAO,IAAI,SAAS,KAAK,CAAC;AACjD,QAAM,SAAS,oBAAoB,IAAI,MAAM,CAAC,GAAG,SAAS;AAC1D,QAAM,CAAC,GAAG,GAAG,GAAG,CAAC,KAAI,iCAAQ,IAAI,yBAAwB,CAAC;AAC1D,SAAO,QAAQ,MAAM,MAAM,MAAM,cAAc,GAAG,KAAK;AACzD;AAEO,MAAM,gBAAgB,CAAC,SAA4B,QAAQ,MAAM;AACtE,QAAM,QAAQ,OAAG,8BAAiB,OAAO;AACzC,MAAI,MAAM,WAAW,MAAM,GAAG;AAC5B,WAAO,MAAM,QAAQ,OAAO,MAAM,EAAE,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAChE;AACA,MAAI,MAAM,WAAW,GAAG,GAAG;AACzB,WAAO,UAAU,OAAO,KAAK;AAAA,EAC/B;AACA,MAAI,MAAM,WAAW,MAAM,GAAG;AAC5B,WAAO,MAAM,QAAQ,OAAO,MAAM,EAAE,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAChE;AACA,SAAO;AACT;AAEA,MAAM,aAAa,CAAC,QAAgB,6BAA6B,KAAK,GAAG;AAEzE,MAAM,sBAAsB,CAAC,IAAY,YAAY,MACnD,GAAG,MAAM,IAAI,OAAO,KAAK,cAAc,GAAG,CAAC;AAE7C,MAAM,sBAAsB,CAAC,WAAmB,SAAS,OAAO,OAAO,IAAI,OAAO,MAAM,GAAG,EAAE;AAE7F,MAAM,gBAAgB,CAAC,GAAQ,QAAQ,MAAM;AAC3C,MAAI,MAAM,QAAW;AACnB,WAAO,IAAI;AAAA,EACb;AACA,MAAI,OAAO,SAAS,YAAY,QAAQ,KAAK,QAAQ,GAAG;AACtD,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './themes'\nexport * from './tokens'\nexport * from '@tamagui/colors'\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;AACA,wBAAc,qBADd;AAEA,wBAAc,4BAFd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/themes.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
6
|
var __export = (target, all) => {
|
|
23
7
|
for (var name in all)
|
|
24
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,163 +18,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
19
|
var themes_exports = {};
|
|
36
20
|
__export(themes_exports, {
|
|
37
|
-
colorNames: () => colorNames,
|
|
38
|
-
colorSchemes: () => colorSchemes,
|
|
39
21
|
themes: () => themes
|
|
40
22
|
});
|
|
41
23
|
module.exports = __toCommonJS(themes_exports);
|
|
42
|
-
var
|
|
43
|
-
var import_colorUtils = require("./colorUtils");
|
|
24
|
+
var import_create_themes = require("@tamagui/create-themes");
|
|
44
25
|
var import_tokens = require("./tokens");
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const alts = [1, 2, 3];
|
|
48
|
-
function createThemesFrom(name, getTheme, props) {
|
|
49
|
-
const { shift = 0 } = props;
|
|
50
|
-
const theme = getTheme(0 + shift, props);
|
|
51
|
-
let themeEntries = [[name, theme]];
|
|
52
|
-
const altThemes = alternates.map((alt) => [
|
|
53
|
-
`${name}_alt${alt}`,
|
|
54
|
-
getTheme(alt + (props.isLight ? 0 : 0) + shift, props)
|
|
55
|
-
]);
|
|
56
|
-
const altThemes2 = alternates.map((alt) => [
|
|
57
|
-
`${name}_alt${alt}`,
|
|
58
|
-
getTheme(alt + shift, props)
|
|
59
|
-
]);
|
|
60
|
-
const altButtonThemes = alternates.map((_, i) => {
|
|
61
|
-
const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]];
|
|
62
|
-
return [`${bName}_Button`, bTheme];
|
|
63
|
-
});
|
|
64
|
-
const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props);
|
|
65
|
-
const activeTheme = makeActiveTheme(theme);
|
|
66
|
-
const inverted = altThemes.map(([_name, theme2]) => {
|
|
67
|
-
return __spreadProps(__spreadValues({}, theme2), {
|
|
68
|
-
background: theme2.color,
|
|
69
|
-
backgroundHover: theme2.colorHover,
|
|
70
|
-
backgroundFocus: theme2.colorFocus,
|
|
71
|
-
backgroundPress: theme2.colorPress,
|
|
72
|
-
color: theme2.background,
|
|
73
|
-
colorHover: theme2.backgroundHover,
|
|
74
|
-
colorFocus: theme2.backgroundFocus,
|
|
75
|
-
colorPress: theme2.backgroundPress
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
themeEntries = [
|
|
79
|
-
...themeEntries,
|
|
80
|
-
...altThemes.slice(0, alts.length),
|
|
81
|
-
...altButtonThemes.slice(0, alts.length),
|
|
82
|
-
[`${name}_Button`, altThemes2[1][1]],
|
|
83
|
-
[`${name}_DrawerFrame`, altThemes2[1][1]],
|
|
84
|
-
[`${name}_SliderTrack`, altThemes[0][1]],
|
|
85
|
-
[`${name}_SliderTrackActive`, altThemes[3][1]],
|
|
86
|
-
[`${name}_SliderThumb`, inverted[2]],
|
|
87
|
-
[`${name}_Progress`, altThemes[2][1]],
|
|
88
|
-
[`${name}_ProgressIndicator`, inverted[2]],
|
|
89
|
-
[`${name}_Switch`, altThemes[0][1]],
|
|
90
|
-
[`${name}_SwitchThumb`, inverted[2]],
|
|
91
|
-
[`${name}_TooltipArrow`, altThemes[1][1]],
|
|
92
|
-
[`${name}_TooltipContent`, altThemes[1][1]],
|
|
93
|
-
[`${name}_darker`, darkerTheme],
|
|
94
|
-
[`${name}_active`, activeTheme]
|
|
95
|
-
];
|
|
96
|
-
const themes2 = Object.fromEntries(themeEntries);
|
|
97
|
-
return themes2;
|
|
98
|
-
}
|
|
99
|
-
const themeCreator = (str = 1, {
|
|
100
|
-
backgrounds,
|
|
101
|
-
isLight = true,
|
|
102
|
-
isBase = false,
|
|
103
|
-
colors = [...backgrounds].reverse(),
|
|
104
|
-
borderColors = isLight ? colors : backgrounds,
|
|
105
|
-
backgroundStrong,
|
|
106
|
-
offsets: offsetsProp
|
|
107
|
-
}) => {
|
|
108
|
-
const offsets = {
|
|
109
|
-
borderColor: (offsetsProp == null ? void 0 : offsetsProp.borderColor) ?? (offsetsProp == null ? void 0 : offsetsProp.background) ?? [0, 0, 0, 0],
|
|
110
|
-
background: (offsetsProp == null ? void 0 : offsetsProp.background) ?? [0, 0, 0, 0],
|
|
111
|
-
color: (offsetsProp == null ? void 0 : offsetsProp.color) ?? [0, 0, 0, 0]
|
|
112
|
-
};
|
|
113
|
-
const darkColors2 = isLight ? colors : backgrounds;
|
|
114
|
-
const lighterDir = isLight ? -1 : 1;
|
|
115
|
-
const darkerDir = -lighterDir;
|
|
116
|
-
const strongerDir = isLight ? darkerDir : lighterDir;
|
|
117
|
-
const softerDir = -strongerDir;
|
|
118
|
-
const get = (arr, index, name = "background") => {
|
|
119
|
-
return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))];
|
|
120
|
-
};
|
|
121
|
-
const colorTranslucent = (0, import_colorUtils.setColorAlpha)((0, import_core.getVariableValue)(get(colors, 0 + str, "color")), 0.5);
|
|
122
|
-
let theme = {
|
|
123
|
-
background: get(backgrounds, str),
|
|
124
|
-
backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),
|
|
125
|
-
backgroundSoft: get(backgrounds, str + softerDir * 2),
|
|
126
|
-
backgroundHover: get(backgrounds, str + lighterDir),
|
|
127
|
-
backgroundPress: get(backgrounds, str + darkerDir),
|
|
128
|
-
backgroundFocus: get(backgrounds, str + darkerDir * 2),
|
|
129
|
-
backgroundTransparent: color.grayA1Light,
|
|
130
|
-
color: get(colors, 0 + str, "color"),
|
|
131
|
-
colorHover: get(colors, 1 + str, "color"),
|
|
132
|
-
colorPress: get(colors, 2 + str, "color"),
|
|
133
|
-
colorFocus: get(colors, 3 + str, "color"),
|
|
134
|
-
colorTranslucent,
|
|
135
|
-
colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],
|
|
136
|
-
shadowColor: isLight ? color.grayA2Light : color.grayA8Light,
|
|
137
|
-
shadowColorHover: darkColors2[!isLight ? 1 : 8],
|
|
138
|
-
shadowColorPress: darkColors2[!isLight ? 1 : 8],
|
|
139
|
-
shadowColorFocus: darkColors2[!isLight ? 1 : 8],
|
|
140
|
-
borderColor: null,
|
|
141
|
-
borderColorHover: null,
|
|
142
|
-
borderColorPress: null,
|
|
143
|
-
borderColorFocus: null
|
|
144
|
-
};
|
|
145
|
-
if (process.env.ENABLE_STEPS) {
|
|
146
|
-
Object.assign(theme, {
|
|
147
|
-
step1: backgrounds[0],
|
|
148
|
-
step2: backgrounds[1],
|
|
149
|
-
step3: backgrounds[2],
|
|
150
|
-
step4: backgrounds[3],
|
|
151
|
-
step5: backgrounds[4],
|
|
152
|
-
step6: backgrounds[5],
|
|
153
|
-
step7: backgrounds[6],
|
|
154
|
-
step8: backgrounds[7],
|
|
155
|
-
step9: backgrounds[8],
|
|
156
|
-
step10: backgrounds[9],
|
|
157
|
-
step11: backgrounds[10],
|
|
158
|
-
step12: backgrounds[11]
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
if (isBase) {
|
|
162
|
-
Object.assign(theme, {
|
|
163
|
-
borderColor: isLight ? get(colors, 8 - str, "borderColor") : get(backgrounds, 2 + str, "borderColor"),
|
|
164
|
-
borderColorHover: isLight ? get(colors, 6 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor"),
|
|
165
|
-
borderColorPress: isLight ? get(colors, 5 - str, "borderColor") : get(backgrounds, 1 + str, "borderColor"),
|
|
166
|
-
borderColorFocus: isLight ? get(colors, 4 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor")
|
|
167
|
-
});
|
|
168
|
-
} else {
|
|
169
|
-
Object.assign(theme, {
|
|
170
|
-
borderColor: get(borderColors, 1 + strongerDir, "borderColor"),
|
|
171
|
-
borderColorHover: get(borderColors, 2 + strongerDir, "borderColor"),
|
|
172
|
-
borderColorPress: get(borderColors, 3 + strongerDir, "borderColor"),
|
|
173
|
-
borderColorFocus: get(borderColors, 4 + strongerDir, "borderColor")
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
return theme;
|
|
177
|
-
};
|
|
178
|
-
const themeColors = {
|
|
26
|
+
const themes = (0, import_create_themes.createThemes)({
|
|
27
|
+
activeColor: "blue",
|
|
179
28
|
light: [
|
|
180
29
|
"#fff",
|
|
181
30
|
"#f4f4f4",
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
31
|
+
"hsl(0, 0%, 99.0%)",
|
|
32
|
+
"hsl(0, 0%, 97.3%)",
|
|
33
|
+
"hsl(0, 0%, 95.1%)",
|
|
34
|
+
"hsl(0, 0%, 93.0%)",
|
|
35
|
+
"hsl(0, 0%, 90.9%)",
|
|
36
|
+
"hsl(0, 0%, 88.7%)",
|
|
37
|
+
"hsl(0, 0%, 85.8%)",
|
|
38
|
+
"hsl(0, 0%, 78.0%)",
|
|
39
|
+
"hsl(0, 0%, 56.1%)",
|
|
40
|
+
"hsl(0, 0%, 52.3%)",
|
|
41
|
+
"hsl(0, 0%, 43.5%)",
|
|
42
|
+
"hsl(0, 0%, 9.0%)"
|
|
194
43
|
],
|
|
195
44
|
dark: [
|
|
196
45
|
"#111111",
|
|
@@ -205,124 +54,12 @@ const themeColors = {
|
|
|
205
54
|
"#545454",
|
|
206
55
|
"#626262",
|
|
207
56
|
"#777777"
|
|
208
|
-
]
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
backgrounds: themeColors.light,
|
|
212
|
-
backgroundStrong: import_core.isWeb ? "#fefefe" : "#f2f2f2",
|
|
213
|
-
borderColors: themeColors.light.slice(2),
|
|
214
|
-
isLight: true,
|
|
215
|
-
offsets: {
|
|
216
|
-
background: [2, 2, 2, 2, 2, 2]
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
const darkThemes = createThemesFrom("dark", themeCreator, {
|
|
220
|
-
backgrounds: themeColors.dark,
|
|
221
|
-
colors: themeColors.light.slice(2),
|
|
222
|
-
backgroundStrong: "#070707",
|
|
223
|
-
isBase: true,
|
|
224
|
-
isLight: false,
|
|
225
|
-
shift: 1,
|
|
226
|
-
offsets: {
|
|
227
|
-
color: [0, 4, 5, 5, 5, 5]
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
darkThemes.dark_darker.background = "#030303";
|
|
231
|
-
darkThemes.dark_darker.backgroundStrong = "#000";
|
|
232
|
-
const light = (0, import_core.createTheme)(__spreadValues(__spreadValues({}, import_tokens.lightColors), lightThemes.light));
|
|
233
|
-
const dark = (0, import_core.createTheme)(__spreadValues(__spreadValues({}, import_tokens.darkColors), darkThemes.dark));
|
|
234
|
-
const baseThemes = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, lightThemes), {
|
|
235
|
-
light,
|
|
236
|
-
light_active: makeActiveTheme(lightThemes.light),
|
|
237
|
-
light_Card: lightThemes.light,
|
|
238
|
-
light_SliderTrack: lightThemes.light_alt2,
|
|
239
|
-
light_SliderTrackActive: lightThemes.light_alt3,
|
|
240
|
-
light_Switch: lightThemes.light_alt1,
|
|
241
|
-
light_SwitchThumb: darkThemes.dark,
|
|
242
|
-
light_DrawerFrame: lightThemes.light_alt1
|
|
243
|
-
}), darkThemes), {
|
|
244
|
-
dark,
|
|
245
|
-
dark_active: makeActiveTheme(darkThemes.dark),
|
|
246
|
-
dark_Card: darkThemes.dark,
|
|
247
|
-
dark_DrawerFrame: darkThemes.dark_alt2,
|
|
248
|
-
dark_SliderTrack: darkThemes.dark_darker,
|
|
249
|
-
dark_SliderTrackActive: darkThemes.dark_alt3,
|
|
250
|
-
dark_Switch: darkThemes.dark_darker,
|
|
251
|
-
dark_SwitchThumb: lightThemes.light_alt3,
|
|
252
|
-
dark_Button: darkThemes.dark_alt1
|
|
253
|
-
});
|
|
254
|
-
function makeActiveTheme(theme) {
|
|
255
|
-
const res = __spreadValues({}, theme);
|
|
256
|
-
res.backgroundHover = res.background;
|
|
257
|
-
res.colorHover = res.color;
|
|
258
|
-
res.backgroundPress = res.background;
|
|
259
|
-
res.colorPress = res.color;
|
|
260
|
-
return res;
|
|
261
|
-
}
|
|
262
|
-
const darkEntries = Object.entries(dark);
|
|
263
|
-
const lightEntries = Object.entries(light);
|
|
264
|
-
function findColors(prefix, dark2 = false) {
|
|
265
|
-
return Object.fromEntries((dark2 ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix)));
|
|
266
|
-
}
|
|
267
|
-
const colorSchemes = [
|
|
268
|
-
{ name: "blue", colors: findColors("blue"), darkColors: findColors("blue", true) },
|
|
269
|
-
{ name: "gray", colors: findColors("gray"), darkColors: findColors("gray", true) },
|
|
270
|
-
{ name: "green", colors: findColors("green"), darkColors: findColors("green", true) },
|
|
271
|
-
{ name: "orange", colors: findColors("orange"), darkColors: findColors("orange", true) },
|
|
272
|
-
{ name: "pink", colors: findColors("pink"), darkColors: findColors("pink", true) },
|
|
273
|
-
{ name: "purple", colors: findColors("purple"), darkColors: findColors("purple", true) },
|
|
274
|
-
{ name: "red", colors: findColors("red"), darkColors: findColors("red", true) },
|
|
275
|
-
{ name: "yellow", colors: findColors("yellow"), darkColors: findColors("yellow", true) },
|
|
276
|
-
{ name: "teal", colors: findColors("teal"), darkColors: findColors("teal", true) }
|
|
277
|
-
];
|
|
278
|
-
const colorNames = [
|
|
279
|
-
"blue",
|
|
280
|
-
"gray",
|
|
281
|
-
"green",
|
|
282
|
-
"orange",
|
|
283
|
-
"pink",
|
|
284
|
-
"purple",
|
|
285
|
-
"red",
|
|
286
|
-
"yellow",
|
|
287
|
-
"teal"
|
|
288
|
-
];
|
|
289
|
-
const colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors: darkColors2 }) => {
|
|
290
|
-
const [altLightThemes, altDarkThemes] = [
|
|
291
|
-
{ colors: darkColors2, backgrounds: colors },
|
|
292
|
-
{ colors, backgrounds: darkColors2 }
|
|
293
|
-
].map((props, i) => {
|
|
294
|
-
const isLight = i === 0;
|
|
295
|
-
const colorsBase = Object.values(props.colors).slice(2);
|
|
296
|
-
const [backgrounds, colors2] = [
|
|
297
|
-
Object.values(props.backgrounds),
|
|
298
|
-
isLight ? colorsBase : [colorsBase[0], "#ccc", ...colorsBase.slice(1)]
|
|
299
|
-
];
|
|
300
|
-
const scheme = isLight ? "light" : "dark";
|
|
301
|
-
const shift = isLight ? 0 : 1;
|
|
302
|
-
const themeWithAlts = createThemesFrom(name, themeCreator, {
|
|
303
|
-
colors: colors2,
|
|
304
|
-
backgrounds,
|
|
305
|
-
borderColors: backgrounds,
|
|
306
|
-
isLight,
|
|
307
|
-
shift,
|
|
308
|
-
isBase: false,
|
|
309
|
-
offsets: {
|
|
310
|
-
background: isLight ? [2, 2, 2, 2, 2, 2] : null,
|
|
311
|
-
borderColor: isLight ? [2, 2, 2, 3, 2] : null,
|
|
312
|
-
color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1]
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v]);
|
|
316
|
-
});
|
|
317
|
-
return [...altLightThemes, ...altDarkThemes];
|
|
57
|
+
],
|
|
58
|
+
colorsLight: import_tokens.colorTokens.light,
|
|
59
|
+
colorsDark: import_tokens.colorTokens.dark
|
|
318
60
|
});
|
|
319
|
-
const colorThemes = Object.fromEntries(colorThemeEntries);
|
|
320
|
-
const allThemes = __spreadValues(__spreadValues({}, baseThemes), colorThemes);
|
|
321
|
-
const themes = allThemes;
|
|
322
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
323
62
|
0 && (module.exports = {
|
|
324
|
-
colorNames,
|
|
325
|
-
colorSchemes,
|
|
326
63
|
themes
|
|
327
64
|
});
|
|
328
65
|
//# sourceMappingURL=themes.js.map
|
package/dist/cjs/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;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA6B;AAE7B,oBAA4B;AAErB,MAAM,aAAS,mCAA6C;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,0BAAY;AAAA,EACzB,YAAY,0BAAY;AAC1B,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/tokens.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
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
6
|
var __export = (target, all) => {
|
|
20
7
|
for (var name in all)
|
|
21
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,9 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
31
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
19
|
var tokens_exports = {};
|
|
33
20
|
__export(tokens_exports, {
|
|
21
|
+
color: () => color,
|
|
22
|
+
colorTokens: () => colorTokens,
|
|
34
23
|
darkColors: () => darkColors,
|
|
35
24
|
lightColors: () => lightColors,
|
|
36
|
-
|
|
25
|
+
radius: () => radius,
|
|
26
|
+
size: () => size,
|
|
27
|
+
space: () => space,
|
|
28
|
+
tokens: () => tokens,
|
|
29
|
+
zIndex: () => zIndex
|
|
37
30
|
});
|
|
38
31
|
module.exports = __toCommonJS(tokens_exports);
|
|
39
32
|
var import_colors = require("@tamagui/colors");
|
|
@@ -53,15 +46,10 @@ const size = {
|
|
|
53
46
|
true: 44,
|
|
54
47
|
4.5: 48,
|
|
55
48
|
5: 52,
|
|
56
|
-
5.5: 59,
|
|
57
49
|
6: 64,
|
|
58
|
-
6.5: 69,
|
|
59
50
|
7: 74,
|
|
60
|
-
7.6: 79,
|
|
61
51
|
8: 84,
|
|
62
|
-
8.5: 89,
|
|
63
52
|
9: 94,
|
|
64
|
-
9.5: 99,
|
|
65
53
|
10: 104,
|
|
66
54
|
11: 124,
|
|
67
55
|
12: 144,
|
|
@@ -79,7 +67,10 @@ const spaces = Object.entries(size).map(([k, v]) => [
|
|
|
79
67
|
Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12))
|
|
80
68
|
]);
|
|
81
69
|
const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v]);
|
|
82
|
-
const space =
|
|
70
|
+
const space = {
|
|
71
|
+
...Object.fromEntries(spaces),
|
|
72
|
+
...Object.fromEntries(spacesNegative)
|
|
73
|
+
};
|
|
83
74
|
const zIndex = {
|
|
84
75
|
0: 0,
|
|
85
76
|
1: 100,
|
|
@@ -92,33 +83,48 @@ const colorTokens = {
|
|
|
92
83
|
light: {
|
|
93
84
|
blue: import_colors.blue,
|
|
94
85
|
gray: import_colors.gray,
|
|
95
|
-
grayA: import_colors.grayA,
|
|
96
86
|
green: import_colors.green,
|
|
97
87
|
orange: import_colors.orange,
|
|
98
88
|
pink: import_colors.pink,
|
|
99
89
|
purple: import_colors.purple,
|
|
100
90
|
red: import_colors.red,
|
|
101
|
-
|
|
102
|
-
yellow: import_colors.yellow,
|
|
103
|
-
teal: import_colors.teal
|
|
91
|
+
yellow: import_colors.yellow
|
|
104
92
|
},
|
|
105
93
|
dark: {
|
|
106
94
|
blue: import_colors.blueDark,
|
|
107
95
|
gray: import_colors.grayDark,
|
|
108
|
-
grayA: import_colors.grayDarkA,
|
|
109
96
|
green: import_colors.greenDark,
|
|
110
97
|
orange: import_colors.orangeDark,
|
|
111
98
|
pink: import_colors.pinkDark,
|
|
112
99
|
purple: import_colors.purpleDark,
|
|
113
100
|
red: import_colors.redDark,
|
|
114
|
-
|
|
115
|
-
yellow: import_colors.yellowDark,
|
|
116
|
-
teal: import_colors.tealDark
|
|
101
|
+
yellow: import_colors.yellowDark
|
|
117
102
|
}
|
|
118
103
|
};
|
|
119
|
-
const darkColors =
|
|
120
|
-
|
|
121
|
-
|
|
104
|
+
const darkColors = {
|
|
105
|
+
...colorTokens.dark.blue,
|
|
106
|
+
...colorTokens.dark.gray,
|
|
107
|
+
...colorTokens.dark.green,
|
|
108
|
+
...colorTokens.dark.orange,
|
|
109
|
+
...colorTokens.dark.pink,
|
|
110
|
+
...colorTokens.dark.purple,
|
|
111
|
+
...colorTokens.dark.red,
|
|
112
|
+
...colorTokens.dark.yellow
|
|
113
|
+
};
|
|
114
|
+
const lightColors = {
|
|
115
|
+
...colorTokens.light.blue,
|
|
116
|
+
...colorTokens.light.gray,
|
|
117
|
+
...colorTokens.light.green,
|
|
118
|
+
...colorTokens.light.orange,
|
|
119
|
+
...colorTokens.light.pink,
|
|
120
|
+
...colorTokens.light.purple,
|
|
121
|
+
...colorTokens.light.red,
|
|
122
|
+
...colorTokens.light.yellow
|
|
123
|
+
};
|
|
124
|
+
const color = {
|
|
125
|
+
...postfixObjKeys(lightColors, "Light"),
|
|
126
|
+
...postfixObjKeys(darkColors, "Dark")
|
|
127
|
+
};
|
|
122
128
|
function postfixObjKeys(obj, postfix) {
|
|
123
129
|
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v]));
|
|
124
130
|
}
|
|
@@ -138,7 +144,7 @@ const radius = {
|
|
|
138
144
|
12: 50
|
|
139
145
|
};
|
|
140
146
|
const tokens = (0, import_core.createTokens)({
|
|
141
|
-
color
|
|
147
|
+
color,
|
|
142
148
|
radius,
|
|
143
149
|
zIndex,
|
|
144
150
|
space,
|
|
@@ -146,8 +152,14 @@ const tokens = (0, import_core.createTokens)({
|
|
|
146
152
|
});
|
|
147
153
|
// Annotate the CommonJS export names for ESM import in node:
|
|
148
154
|
0 && (module.exports = {
|
|
155
|
+
color,
|
|
156
|
+
colorTokens,
|
|
149
157
|
darkColors,
|
|
150
158
|
lightColors,
|
|
151
|
-
|
|
159
|
+
radius,
|
|
160
|
+
size,
|
|
161
|
+
space,
|
|
162
|
+
tokens,
|
|
163
|
+
zIndex
|
|
152
164
|
});
|
|
153
165
|
//# sourceMappingURL=tokens.js.map
|
package/dist/cjs/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": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/colorUtils.js
CHANGED
|
@@ -9,7 +9,7 @@ const hexToRGBA = (hex, alpha = 1) => {
|
|
|
9
9
|
return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`;
|
|
10
10
|
};
|
|
11
11
|
const setColorAlpha = (colorIn, alpha = 1) => {
|
|
12
|
-
|
|
12
|
+
const color = `${getVariableValue(colorIn)}`;
|
|
13
13
|
if (color.startsWith("hsl(")) {
|
|
14
14
|
return color.replace("hsl", "hsla").replace(")", `, ${alpha})`);
|
|
15
15
|
}
|