@tamagui/theme-base 1.4.0 → 1.5.1
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/themesv2.js +223 -0
- package/dist/cjs/themesv2.js.map +7 -0
- package/dist/cjs/tokens.js +2 -2
- package/dist/cjs/tokens.js.map +2 -2
- package/dist/cjs/v2.js +2 -0
- package/dist/cjs/v2.js.map +7 -0
- package/dist/esm/themesv2.js +205 -0
- package/dist/esm/themesv2.js.map +7 -0
- package/dist/esm/themesv2.mjs +205 -0
- package/dist/esm/themesv2.mjs.map +7 -0
- package/dist/esm/tokens.js +1 -1
- package/dist/esm/tokens.js.map +2 -2
- package/dist/esm/tokens.mjs +1 -1
- package/dist/esm/tokens.mjs.map +2 -2
- package/dist/esm/v2.js +1 -0
- package/dist/esm/v2.js.map +7 -0
- package/dist/esm/v2.mjs +1 -0
- package/dist/esm/v2.mjs.map +7 -0
- package/package.json +6 -5
- package/src/tokens.tsx +1 -1
- package/types/themesv2.d.ts.map +1 -0
- package/types/tokens.d.ts +6 -6
- package/types/tokens.d.ts.map +1 -1
- package/types/v2.d.ts.map +1 -0
- package/README.md +0 -21
- package/src/colorUtils.tsx +0 -43
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var themesv2_exports = {};
|
|
20
|
+
__export(themesv2_exports, {
|
|
21
|
+
themes: () => themes
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(themesv2_exports);
|
|
24
|
+
var import_create_theme = require("@tamagui/create-theme");
|
|
25
|
+
var import_tokens = require("./tokens");
|
|
26
|
+
const lightTransparent = "rgba(255,255,255,0)";
|
|
27
|
+
const darkTransparent = "rgba(10,10,10,0)";
|
|
28
|
+
const palettes = {
|
|
29
|
+
dark: [
|
|
30
|
+
darkTransparent,
|
|
31
|
+
"#090909",
|
|
32
|
+
"#151515",
|
|
33
|
+
"#191919",
|
|
34
|
+
"#232323",
|
|
35
|
+
"#282828",
|
|
36
|
+
"#323232",
|
|
37
|
+
"#424242",
|
|
38
|
+
"#494949",
|
|
39
|
+
"#545454",
|
|
40
|
+
"#626262",
|
|
41
|
+
"#a5a5a5",
|
|
42
|
+
"#fff",
|
|
43
|
+
lightTransparent
|
|
44
|
+
],
|
|
45
|
+
light: [
|
|
46
|
+
lightTransparent,
|
|
47
|
+
"#fff",
|
|
48
|
+
"#f4f4f4",
|
|
49
|
+
"hsl(0, 0%, 99.0%)",
|
|
50
|
+
"hsl(0, 0%, 97.3%)",
|
|
51
|
+
"hsl(0, 0%, 95.1%)",
|
|
52
|
+
"hsl(0, 0%, 93.0%)",
|
|
53
|
+
"hsl(0, 0%, 90.9%)",
|
|
54
|
+
"hsl(0, 0%, 80.0%)",
|
|
55
|
+
"hsl(0, 0%, 56.1%)",
|
|
56
|
+
"hsl(0, 0%, 52.3%)",
|
|
57
|
+
"hsl(0, 0%, 43.5%)",
|
|
58
|
+
"hsl(0, 0%, 9.0%)",
|
|
59
|
+
darkTransparent
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
const colorScale = {
|
|
63
|
+
color1: 1,
|
|
64
|
+
color2: 2,
|
|
65
|
+
color3: 3,
|
|
66
|
+
color4: 4,
|
|
67
|
+
color5: 5,
|
|
68
|
+
color6: 6,
|
|
69
|
+
color7: 7,
|
|
70
|
+
color8: 8,
|
|
71
|
+
color9: 9,
|
|
72
|
+
color10: 10,
|
|
73
|
+
color11: 11,
|
|
74
|
+
color12: 12
|
|
75
|
+
};
|
|
76
|
+
const skip = {
|
|
77
|
+
...colorScale,
|
|
78
|
+
shadowColor: 1,
|
|
79
|
+
shadowColorHover: 1,
|
|
80
|
+
shadowColorPress: 2,
|
|
81
|
+
shadowColorFocus: 2
|
|
82
|
+
};
|
|
83
|
+
const template = {
|
|
84
|
+
...skip,
|
|
85
|
+
// the background, color, etc keys here work like generics - they make it so you
|
|
86
|
+
// can publish components for others to use without mandating a specific color scale
|
|
87
|
+
// the @tamagui/button Button component looks for `$background`, so you set the
|
|
88
|
+
// dark_red_Button theme to have a stronger background than the dark_red theme.
|
|
89
|
+
background: 2,
|
|
90
|
+
backgroundHover: 3,
|
|
91
|
+
backgroundPress: 1,
|
|
92
|
+
backgroundFocus: 2,
|
|
93
|
+
backgroundStrong: 1,
|
|
94
|
+
backgroundTransparent: 0,
|
|
95
|
+
color: -1,
|
|
96
|
+
colorHover: -2,
|
|
97
|
+
colorPress: -1,
|
|
98
|
+
colorFocus: -2,
|
|
99
|
+
colorTransparent: -0,
|
|
100
|
+
borderColor: 3,
|
|
101
|
+
borderColorHover: 4,
|
|
102
|
+
borderColorPress: 2,
|
|
103
|
+
borderColorFocus: 3,
|
|
104
|
+
placeholderColor: -4
|
|
105
|
+
};
|
|
106
|
+
const lightShadowColor = "rgba(0,0,0,0.15)";
|
|
107
|
+
const lightShadowColorStrong = "rgba(0,0,0,0.2)";
|
|
108
|
+
const darkShadowColor = "rgba(0,0,0,0.5)";
|
|
109
|
+
const darkShadowColorStrong = "rgba(0,0,0,0.7)";
|
|
110
|
+
const lightShadows = {
|
|
111
|
+
shadowColor: lightShadowColorStrong,
|
|
112
|
+
shadowColorHover: lightShadowColorStrong,
|
|
113
|
+
shadowColorPress: lightShadowColor,
|
|
114
|
+
shadowColorFocus: lightShadowColor
|
|
115
|
+
};
|
|
116
|
+
const darkShadows = {
|
|
117
|
+
shadowColor: darkShadowColorStrong,
|
|
118
|
+
shadowColorHover: darkShadowColorStrong,
|
|
119
|
+
shadowColorPress: darkShadowColor,
|
|
120
|
+
shadowColorFocus: darkShadowColor
|
|
121
|
+
};
|
|
122
|
+
const lightTemplate = {
|
|
123
|
+
...template,
|
|
124
|
+
...lightShadows
|
|
125
|
+
};
|
|
126
|
+
const darkTemplate = { ...template, ...darkShadows };
|
|
127
|
+
const light = (0, import_create_theme.createTheme)(palettes.light, lightTemplate, {
|
|
128
|
+
nonInheritedValues: import_tokens.lightColors
|
|
129
|
+
});
|
|
130
|
+
const dark = (0, import_create_theme.createTheme)(palettes.dark, darkTemplate, { nonInheritedValues: import_tokens.darkColors });
|
|
131
|
+
const baseThemes = {
|
|
132
|
+
light,
|
|
133
|
+
dark
|
|
134
|
+
};
|
|
135
|
+
const max = palettes.dark.length - 1;
|
|
136
|
+
const masks = {
|
|
137
|
+
weaker: (0, import_create_theme.createWeakenMask)({
|
|
138
|
+
by: 1,
|
|
139
|
+
min: 1,
|
|
140
|
+
max
|
|
141
|
+
}),
|
|
142
|
+
stronger: (0, import_create_theme.createStrengthenMask)({
|
|
143
|
+
by: 1,
|
|
144
|
+
min: 1,
|
|
145
|
+
max
|
|
146
|
+
})
|
|
147
|
+
};
|
|
148
|
+
const themes = (0, import_create_theme.addChildren)(baseThemes, (name, themeIn) => {
|
|
149
|
+
const theme = themeIn;
|
|
150
|
+
const inverseName = name === "light" ? "dark" : "light";
|
|
151
|
+
const inverseTheme = baseThemes[inverseName];
|
|
152
|
+
const transparent = (hsl, opacity = 0) => hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`);
|
|
153
|
+
const [colorThemes, inverseColorThemes] = [
|
|
154
|
+
import_tokens.colorTokens[name],
|
|
155
|
+
import_tokens.colorTokens[inverseName]
|
|
156
|
+
].map((colorSet) => {
|
|
157
|
+
return Object.fromEntries(
|
|
158
|
+
Object.keys(colorSet).map((color) => {
|
|
159
|
+
const colorPalette = Object.values(colorSet[color]);
|
|
160
|
+
const first6 = colorPalette.slice(0, 6);
|
|
161
|
+
const last5 = colorPalette.slice(colorPalette.length - 5);
|
|
162
|
+
return [
|
|
163
|
+
color,
|
|
164
|
+
(0, import_create_theme.createTheme)(
|
|
165
|
+
[
|
|
166
|
+
transparent(colorPalette[0]),
|
|
167
|
+
...first6,
|
|
168
|
+
...last5,
|
|
169
|
+
theme.color,
|
|
170
|
+
transparent(colorPalette[colorPalette.length - 1])
|
|
171
|
+
],
|
|
172
|
+
template
|
|
173
|
+
)
|
|
174
|
+
];
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
...getAltThemes(theme, inverseTheme),
|
|
180
|
+
...getComponentThemes(theme, inverseTheme),
|
|
181
|
+
...(0, import_create_theme.addChildren)(colorThemes, (colorName, colorTheme) => {
|
|
182
|
+
const inverse = inverseColorThemes[colorName];
|
|
183
|
+
console.log("color", colorName);
|
|
184
|
+
return {
|
|
185
|
+
...getAltThemes(colorTheme, inverse),
|
|
186
|
+
...getComponentThemes(colorTheme, inverse)
|
|
187
|
+
};
|
|
188
|
+
})
|
|
189
|
+
};
|
|
190
|
+
function getComponentThemes(theme2, inverse) {
|
|
191
|
+
const stronger1 = (0, import_create_theme.applyMask)(theme2, masks.stronger, { skip });
|
|
192
|
+
const stronger2 = (0, import_create_theme.applyMask)(stronger1, masks.stronger, { skip });
|
|
193
|
+
console.log("stronger2", { theme: theme2, stronger1, stronger2 });
|
|
194
|
+
const inverse1 = (0, import_create_theme.applyMask)(inverse, masks.weaker, { skip });
|
|
195
|
+
const inverse2 = (0, import_create_theme.applyMask)(inverse1, masks.weaker, { skip });
|
|
196
|
+
return {
|
|
197
|
+
Button: stronger2,
|
|
198
|
+
DrawerFrame: stronger1,
|
|
199
|
+
SliderTrack: theme2,
|
|
200
|
+
SliderTrackActive: stronger2,
|
|
201
|
+
SliderThumb: inverse1,
|
|
202
|
+
Progress: stronger1,
|
|
203
|
+
ProgressIndicator: inverse,
|
|
204
|
+
Switch: stronger2,
|
|
205
|
+
SwitchThumb: inverse2,
|
|
206
|
+
TooltipArrow: stronger1,
|
|
207
|
+
TooltipContent: stronger2
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function getAltThemes(theme2, inverse) {
|
|
211
|
+
const alt1 = (0, import_create_theme.applyMask)(theme2, masks.weaker, { skip });
|
|
212
|
+
const alt2 = (0, import_create_theme.applyMask)(alt1, masks.weaker, { skip });
|
|
213
|
+
return (0, import_create_theme.addChildren)({ alt1, alt2 }, (name2, theme3) => {
|
|
214
|
+
return getComponentThemes(theme3, inverse);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
globalThis["themes"] = themes;
|
|
219
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
220
|
+
0 && (module.exports = {
|
|
221
|
+
themes
|
|
222
|
+
});
|
|
223
|
+
//# sourceMappingURL=themesv2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themesv2.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 console.log('color', 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 console.log('stronger2', { theme, stronger1, stronger2 })\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\nglobalThis['themes'] = themes\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAMO;AAEP,oBAAqD;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,M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ens.js
CHANGED
|
@@ -30,7 +30,7 @@ __export(tokens_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(tokens_exports);
|
|
32
32
|
var import_colors = require("@tamagui/colors");
|
|
33
|
-
var
|
|
33
|
+
var import_web = require("@tamagui/web");
|
|
34
34
|
const size = {
|
|
35
35
|
$0: 0,
|
|
36
36
|
"$0.25": 2,
|
|
@@ -158,7 +158,7 @@ const radius = {
|
|
|
158
158
|
11: 42,
|
|
159
159
|
12: 50
|
|
160
160
|
};
|
|
161
|
-
const tokens = (0,
|
|
161
|
+
const tokens = (0, import_web.createTokens)({
|
|
162
162
|
color,
|
|
163
163
|
radius,
|
|
164
164
|
zIndex,
|
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 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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAiBO;AACP,
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAiBO;AACP,iBAAuC;AAchC,MAAM,OAAO;AAAA,EAClB,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,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AA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,MAAM,aAAS,yBAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/v2.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
console.log("color", colorName);
|
|
167
|
+
return {
|
|
168
|
+
...getAltThemes(colorTheme, inverse),
|
|
169
|
+
...getComponentThemes(colorTheme, inverse)
|
|
170
|
+
};
|
|
171
|
+
})
|
|
172
|
+
};
|
|
173
|
+
function getComponentThemes(theme2, inverse) {
|
|
174
|
+
const stronger1 = applyMask(theme2, masks.stronger, { skip });
|
|
175
|
+
const stronger2 = applyMask(stronger1, masks.stronger, { skip });
|
|
176
|
+
console.log("stronger2", { theme: theme2, stronger1, stronger2 });
|
|
177
|
+
const inverse1 = applyMask(inverse, masks.weaker, { skip });
|
|
178
|
+
const inverse2 = applyMask(inverse1, masks.weaker, { skip });
|
|
179
|
+
return {
|
|
180
|
+
Button: stronger2,
|
|
181
|
+
DrawerFrame: stronger1,
|
|
182
|
+
SliderTrack: theme2,
|
|
183
|
+
SliderTrackActive: stronger2,
|
|
184
|
+
SliderThumb: inverse1,
|
|
185
|
+
Progress: stronger1,
|
|
186
|
+
ProgressIndicator: inverse,
|
|
187
|
+
Switch: stronger2,
|
|
188
|
+
SwitchThumb: inverse2,
|
|
189
|
+
TooltipArrow: stronger1,
|
|
190
|
+
TooltipContent: stronger2
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function getAltThemes(theme2, inverse) {
|
|
194
|
+
const alt1 = applyMask(theme2, masks.weaker, { skip });
|
|
195
|
+
const alt2 = applyMask(alt1, masks.weaker, { skip });
|
|
196
|
+
return addChildren({ alt1, alt2 }, (name2, theme3) => {
|
|
197
|
+
return getComponentThemes(theme3, inverse);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
globalThis["themes"] = themes;
|
|
202
|
+
export {
|
|
203
|
+
themes
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=themesv2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themesv2.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 console.log('color', 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 console.log('stronger2', { theme, stronger1, stronger2 })\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\nglobalThis['themes'] = themes\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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Aa,YAAmB,OAAc;AAAA,QACjD,GAAG,mBAAmB,YAAmB,OAAc;AAAA,MACzD;AAAA,IACF,CAAC;AAAA,EACH;AAEA,WAAS,mBAAmBA,QAAc,SAAgB;AACxD,UAAM,YAAY,UAAUA,QAAO,MAAM,UAAU,EAAE,KAAK,CAAC;AAC3D,UAAM,YAAY,UAAU,WAAW,MAAM,UAAU,EAAE,KAAK,CAAC;AAC/D,YAAQ,IAAI,aAAa,EAAE,OAAAA,QAAO,WAAW,UAAU,CAAC;AACxD,UAAM,WAAW,UAAU,SAAS,MAAM,QAAQ,EAAE,KAAK,CAAC;AAC1D,UAAM,WAAW,UAAU,UAAU,MAAM,QAAQ,EAAE,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;AAED,WAAW,QAAQ,IAAI;",
|
|
6
|
+
"names": ["theme", "name"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
console.log("color", colorName);
|
|
167
|
+
return {
|
|
168
|
+
...getAltThemes(colorTheme, inverse),
|
|
169
|
+
...getComponentThemes(colorTheme, inverse)
|
|
170
|
+
};
|
|
171
|
+
})
|
|
172
|
+
};
|
|
173
|
+
function getComponentThemes(theme2, inverse) {
|
|
174
|
+
const stronger1 = applyMask(theme2, masks.stronger, { skip });
|
|
175
|
+
const stronger2 = applyMask(stronger1, masks.stronger, { skip });
|
|
176
|
+
console.log("stronger2", { theme: theme2, stronger1, stronger2 });
|
|
177
|
+
const inverse1 = applyMask(inverse, masks.weaker, { skip });
|
|
178
|
+
const inverse2 = applyMask(inverse1, masks.weaker, { skip });
|
|
179
|
+
return {
|
|
180
|
+
Button: stronger2,
|
|
181
|
+
DrawerFrame: stronger1,
|
|
182
|
+
SliderTrack: theme2,
|
|
183
|
+
SliderTrackActive: stronger2,
|
|
184
|
+
SliderThumb: inverse1,
|
|
185
|
+
Progress: stronger1,
|
|
186
|
+
ProgressIndicator: inverse,
|
|
187
|
+
Switch: stronger2,
|
|
188
|
+
SwitchThumb: inverse2,
|
|
189
|
+
TooltipArrow: stronger1,
|
|
190
|
+
TooltipContent: stronger2
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function getAltThemes(theme2, inverse) {
|
|
194
|
+
const alt1 = applyMask(theme2, masks.weaker, { skip });
|
|
195
|
+
const alt2 = applyMask(alt1, masks.weaker, { skip });
|
|
196
|
+
return addChildren({ alt1, alt2 }, (name2, theme3) => {
|
|
197
|
+
return getComponentThemes(theme3, inverse);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
globalThis["themes"] = themes;
|
|
202
|
+
export {
|
|
203
|
+
themes
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=themesv2.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themesv2.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 console.log('color', 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 console.log('stronger2', { theme, stronger1, stronger2 })\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\nglobalThis['themes'] = themes\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,EACjB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,Y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AK,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;AAED,WAAW,QAAQ,IAAI;",
|
|
6
|
+
"names": ["theme", "name"]
|
|
7
|
+
}
|
package/dist/esm/tokens.js
CHANGED
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 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
|
|
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,
|
|
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})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;AAAA,IACZ,OAAO,QAAQ,GAAG,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,WAAW,CAAC,CAAC;AAAA,EAC3D;AACF;AAEO,MAAM,SAAS;AAAA,EACpB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,MAAM,SAAS,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/tokens.mjs
CHANGED
package/dist/esm/tokens.mjs.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 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
|
|
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,
|
|
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,EAC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AG,IAAI,WAAW,CAAC,CAAC;AAAA,EAC3D;AACF;AAEO,MAAM,SAAS;AAAA,EACpB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,MAAM,SAAS,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/v2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=v2.js.map
|
package/dist/esm/v2.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=v2.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/theme-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/colors": "^1.
|
|
31
|
-
"@tamagui/core": "^1.
|
|
32
|
-
"@tamagui/create-
|
|
30
|
+
"@tamagui/colors": "^1.5.1",
|
|
31
|
+
"@tamagui/core": "^1.5.1",
|
|
32
|
+
"@tamagui/create-theme": "^1.5.1",
|
|
33
|
+
"@tamagui/create-themes": "^1.5.1"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@tamagui/build": "^1.
|
|
36
|
+
"@tamagui/build": "^1.5.1"
|
|
36
37
|
},
|
|
37
38
|
"publishConfig": {
|
|
38
39
|
"access": "public"
|
package/src/tokens.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
yellow,
|
|
17
17
|
yellowDark,
|
|
18
18
|
} from '@tamagui/colors'
|
|
19
|
-
import { Variable, createTokens
|
|
19
|
+
import { Variable, createTokens } from '@tamagui/web'
|
|
20
20
|
|
|
21
21
|
// should roughly map to button/input etc height at each level
|
|
22
22
|
// fonts should match that height/lineHeight at each stop
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themesv2.d.ts","sourceRoot":"","sources":["../src/themesv2.tsx"],"names":[],"mappings":"AA2JA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4EjB,CAAA"}
|
package/types/tokens.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Variable } from '@tamagui/
|
|
1
|
+
import { Variable } from '@tamagui/web';
|
|
2
2
|
export declare const size: {
|
|
3
3
|
$0: number;
|
|
4
4
|
'$0.25': number;
|
|
@@ -971,13 +971,13 @@ export declare const tokens: {
|
|
|
971
971
|
};
|
|
972
972
|
radius: {
|
|
973
973
|
0: Variable<number>;
|
|
974
|
-
1: Variable<number>;
|
|
975
|
-
4: Variable<number>;
|
|
976
974
|
2: Variable<number>;
|
|
977
|
-
|
|
975
|
+
4: Variable<number>;
|
|
978
976
|
8: Variable<number>;
|
|
979
977
|
true: Variable<number>;
|
|
978
|
+
1: Variable<number>;
|
|
980
979
|
12: Variable<number>;
|
|
980
|
+
3: Variable<number>;
|
|
981
981
|
5: Variable<number>;
|
|
982
982
|
7: Variable<number>;
|
|
983
983
|
9: Variable<number>;
|
|
@@ -987,9 +987,9 @@ export declare const tokens: {
|
|
|
987
987
|
};
|
|
988
988
|
zIndex: {
|
|
989
989
|
0: Variable<number>;
|
|
990
|
-
1: Variable<number>;
|
|
991
|
-
4: Variable<number>;
|
|
992
990
|
2: Variable<number>;
|
|
991
|
+
4: Variable<number>;
|
|
992
|
+
1: Variable<number>;
|
|
993
993
|
3: Variable<number>;
|
|
994
994
|
5: Variable<number>;
|
|
995
995
|
};
|
package/types/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAgB,MAAM,cAAc,CAAA;AAcrD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BhB,CAAA;AAED,KAAK,UAAU,GAAG,MAAM,OAAO,IAAI,CAAA;AACnC,KAAK,KAAK,GAAG;KACV,GAAG,IAAI,UAAU,SAAS,IAAI,MAAM,GAAG,EAAE,GAAG,GAAG,GAAG,UAAU,GAAG,MAAM;CACvE,CAAA;AACD,KAAK,QAAQ,GAAG,GAAG,MAAM,KAAK,SAAS,GAAG,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE,CAAA;AAkBjE,KAAK,qBAAqB,GACtB,IAAI,QAAQ,SAAS,IAAI,MAAM,GAAG,EAAE,GAAG,GAAG,GAAG,QAAQ,EAAE,GACvD,QAAQ,CAAA;AAEZ,eAAO,MAAM,KAAK,EAAE;KACjB,GAAG,IAAI,qBAAqB,GAAG,GAAG,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM;CAIvE,CAAA;AAER,eAAO,MAAM,MAAM;;;;;;;CAOlB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../src/v2.tsx"],"names":[],"mappings":""}
|
package/README.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
```tsx
|
|
2
|
-
import '@tamagui/theme-base/inter.css' // web-fonts
|
|
3
|
-
import '@tamagui/theme-base/fira-code.css' // web-fonts
|
|
4
|
-
import { shorthands } from '@tamagui/shorthands'
|
|
5
|
-
import { themes, tokens } from '@tamagui/theme-base'
|
|
6
|
-
import { createTamagui } from 'tamagui'
|
|
7
|
-
|
|
8
|
-
export default createTamagui({
|
|
9
|
-
themes,
|
|
10
|
-
tokens,
|
|
11
|
-
shorthands,
|
|
12
|
-
})
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
For Fira Code:
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
.font_mono {
|
|
19
|
-
font-feature-settings:"liga","tnum","zero","ss01","locl","calt";
|
|
20
|
-
}
|
|
21
|
-
```
|
package/src/colorUtils.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Variable, getVariableValue } from '@tamagui/core'
|
|
2
|
-
|
|
3
|
-
export const hexToRGBA = (hex: string, alpha = 1) => {
|
|
4
|
-
if (!isValidHex(hex)) {
|
|
5
|
-
throw new Error('Invalid HEX')
|
|
6
|
-
}
|
|
7
|
-
const chunkSize = Math.floor((hex.length - 1) / 3)
|
|
8
|
-
const hexArr = getChunksFromString(hex.slice(1), chunkSize)
|
|
9
|
-
const [r, g, b, a] = hexArr?.map(convertHexUnitTo256) ?? []
|
|
10
|
-
return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const setColorAlpha = (colorIn: string | Variable, alpha = 1) => {
|
|
14
|
-
const color = `${getVariableValue(colorIn)}`
|
|
15
|
-
if (color.startsWith('hsl(')) {
|
|
16
|
-
return color.replace('hsl', 'hsla').replace(')', `, ${alpha})`)
|
|
17
|
-
}
|
|
18
|
-
if (color.startsWith('#')) {
|
|
19
|
-
return hexToRGBA(color, alpha)
|
|
20
|
-
}
|
|
21
|
-
if (color.startsWith('rgb(')) {
|
|
22
|
-
return color.replace('rgb', 'rgba').replace(')', `, ${alpha})`)
|
|
23
|
-
}
|
|
24
|
-
return color
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const isValidHex = (hex: string) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex)
|
|
28
|
-
|
|
29
|
-
const getChunksFromString = (st: string, chunkSize = 0) =>
|
|
30
|
-
st.match(new RegExp(`.{${chunkSize}}`, 'g'))
|
|
31
|
-
|
|
32
|
-
const convertHexUnitTo256 = (hexStr: string) =>
|
|
33
|
-
parseInt(hexStr.repeat(2 / hexStr.length), 16)
|
|
34
|
-
|
|
35
|
-
const getAlphaFloat = (a: any, alpha = 1) => {
|
|
36
|
-
if (a !== undefined) {
|
|
37
|
-
return a / 255
|
|
38
|
-
}
|
|
39
|
-
if (typeof alpha !== 'number' || alpha < 0 || alpha > 1) {
|
|
40
|
-
return 1
|
|
41
|
-
}
|
|
42
|
-
return alpha
|
|
43
|
-
}
|