@tamagui/core 1.0.1-beta.219 → 1.0.1-beta.220
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/createFont.js +11 -4
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createFont.test.js +125 -0
- package/dist/cjs/createFont.test.js.map +7 -0
- package/dist/cjs/helpers/ThemeManager.js +1 -1
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.test.js +62 -0
- package/dist/cjs/helpers/ThemeManager.test.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +0 -2
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +4 -2
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/esm/createFont.js +11 -4
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createFont.test.js +124 -0
- package/dist/esm/createFont.test.js.map +7 -0
- package/dist/esm/helpers/ThemeManager.js +1 -1
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.test.js +61 -0
- package/dist/esm/helpers/ThemeManager.test.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +0 -2
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.native.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +4 -2
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/package.json +13 -13
- package/src/createFont.test.ts +129 -0
- package/src/createFont.ts +12 -5
- package/src/helpers/ThemeManager.tsx +1 -1
- package/src/helpers/getSplitStyles.tsx +0 -1
- package/src/helpers/getStylesAtomic.native.ts +1 -0
- package/src/views/ThemeInverse.tsx +5 -2
- package/types/createFont.test.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.220",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tamagui-build",
|
|
17
17
|
"watch": "tamagui-build --watch",
|
|
18
|
-
"lint": "eslint",
|
|
18
|
+
"lint": "eslint src",
|
|
19
19
|
"clean": "tamagui-build clean",
|
|
20
20
|
"clean:build": "tamagui-build clean:build",
|
|
21
21
|
"test": "vitest --run --config ../vite-plugin-internal/src/vite.config.ts"
|
|
@@ -28,23 +28,23 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@expo/match-media": "^0.3.0",
|
|
31
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/constants": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
34
|
-
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.
|
|
35
|
-
"@tamagui/react-native-use-pressable": "^1.0.1-beta.
|
|
36
|
-
"@tamagui/react-native-use-responder-events": "^1.0.1-beta.
|
|
37
|
-
"@tamagui/types-react-native": "^1.0.1-beta.
|
|
38
|
-
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.
|
|
39
|
-
"@tamagui/use-event": "^1.0.1-beta.
|
|
40
|
-
"@tamagui/use-force-update": "^1.0.1-beta.
|
|
31
|
+
"@tamagui/compose-refs": "^1.0.1-beta.220",
|
|
32
|
+
"@tamagui/constants": "^1.0.1-beta.220",
|
|
33
|
+
"@tamagui/helpers": "^1.0.1-beta.220",
|
|
34
|
+
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.220",
|
|
35
|
+
"@tamagui/react-native-use-pressable": "^1.0.1-beta.220",
|
|
36
|
+
"@tamagui/react-native-use-responder-events": "^1.0.1-beta.220",
|
|
37
|
+
"@tamagui/types-react-native": "^1.0.1-beta.220",
|
|
38
|
+
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.220",
|
|
39
|
+
"@tamagui/use-event": "^1.0.1-beta.220",
|
|
40
|
+
"@tamagui/use-force-update": "^1.0.1-beta.220"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": ">=18",
|
|
44
44
|
"react-dom": ">=18"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
47
|
+
"@tamagui/build": "^1.0.1-beta.220",
|
|
48
48
|
"@types/node": "^16.11.9",
|
|
49
49
|
"@types/react": "^18.0.15",
|
|
50
50
|
"@types/react-native": "^0.69.2",
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { createFont } from './createFont'
|
|
4
|
+
import { GenericFont } from './types'
|
|
5
|
+
|
|
6
|
+
const font: GenericFont = {
|
|
7
|
+
family: 'Inter',
|
|
8
|
+
size: {
|
|
9
|
+
1: 11,
|
|
10
|
+
2: 12,
|
|
11
|
+
3: 14,
|
|
12
|
+
4: 16,
|
|
13
|
+
5: 20,
|
|
14
|
+
6: 24,
|
|
15
|
+
},
|
|
16
|
+
lineHeight: {
|
|
17
|
+
1: 14,
|
|
18
|
+
2: 16,
|
|
19
|
+
3: 18,
|
|
20
|
+
4: 20,
|
|
21
|
+
5: 24,
|
|
22
|
+
6: 28,
|
|
23
|
+
},
|
|
24
|
+
transform: {
|
|
25
|
+
3: 'uppercase',
|
|
26
|
+
4: 'none',
|
|
27
|
+
},
|
|
28
|
+
weight: {
|
|
29
|
+
1: '400',
|
|
30
|
+
3: '700',
|
|
31
|
+
},
|
|
32
|
+
color: {
|
|
33
|
+
1: '$colorFocus',
|
|
34
|
+
6: '$color',
|
|
35
|
+
},
|
|
36
|
+
letterSpacing: {
|
|
37
|
+
5: 2,
|
|
38
|
+
6: 1,
|
|
39
|
+
7: 0,
|
|
40
|
+
8: 0,
|
|
41
|
+
9: -1,
|
|
42
|
+
10: -1.5,
|
|
43
|
+
12: -2,
|
|
44
|
+
14: -3,
|
|
45
|
+
15: -4,
|
|
46
|
+
},
|
|
47
|
+
face: {
|
|
48
|
+
700: { normal: 'InterBold' },
|
|
49
|
+
800: { normal: 'InterBold' },
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const expectedProcessedFont: GenericFont = {
|
|
54
|
+
family: 'Inter',
|
|
55
|
+
size: {
|
|
56
|
+
1: 11,
|
|
57
|
+
2: 12,
|
|
58
|
+
3: 14,
|
|
59
|
+
4: 16,
|
|
60
|
+
5: 20,
|
|
61
|
+
6: 24,
|
|
62
|
+
},
|
|
63
|
+
lineHeight: {
|
|
64
|
+
1: 14,
|
|
65
|
+
2: 16,
|
|
66
|
+
3: 18,
|
|
67
|
+
4: 20,
|
|
68
|
+
5: 24,
|
|
69
|
+
6: 28,
|
|
70
|
+
},
|
|
71
|
+
transform: {
|
|
72
|
+
1: 'uppercase',
|
|
73
|
+
2: 'uppercase',
|
|
74
|
+
3: 'uppercase',
|
|
75
|
+
4: 'none',
|
|
76
|
+
5: 'none',
|
|
77
|
+
6: 'none',
|
|
78
|
+
},
|
|
79
|
+
weight: {
|
|
80
|
+
1: '400',
|
|
81
|
+
2: '400',
|
|
82
|
+
3: '700',
|
|
83
|
+
4: '700',
|
|
84
|
+
5: '700',
|
|
85
|
+
6: '700',
|
|
86
|
+
},
|
|
87
|
+
color: {
|
|
88
|
+
1: '$colorFocus',
|
|
89
|
+
2: '$colorFocus',
|
|
90
|
+
3: '$colorFocus',
|
|
91
|
+
4: '$colorFocus',
|
|
92
|
+
5: '$colorFocus',
|
|
93
|
+
6: '$color',
|
|
94
|
+
},
|
|
95
|
+
letterSpacing: {
|
|
96
|
+
1: 2,
|
|
97
|
+
2: 2,
|
|
98
|
+
3: 2,
|
|
99
|
+
4: 2,
|
|
100
|
+
5: 2,
|
|
101
|
+
6: 1,
|
|
102
|
+
7: 0,
|
|
103
|
+
8: 0,
|
|
104
|
+
9: -1,
|
|
105
|
+
10: -1.5,
|
|
106
|
+
12: -2,
|
|
107
|
+
14: -3,
|
|
108
|
+
15: -4,
|
|
109
|
+
},
|
|
110
|
+
face: {
|
|
111
|
+
100: { normal: 'Inter' },
|
|
112
|
+
200: { normal: 'Inter' },
|
|
113
|
+
300: { normal: 'Inter' },
|
|
114
|
+
400: { normal: 'Inter' },
|
|
115
|
+
500: { normal: 'Inter' },
|
|
116
|
+
600: { normal: 'Inter' },
|
|
117
|
+
700: { normal: 'InterBold' },
|
|
118
|
+
800: { normal: 'InterBold' },
|
|
119
|
+
900: { normal: 'InterBold' },
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
describe('createFont', () => {
|
|
124
|
+
test('should return a font object with normalised property hashes', () => {
|
|
125
|
+
const processedFont = createFont(font)
|
|
126
|
+
|
|
127
|
+
expect(processedFont).toStrictEqual(expectedProcessedFont)
|
|
128
|
+
})
|
|
129
|
+
})
|
package/src/createFont.ts
CHANGED
|
@@ -14,7 +14,8 @@ const fontWeights: FontWeightSteps[] = [
|
|
|
14
14
|
|
|
15
15
|
const processSection = <T>(
|
|
16
16
|
section: string | Record<string, T>,
|
|
17
|
-
keys: string[]
|
|
17
|
+
keys: string[],
|
|
18
|
+
defaultValue?: any
|
|
18
19
|
): string | Record<string, T> => {
|
|
19
20
|
if (typeof section === 'string') return section
|
|
20
21
|
|
|
@@ -23,8 +24,9 @@ const processSection = <T>(
|
|
|
23
24
|
|
|
24
25
|
return Object.fromEntries(
|
|
25
26
|
[...new Set([...keys, ...sectionKeys])].map((key) => {
|
|
26
|
-
const value = section[key] ?? fillValue
|
|
27
|
+
const value = section[key] ?? defaultValue ?? fillValue
|
|
27
28
|
fillValue = value
|
|
29
|
+
defaultValue = value
|
|
28
30
|
return [key, value]
|
|
29
31
|
})
|
|
30
32
|
)
|
|
@@ -35,9 +37,14 @@ export const createFont = <A extends GenericFont>(font: A): A => {
|
|
|
35
37
|
|
|
36
38
|
const processedFont = Object.fromEntries(
|
|
37
39
|
Object.entries(font).map(([key, section]) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
return [
|
|
41
|
+
key,
|
|
42
|
+
processSection(
|
|
43
|
+
section,
|
|
44
|
+
key === 'face' ? fontWeights : sizeKeys,
|
|
45
|
+
key === 'face' ? { normal: font.family } : undefined
|
|
46
|
+
),
|
|
47
|
+
]
|
|
41
48
|
})
|
|
42
49
|
)
|
|
43
50
|
|
|
@@ -224,4 +224,4 @@ export class ThemeManager {
|
|
|
224
224
|
export const ThemeManagerContext = createContext<ThemeManager | null>(null)
|
|
225
225
|
export const emptyManager = new ThemeManager()
|
|
226
226
|
|
|
227
|
-
const withoutComponentName = (name: string) => name.replace(/(
|
|
227
|
+
const withoutComponentName = (name: string) => name.replace(/(_[A-Z][a-zA-Z]+)+$/g, '')
|
|
@@ -554,7 +554,6 @@ export const getSplitStyles: StyleSplitter = (
|
|
|
554
554
|
|
|
555
555
|
if (shouldDoClasses) {
|
|
556
556
|
const pseudoStyles = getAtomicStyle(pseudoStyleObject, descriptor)
|
|
557
|
-
if (debug) console.log('pseudoStyles', pseudoStyles)
|
|
558
557
|
for (const psuedoStyle of pseudoStyles) {
|
|
559
558
|
const fullKey = `${psuedoStyle.property}${PROP_SPLIT}${descriptor.name}`
|
|
560
559
|
if (!usedKeys[fullKey]) {
|
|
@@ -16,15 +16,18 @@ export const useThemeInverse = (props: ThemeInverseProps = {}) => {
|
|
|
16
16
|
const themeName = useThemeName()
|
|
17
17
|
const defaultTheme = useDefaultThemeName()
|
|
18
18
|
const [name, setName] = useState<null | string>(null)
|
|
19
|
+
const curName = themeName || defaultTheme || ''
|
|
19
20
|
|
|
20
21
|
if (isWeb) {
|
|
21
22
|
// for SSR must be in effect
|
|
22
23
|
useIsomorphicLayoutEffect(() => {
|
|
23
|
-
setName(toggleTheme(
|
|
24
|
+
setName(toggleTheme(curName))
|
|
24
25
|
}, [defaultTheme, themeName])
|
|
26
|
+
|
|
27
|
+
return props.disable ? null : name
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
return props.disable ? null :
|
|
30
|
+
return props.disable ? null : toggleTheme(curName)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export const ThemeInverse = ({
|