@tamagui/theme-base 1.0.1-beta.18 → 1.0.1-beta.180
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 +10 -10
- package/dist/cjs/colorUtils.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/themes.js +196 -147
- package/dist/cjs/themes.js.map +3 -3
- package/dist/cjs/tokens.js +116 -30
- package/dist/cjs/tokens.js.map +2 -2
- package/dist/esm/colorUtils.js +10 -13
- package/dist/esm/colorUtils.js.map +1 -1
- package/dist/esm/index.js +0 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/themes.js +191 -134
- package/dist/esm/themes.js.map +3 -3
- package/dist/esm/tokens.js +126 -18
- package/dist/esm/tokens.js.map +2 -2
- package/package.json +16 -6
- package/src/colorUtils.tsx +42 -0
- package/src/index.tsx +3 -0
- package/src/themes.tsx +449 -0
- package/src/tokens.tsx +177 -0
- package/types/themes.d.ts +124 -4479
- package/types/tokens.d.ts +657 -197
- package/dist/jsx/colorUtils.js +0 -42
- package/dist/jsx/index.js +0 -3
- package/dist/jsx/themes.js +0 -244
- package/dist/jsx/tokens.js +0 -45
- 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/esm/tokens.js
CHANGED
|
@@ -1,14 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {
|
|
2
|
+
blue,
|
|
3
|
+
blueDark,
|
|
4
|
+
gray,
|
|
5
|
+
grayDark,
|
|
6
|
+
green,
|
|
7
|
+
greenDark,
|
|
8
|
+
orange,
|
|
9
|
+
orangeDark,
|
|
10
|
+
pink,
|
|
11
|
+
pinkDark,
|
|
12
|
+
purple,
|
|
13
|
+
purpleDark,
|
|
14
|
+
red,
|
|
15
|
+
redDark,
|
|
16
|
+
yellow,
|
|
17
|
+
yellowDark
|
|
18
|
+
} from "@tamagui/colors";
|
|
19
|
+
import { createTokens } from "@tamagui/core";
|
|
20
|
+
const size = {
|
|
21
|
+
0: 0,
|
|
22
|
+
0.25: 2,
|
|
23
|
+
0.5: 4,
|
|
24
|
+
0.75: 8,
|
|
25
|
+
1: 20,
|
|
26
|
+
1.5: 24,
|
|
27
|
+
2: 28,
|
|
28
|
+
2.5: 32,
|
|
29
|
+
3: 36,
|
|
30
|
+
3.5: 40,
|
|
31
|
+
4: 44,
|
|
32
|
+
true: 44,
|
|
33
|
+
4.5: 48,
|
|
34
|
+
5: 52,
|
|
35
|
+
5.5: 59,
|
|
36
|
+
6: 64,
|
|
37
|
+
6.5: 69,
|
|
38
|
+
7: 74,
|
|
39
|
+
7.6: 79,
|
|
40
|
+
8: 84,
|
|
41
|
+
8.5: 89,
|
|
42
|
+
9: 94,
|
|
43
|
+
9.5: 99,
|
|
44
|
+
10: 104,
|
|
45
|
+
11: 124,
|
|
46
|
+
12: 144,
|
|
47
|
+
13: 164,
|
|
48
|
+
14: 184,
|
|
49
|
+
15: 204,
|
|
50
|
+
16: 224,
|
|
51
|
+
17: 224,
|
|
52
|
+
18: 244,
|
|
53
|
+
19: 264,
|
|
54
|
+
20: 284
|
|
55
|
+
};
|
|
56
|
+
const spaces = Object.entries(size).map(([k, v]) => [
|
|
57
|
+
k,
|
|
58
|
+
Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12))
|
|
59
|
+
]);
|
|
60
|
+
const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v]);
|
|
9
61
|
const space = {
|
|
10
|
-
...
|
|
11
|
-
...Object.fromEntries(
|
|
62
|
+
...Object.fromEntries(spaces),
|
|
63
|
+
...Object.fromEntries(spacesNegative)
|
|
12
64
|
};
|
|
13
65
|
const zIndex = {
|
|
14
66
|
0: 0,
|
|
@@ -18,10 +70,55 @@ const zIndex = {
|
|
|
18
70
|
4: 400,
|
|
19
71
|
5: 500
|
|
20
72
|
};
|
|
73
|
+
const colorTokens = {
|
|
74
|
+
light: {
|
|
75
|
+
blue,
|
|
76
|
+
gray,
|
|
77
|
+
green,
|
|
78
|
+
orange,
|
|
79
|
+
pink,
|
|
80
|
+
purple,
|
|
81
|
+
red,
|
|
82
|
+
yellow
|
|
83
|
+
},
|
|
84
|
+
dark: {
|
|
85
|
+
blue: blueDark,
|
|
86
|
+
gray: grayDark,
|
|
87
|
+
green: greenDark,
|
|
88
|
+
orange: orangeDark,
|
|
89
|
+
pink: pinkDark,
|
|
90
|
+
purple: purpleDark,
|
|
91
|
+
red: redDark,
|
|
92
|
+
yellow: yellowDark
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const darkColors = {
|
|
96
|
+
...colorTokens.dark.blue,
|
|
97
|
+
...colorTokens.dark.gray,
|
|
98
|
+
...colorTokens.dark.green,
|
|
99
|
+
...colorTokens.dark.orange,
|
|
100
|
+
...colorTokens.dark.pink,
|
|
101
|
+
...colorTokens.dark.purple,
|
|
102
|
+
...colorTokens.dark.red,
|
|
103
|
+
...colorTokens.dark.yellow
|
|
104
|
+
};
|
|
105
|
+
const lightColors = {
|
|
106
|
+
...colorTokens.light.blue,
|
|
107
|
+
...colorTokens.light.gray,
|
|
108
|
+
...colorTokens.light.green,
|
|
109
|
+
...colorTokens.light.orange,
|
|
110
|
+
...colorTokens.light.pink,
|
|
111
|
+
...colorTokens.light.purple,
|
|
112
|
+
...colorTokens.light.red,
|
|
113
|
+
...colorTokens.light.yellow
|
|
114
|
+
};
|
|
21
115
|
const color = {
|
|
22
|
-
...
|
|
23
|
-
...
|
|
116
|
+
...postfixObjKeys(lightColors, "Light"),
|
|
117
|
+
...postfixObjKeys(darkColors, "Dark")
|
|
24
118
|
};
|
|
119
|
+
function postfixObjKeys(obj, postfix) {
|
|
120
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v]));
|
|
121
|
+
}
|
|
25
122
|
const radius = {
|
|
26
123
|
0: 0,
|
|
27
124
|
1: 3,
|
|
@@ -29,18 +126,29 @@ const radius = {
|
|
|
29
126
|
3: 7,
|
|
30
127
|
4: 9,
|
|
31
128
|
5: 10,
|
|
32
|
-
6:
|
|
33
|
-
7:
|
|
34
|
-
8:
|
|
35
|
-
9:
|
|
129
|
+
6: 16,
|
|
130
|
+
7: 19,
|
|
131
|
+
8: 22,
|
|
132
|
+
9: 26,
|
|
133
|
+
10: 34,
|
|
134
|
+
11: 42,
|
|
135
|
+
12: 50
|
|
36
136
|
};
|
|
137
|
+
const tokens = createTokens({
|
|
138
|
+
color,
|
|
139
|
+
radius,
|
|
140
|
+
zIndex,
|
|
141
|
+
space,
|
|
142
|
+
size
|
|
143
|
+
});
|
|
37
144
|
export {
|
|
38
145
|
color,
|
|
39
|
-
|
|
146
|
+
darkColors,
|
|
147
|
+
lightColors,
|
|
40
148
|
radius,
|
|
41
149
|
size,
|
|
42
|
-
sizeKeys,
|
|
43
150
|
space,
|
|
151
|
+
tokens,
|
|
44
152
|
zIndex
|
|
45
153
|
};
|
|
46
154
|
//# sourceMappingURL=tokens.js.map
|
package/dist/esm/tokens.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tokens.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
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 5.5: 59,\n 6: 64,\n 6.5: 69,\n 7: 74,\n 7.6: 79,\n 8: 84,\n 8.5: 89,\n 9: 94,\n 9.5: 99,\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\nconst colorTokens = {\n light: {\n blue: blue,\n gray: gray,\n green: green,\n orange: orange,\n pink: pink,\n purple: purple,\n red: red,\n yellow: yellow,\n },\n dark: {\n blue: blueDark,\n gray: grayDark,\n green: greenDark,\n orange: orangeDark,\n pink: pinkDark,\n purple: purpleDark,\n red: redDark,\n yellow: yellowDark,\n },\n}\n\nexport const darkColors = {\n ...colorTokens.dark.blue,\n ...colorTokens.dark.gray,\n ...colorTokens.dark.green,\n ...colorTokens.dark.orange,\n ...colorTokens.dark.pink,\n ...colorTokens.dark.purple,\n ...colorTokens.dark.red,\n ...colorTokens.dark.yellow,\n}\n\nexport const lightColors = {\n ...colorTokens.light.blue,\n ...colorTokens.light.gray,\n ...colorTokens.light.green,\n ...colorTokens.light.orange,\n ...colorTokens.light.pink,\n ...colorTokens.light.purple,\n ...colorTokens.light.red,\n ...colorTokens.light.yellow,\n}\n\nexport const color = {\n ...postfixObjKeys(lightColors, 'Light'),\n ...postfixObjKeys(darkColors, 'Dark'),\n}\n\nfunction postfixObjKeys<A extends { [key: string]: Variable<string> | string }, B extends string>(\n obj: A,\n postfix: B\n): {\n [Key in `${keyof A extends string ? keyof A : never}${B}`]: Variable<string> | string\n} {\n return Object.fromEntries(Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])) as any\n}\n\nexport const radius = {\n 0: 0,\n 1: 3,\n 2: 5,\n 3: 7,\n 4: 9,\n 5: 10,\n 6: 16,\n 7: 19,\n 8: 22,\n 9: 26,\n 10: 34,\n 11: 42,\n 12: 50,\n}\n\nexport const tokens = createTokens({\n color,\n radius,\n zIndex,\n space,\n size,\n})\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAmB,oBAAoB;AAchC,MAAM,OAAO;AAAA,EAClB,GAAG;AAAA,EACH,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,KAAK;AAAA,EACL,GAAG;AAAA,EACH,MAAM;AAAA,EACN,KAAK;AAAA,E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1-beta.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.1-beta.180",
|
|
4
|
+
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
7
|
-
"
|
|
7
|
+
"sideEffects": false,
|
|
8
8
|
"files": [
|
|
9
|
+
"src",
|
|
9
10
|
"types",
|
|
10
11
|
"dist"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "tamagui-build",
|
|
14
15
|
"watch": "tamagui-build --watch",
|
|
16
|
+
"lint": "eslint",
|
|
17
|
+
"lint:fix": "yarn lint --fix",
|
|
15
18
|
"clean": "tamagui-build clean",
|
|
16
19
|
"clean:build": "tamagui-build clean:build"
|
|
17
20
|
},
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/esm/index.js",
|
|
25
|
+
"require": "./dist/cjs/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
18
28
|
"dependencies": {
|
|
19
|
-
"@tamagui/colors": "^1.0.1-beta.
|
|
20
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
29
|
+
"@tamagui/colors": "^1.0.1-beta.180",
|
|
30
|
+
"@tamagui/core": "^1.0.1-beta.180"
|
|
21
31
|
},
|
|
22
32
|
"devDependencies": {
|
|
23
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
33
|
+
"@tamagui/build": "^1.0.1-beta.180"
|
|
24
34
|
},
|
|
25
35
|
"publishConfig": {
|
|
26
36
|
"access": "public"
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
let 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) => parseInt(hexStr.repeat(2 / hexStr.length), 16)
|
|
33
|
+
|
|
34
|
+
const getAlphaFloat = (a: any, alpha = 1) => {
|
|
35
|
+
if (a !== undefined) {
|
|
36
|
+
return a / 255
|
|
37
|
+
}
|
|
38
|
+
if (typeof alpha != 'number' || alpha < 0 || alpha > 1) {
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
return alpha
|
|
42
|
+
}
|
package/src/index.tsx
ADDED