@react-native-styled-system/core 0.0.5
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/bin/theme-gen.js +149 -0
- package/lib/commonjs/@types/SxProps.js +12 -0
- package/lib/commonjs/@types/SxProps.js.map +1 -0
- package/lib/commonjs/@types/ThemedDict.js +14 -0
- package/lib/commonjs/@types/ThemedDict.js.map +1 -0
- package/lib/commonjs/@types/ThemedTypings.js +6 -0
- package/lib/commonjs/@types/ThemedTypings.js.map +1 -0
- package/lib/commonjs/@types/Token.js +6 -0
- package/lib/commonjs/@types/Token.js.map +1 -0
- package/lib/commonjs/hook/useSx.js +82 -0
- package/lib/commonjs/hook/useSx.js.map +1 -0
- package/lib/commonjs/hook/useSxStyle.js +29 -0
- package/lib/commonjs/hook/useSxStyle.js.map +1 -0
- package/lib/commonjs/hook/useSxTokens.js +33 -0
- package/lib/commonjs/hook/useSxTokens.js.map +1 -0
- package/lib/commonjs/index.js +72 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/TokenParser/ColorsParser.js +21 -0
- package/lib/commonjs/internal/TokenParser/ColorsParser.js.map +1 -0
- package/lib/commonjs/internal/TokenParser/RadiiParser.js +41 -0
- package/lib/commonjs/internal/TokenParser/RadiiParser.js.map +1 -0
- package/lib/commonjs/internal/TokenParser/SizesParser.js +41 -0
- package/lib/commonjs/internal/TokenParser/SizesParser.js.map +1 -0
- package/lib/commonjs/internal/TokenParser/SpaceParser.js +90 -0
- package/lib/commonjs/internal/TokenParser/SpaceParser.js.map +1 -0
- package/lib/commonjs/internal/TokenParser/TokenParser.js +23 -0
- package/lib/commonjs/internal/TokenParser/TokenParser.js.map +1 -0
- package/lib/commonjs/internal/TokenParser/TypographyParser.js +23 -0
- package/lib/commonjs/internal/TokenParser/TypographyParser.js.map +1 -0
- package/lib/commonjs/internal/useStableCallback.js +34 -0
- package/lib/commonjs/internal/useStableCallback.js.map +1 -0
- package/lib/commonjs/internal/util/fillNullishThemeKey.js +18 -0
- package/lib/commonjs/internal/util/fillNullishThemeKey.js.map +1 -0
- package/lib/commonjs/internal/util/fillStyleIfNotNullish.js +21 -0
- package/lib/commonjs/internal/util/fillStyleIfNotNullish.js.map +1 -0
- package/lib/commonjs/internal/util/parsePxSuffixNumber.js +16 -0
- package/lib/commonjs/internal/util/parsePxSuffixNumber.js.map +1 -0
- package/lib/commonjs/internal/util/printWarning.js +18 -0
- package/lib/commonjs/internal/util/printWarning.js.map +1 -0
- package/lib/commonjs/provider/StyledSystemProvider.js +25 -0
- package/lib/commonjs/provider/StyledSystemProvider.js.map +1 -0
- package/lib/commonjs/util/propsToThemedStyle.js +138 -0
- package/lib/commonjs/util/propsToThemedStyle.js.map +1 -0
- package/lib/module/@types/SxProps.js +6 -0
- package/lib/module/@types/SxProps.js.map +1 -0
- package/lib/module/@types/ThemedDict.js +8 -0
- package/lib/module/@types/ThemedDict.js.map +1 -0
- package/lib/module/@types/ThemedTypings.js +2 -0
- package/lib/module/@types/ThemedTypings.js.map +1 -0
- package/lib/module/@types/Token.js +2 -0
- package/lib/module/@types/Token.js.map +1 -0
- package/lib/module/hook/useSx.js +75 -0
- package/lib/module/hook/useSx.js.map +1 -0
- package/lib/module/hook/useSxStyle.js +22 -0
- package/lib/module/hook/useSxStyle.js.map +1 -0
- package/lib/module/hook/useSxTokens.js +26 -0
- package/lib/module/hook/useSxTokens.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/TokenParser/ColorsParser.js +14 -0
- package/lib/module/internal/TokenParser/ColorsParser.js.map +1 -0
- package/lib/module/internal/TokenParser/RadiiParser.js +34 -0
- package/lib/module/internal/TokenParser/RadiiParser.js.map +1 -0
- package/lib/module/internal/TokenParser/SizesParser.js +34 -0
- package/lib/module/internal/TokenParser/SizesParser.js.map +1 -0
- package/lib/module/internal/TokenParser/SpaceParser.js +82 -0
- package/lib/module/internal/TokenParser/SpaceParser.js.map +1 -0
- package/lib/module/internal/TokenParser/TokenParser.js +16 -0
- package/lib/module/internal/TokenParser/TokenParser.js.map +1 -0
- package/lib/module/internal/TokenParser/TypographyParser.js +15 -0
- package/lib/module/internal/TokenParser/TypographyParser.js.map +1 -0
- package/lib/module/internal/useStableCallback.js +27 -0
- package/lib/module/internal/useStableCallback.js.map +1 -0
- package/lib/module/internal/util/fillNullishThemeKey.js +11 -0
- package/lib/module/internal/util/fillNullishThemeKey.js.map +1 -0
- package/lib/module/internal/util/fillStyleIfNotNullish.js +14 -0
- package/lib/module/internal/util/fillStyleIfNotNullish.js.map +1 -0
- package/lib/module/internal/util/parsePxSuffixNumber.js +10 -0
- package/lib/module/internal/util/parsePxSuffixNumber.js.map +1 -0
- package/lib/module/internal/util/printWarning.js +11 -0
- package/lib/module/internal/util/printWarning.js.map +1 -0
- package/lib/module/provider/StyledSystemProvider.js +17 -0
- package/lib/module/provider/StyledSystemProvider.js.map +1 -0
- package/lib/module/util/propsToThemedStyle.js +131 -0
- package/lib/module/util/propsToThemedStyle.js.map +1 -0
- package/lib/typescript/@types/SxProps.d.ts +140 -0
- package/lib/typescript/@types/SxProps.d.ts.map +1 -0
- package/lib/typescript/@types/ThemedDict.d.ts +16 -0
- package/lib/typescript/@types/ThemedDict.d.ts.map +1 -0
- package/lib/typescript/@types/ThemedTypings.d.ts +9 -0
- package/lib/typescript/@types/ThemedTypings.d.ts.map +1 -0
- package/lib/typescript/@types/Token.d.ts +17 -0
- package/lib/typescript/@types/Token.d.ts.map +1 -0
- package/lib/typescript/hook/useSx.d.ts +307 -0
- package/lib/typescript/hook/useSx.d.ts.map +1 -0
- package/lib/typescript/hook/useSxStyle.d.ts +8 -0
- package/lib/typescript/hook/useSxStyle.d.ts.map +1 -0
- package/lib/typescript/hook/useSxTokens.d.ts +7 -0
- package/lib/typescript/hook/useSxTokens.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/internal/TokenParser/ColorsParser.d.ts +4 -0
- package/lib/typescript/internal/TokenParser/ColorsParser.d.ts.map +1 -0
- package/lib/typescript/internal/TokenParser/RadiiParser.d.ts +4 -0
- package/lib/typescript/internal/TokenParser/RadiiParser.d.ts.map +1 -0
- package/lib/typescript/internal/TokenParser/SizesParser.d.ts +4 -0
- package/lib/typescript/internal/TokenParser/SizesParser.d.ts.map +1 -0
- package/lib/typescript/internal/TokenParser/SpaceParser.d.ts +5 -0
- package/lib/typescript/internal/TokenParser/SpaceParser.d.ts.map +1 -0
- package/lib/typescript/internal/TokenParser/TokenParser.d.ts +10 -0
- package/lib/typescript/internal/TokenParser/TokenParser.d.ts.map +1 -0
- package/lib/typescript/internal/TokenParser/TypographyParser.d.ts +4 -0
- package/lib/typescript/internal/TokenParser/TypographyParser.d.ts.map +1 -0
- package/lib/typescript/internal/useStableCallback.d.ts +2 -0
- package/lib/typescript/internal/useStableCallback.d.ts.map +1 -0
- package/lib/typescript/internal/util/fillNullishThemeKey.d.ts +3 -0
- package/lib/typescript/internal/util/fillNullishThemeKey.d.ts.map +1 -0
- package/lib/typescript/internal/util/fillStyleIfNotNullish.d.ts +4 -0
- package/lib/typescript/internal/util/fillStyleIfNotNullish.d.ts.map +1 -0
- package/lib/typescript/internal/util/parsePxSuffixNumber.d.ts +2 -0
- package/lib/typescript/internal/util/parsePxSuffixNumber.d.ts.map +1 -0
- package/lib/typescript/internal/util/printWarning.d.ts +2 -0
- package/lib/typescript/internal/util/printWarning.d.ts.map +1 -0
- package/lib/typescript/provider/StyledSystemProvider.d.ts +13 -0
- package/lib/typescript/provider/StyledSystemProvider.d.ts.map +1 -0
- package/lib/typescript/util/propsToThemedStyle.d.ts +10 -0
- package/lib/typescript/util/propsToThemedStyle.d.ts.map +1 -0
- package/package.json +78 -0
- package/src/@types/SxProps.ts +255 -0
- package/src/@types/ThemedDict.ts +16 -0
- package/src/@types/ThemedTypings.ts +9 -0
- package/src/@types/Token.ts +21 -0
- package/src/hook/useSx.test.ts +348 -0
- package/src/hook/useSx.ts +94 -0
- package/src/hook/useSxStyle.test.ts +57 -0
- package/src/hook/useSxStyle.ts +32 -0
- package/src/hook/useSxTokens.test.ts +59 -0
- package/src/hook/useSxTokens.ts +42 -0
- package/src/index.ts +6 -0
- package/src/internal/TokenParser/ColorsParser.ts +18 -0
- package/src/internal/TokenParser/RadiiParser.ts +44 -0
- package/src/internal/TokenParser/SizesParser.ts +44 -0
- package/src/internal/TokenParser/SpaceParser.ts +95 -0
- package/src/internal/TokenParser/TokenParser.ts +18 -0
- package/src/internal/TokenParser/TypographyParser.ts +24 -0
- package/src/internal/useStableCallback.ts +29 -0
- package/src/internal/util/fillNullishThemeKey.ts +12 -0
- package/src/internal/util/fillStyleIfNotNullish.ts +26 -0
- package/src/internal/util/parsePxSuffixNumber.ts +10 -0
- package/src/internal/util/printWarning.ts +11 -0
- package/src/provider/StyledSystemProvider.tsx +23 -0
- package/src/util/propsToThemedStyle.ts +168 -0
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-styled-system/core",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "React Native Styled System",
|
|
5
|
+
"main": "lib/commonjs/index.js",
|
|
6
|
+
"types": "lib/typescript/index.d.ts",
|
|
7
|
+
"homepage": "https://github.com/mj-studio-library/react-native-styled-system",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "bob build",
|
|
10
|
+
"gen": "node bin/theme-gen.js bin/theme.ts bin/ret.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/mj-studio-library/react-native-styled-system"
|
|
15
|
+
},
|
|
16
|
+
"author": "zmin9 <lucy@teamturing.com>",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
20
|
+
"@types/react": "^18.2.65",
|
|
21
|
+
"@types/react-test-renderer": "^18",
|
|
22
|
+
"prettier": "^3.2.5",
|
|
23
|
+
"react": "*",
|
|
24
|
+
"react-native": "^0.73.6",
|
|
25
|
+
"react-native-builder-bob": "^0.23.2",
|
|
26
|
+
"react-test-renderer": "^18.2.0",
|
|
27
|
+
"typescript": "*"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "*",
|
|
31
|
+
"react-native": "*"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"src",
|
|
35
|
+
"lib",
|
|
36
|
+
"!**/__tests__",
|
|
37
|
+
"!**/__fixtures__",
|
|
38
|
+
"!**/__mocks__",
|
|
39
|
+
"!lib/typescript/example"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@mj-studio/js-util": "1.0.31",
|
|
43
|
+
"invariant": "^2.2.4"
|
|
44
|
+
},
|
|
45
|
+
"bin": "./bin/theme-gen.js",
|
|
46
|
+
"react-native": "src/index.ts",
|
|
47
|
+
"source": "src/index.ts",
|
|
48
|
+
"module": "lib/module/index.js",
|
|
49
|
+
"react-native-builder-bob": {
|
|
50
|
+
"declarationMap": false,
|
|
51
|
+
"source": "src",
|
|
52
|
+
"typescript": "",
|
|
53
|
+
"output": "lib",
|
|
54
|
+
"targets": [
|
|
55
|
+
"commonjs",
|
|
56
|
+
"module",
|
|
57
|
+
[
|
|
58
|
+
"typescript",
|
|
59
|
+
{
|
|
60
|
+
"project": "tsconfig.build.json"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
],
|
|
64
|
+
"exclude": [
|
|
65
|
+
"**/{__tests__,__fixtures__,__mocks__}/**",
|
|
66
|
+
"**/*.test.*"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"config": {
|
|
70
|
+
"commitizen": {
|
|
71
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"workspaces": [
|
|
75
|
+
"packages/*"
|
|
76
|
+
],
|
|
77
|
+
"gitHead": "7c09f0fe9584d8280bdfd1f39f89525133e9a65e"
|
|
78
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import type { TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { Token } from './Token';
|
|
4
|
+
|
|
5
|
+
export type SxPropsKeys = keyof SxProps;
|
|
6
|
+
export type TextSxPropsKey = keyof TextSxProps;
|
|
7
|
+
/**
|
|
8
|
+
* Always modify if you change API
|
|
9
|
+
*/
|
|
10
|
+
export const _viewStylePropList = [
|
|
11
|
+
'style',
|
|
12
|
+
'sx',
|
|
13
|
+
'backgroundColor',
|
|
14
|
+
'bg',
|
|
15
|
+
'borderColor',
|
|
16
|
+
'margin',
|
|
17
|
+
'm',
|
|
18
|
+
'marginTop',
|
|
19
|
+
'mt',
|
|
20
|
+
'marginRight',
|
|
21
|
+
'mr',
|
|
22
|
+
'marginBottom',
|
|
23
|
+
'mb',
|
|
24
|
+
'marginLeft',
|
|
25
|
+
'ml',
|
|
26
|
+
'marginX',
|
|
27
|
+
'mx',
|
|
28
|
+
'marginY',
|
|
29
|
+
'my',
|
|
30
|
+
'padding',
|
|
31
|
+
'p',
|
|
32
|
+
'paddingTop',
|
|
33
|
+
'pt',
|
|
34
|
+
'paddingRight',
|
|
35
|
+
'pr',
|
|
36
|
+
'paddingBottom',
|
|
37
|
+
'pb',
|
|
38
|
+
'paddingLeft',
|
|
39
|
+
'pl',
|
|
40
|
+
'paddingX',
|
|
41
|
+
'px',
|
|
42
|
+
'paddingY',
|
|
43
|
+
'py',
|
|
44
|
+
'top',
|
|
45
|
+
'right',
|
|
46
|
+
'bottom',
|
|
47
|
+
'left',
|
|
48
|
+
'gap',
|
|
49
|
+
'gapX',
|
|
50
|
+
'gapY',
|
|
51
|
+
'width',
|
|
52
|
+
'w',
|
|
53
|
+
'minW',
|
|
54
|
+
'minWidth',
|
|
55
|
+
'maxW',
|
|
56
|
+
'maxWidth',
|
|
57
|
+
'height',
|
|
58
|
+
'h',
|
|
59
|
+
'minH',
|
|
60
|
+
'minHeight',
|
|
61
|
+
'maxH',
|
|
62
|
+
'maxHeight',
|
|
63
|
+
'flex',
|
|
64
|
+
'alignItems',
|
|
65
|
+
'alignContent',
|
|
66
|
+
'justifyContent',
|
|
67
|
+
'flexWrap',
|
|
68
|
+
'flexDirection',
|
|
69
|
+
'flexGrow',
|
|
70
|
+
'flexShrink',
|
|
71
|
+
'flexBasis',
|
|
72
|
+
'alignSelf',
|
|
73
|
+
'position',
|
|
74
|
+
'pos',
|
|
75
|
+
'borderWidth',
|
|
76
|
+
'borderTopWidth',
|
|
77
|
+
'borderRightWidth',
|
|
78
|
+
'borderBottomWidth',
|
|
79
|
+
'borderLeftWidth',
|
|
80
|
+
'borderRadius',
|
|
81
|
+
'radius',
|
|
82
|
+
'opacity',
|
|
83
|
+
'overflow',
|
|
84
|
+
'transform',
|
|
85
|
+
'aspectRatio',
|
|
86
|
+
'display',
|
|
87
|
+
'elevation',
|
|
88
|
+
'zIndex',
|
|
89
|
+
'borderTopLeftRadius',
|
|
90
|
+
'borderTopRightRadius',
|
|
91
|
+
'borderBottomLeftRadius',
|
|
92
|
+
'borderBottomRightRadius',
|
|
93
|
+
] satisfies (SxPropsKeys | 'style')[];
|
|
94
|
+
export const _textStylePropList = [
|
|
95
|
+
'color',
|
|
96
|
+
'textDecorationColor',
|
|
97
|
+
'textShadowColor',
|
|
98
|
+
'fontFamily',
|
|
99
|
+
'fontSize',
|
|
100
|
+
'fontStyle',
|
|
101
|
+
'fontWeight',
|
|
102
|
+
'weight',
|
|
103
|
+
'letterSpacing',
|
|
104
|
+
'lineHeight',
|
|
105
|
+
'textAlign',
|
|
106
|
+
'align',
|
|
107
|
+
'textDecorationLine',
|
|
108
|
+
'textDecorationStyle',
|
|
109
|
+
'textShadowOffset',
|
|
110
|
+
'textShadowRadius',
|
|
111
|
+
'textTransform',
|
|
112
|
+
'userSelect',
|
|
113
|
+
'includeFontPadding',
|
|
114
|
+
'typography',
|
|
115
|
+
't',
|
|
116
|
+
] satisfies (Omit<TextSxPropsKey, keyof TextSxPropsKey> | 'style')[];
|
|
117
|
+
type ThemedColorTokenProps = {
|
|
118
|
+
backgroundColor: Token<'colors'>;
|
|
119
|
+
bg: Token<'colors'>; // backgroundColor
|
|
120
|
+
borderColor: Token<'colors'>;
|
|
121
|
+
};
|
|
122
|
+
type ThemedColorTokenTextProps = {
|
|
123
|
+
color: Token<'colors'>;
|
|
124
|
+
textDecorationColor: Token<'colors'>;
|
|
125
|
+
textShadowColor: Token<'colors'>;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
type ThemedSpaceTokenProps = {
|
|
129
|
+
margin: Token<'space'>;
|
|
130
|
+
m: Token<'space'>; // margin
|
|
131
|
+
marginTop: Token<'space'>;
|
|
132
|
+
mt: Token<'space'>; // marginTop
|
|
133
|
+
marginRight: Token<'space'>;
|
|
134
|
+
mr: Token<'space'>; // marginRight
|
|
135
|
+
marginBottom: Token<'space'>;
|
|
136
|
+
mb: Token<'space'>; // marginBottom
|
|
137
|
+
marginLeft: Token<'space'>;
|
|
138
|
+
ml: Token<'space'>; // marginLeft
|
|
139
|
+
marginX: Token<'space'>;
|
|
140
|
+
mx: Token<'space'>; // marginX
|
|
141
|
+
marginY: Token<'space'>;
|
|
142
|
+
my: Token<'space'>; // marginY
|
|
143
|
+
padding: Token<'space'>;
|
|
144
|
+
p: Token<'space'>; // padding
|
|
145
|
+
paddingTop: Token<'space'>;
|
|
146
|
+
pt: Token<'space'>; // paddingTop
|
|
147
|
+
paddingRight: Token<'space'>;
|
|
148
|
+
pr: Token<'space'>; // paddingRight
|
|
149
|
+
paddingBottom: Token<'space'>;
|
|
150
|
+
pb: Token<'space'>; // paddingBottom
|
|
151
|
+
paddingLeft: Token<'space'>;
|
|
152
|
+
pl: Token<'space'>; // paddingLeft
|
|
153
|
+
paddingX: Token<'space'>;
|
|
154
|
+
px: Token<'space'>; // paddingX
|
|
155
|
+
paddingY: Token<'space'>;
|
|
156
|
+
py: Token<'space'>; // paddingY
|
|
157
|
+
top: Token<'space'>;
|
|
158
|
+
right: Token<'space'>;
|
|
159
|
+
bottom: Token<'space'>;
|
|
160
|
+
left: Token<'space'>;
|
|
161
|
+
gap: Token<'space'>; // only works if parsed result is number
|
|
162
|
+
gapX: Token<'space'>; // only works if parsed result is number
|
|
163
|
+
gapY: Token<'space'>; // only works if parsed result is number
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
type ThemedSizeTokenProps = {
|
|
167
|
+
width: Token<'sizes'>;
|
|
168
|
+
w: Token<'sizes'>; // width
|
|
169
|
+
minWidth: Token<'sizes'>;
|
|
170
|
+
minW: Token<'sizes'>; // minWidth
|
|
171
|
+
maxWidth: Token<'sizes'>;
|
|
172
|
+
maxW: Token<'sizes'>; // maxWidth
|
|
173
|
+
height: Token<'sizes'>;
|
|
174
|
+
h: Token<'sizes'>; // height
|
|
175
|
+
minHeight: Token<'sizes'>;
|
|
176
|
+
minH: Token<'sizes'>; // minHeight
|
|
177
|
+
maxHeight: Token<'sizes'>;
|
|
178
|
+
maxH: Token<'sizes'>; // maxHeight
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
type ThemedRadiiTokenProps = {
|
|
182
|
+
borderRadius: Token<'radii'>;
|
|
183
|
+
radius: Token<'radii'>; // borderRadius
|
|
184
|
+
borderTopLeftRadius: Token<'radii'>;
|
|
185
|
+
topLeftRadius: Token<'radii'>; // borderTopLeftRadius
|
|
186
|
+
borderTopRightRadius: Token<'radii'>;
|
|
187
|
+
topRightRadius: Token<'radii'>; // borderTopRightRadius
|
|
188
|
+
borderBottomLeftRadius: Token<'radii'>;
|
|
189
|
+
bottomLeftRadius: Token<'radii'>; // borderBottomLeftRadius
|
|
190
|
+
borderBottomRightRadius: Token<'radii'>;
|
|
191
|
+
bottomRightRadius: Token<'radii'>; // borderBottomRightRadius
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
type ThemedViewStyleProps = {
|
|
195
|
+
flex: ViewStyle['flex'];
|
|
196
|
+
alignItems: ViewStyle['alignItems'];
|
|
197
|
+
alignContent: ViewStyle['alignContent'];
|
|
198
|
+
justifyContent: ViewStyle['justifyContent'];
|
|
199
|
+
flexWrap: ViewStyle['flexWrap'];
|
|
200
|
+
flexDirection: ViewStyle['flexDirection'];
|
|
201
|
+
flexGrow: ViewStyle['flexGrow'];
|
|
202
|
+
flexShrink: ViewStyle['flexShrink'];
|
|
203
|
+
flexBasis: ViewStyle['flexBasis'];
|
|
204
|
+
alignSelf: ViewStyle['alignSelf'];
|
|
205
|
+
position: ViewStyle['position'];
|
|
206
|
+
pos: ViewStyle['position']; // position
|
|
207
|
+
borderWidth: ViewStyle['borderWidth'];
|
|
208
|
+
borderTopWidth: ViewStyle['borderTopWidth'];
|
|
209
|
+
borderRightWidth: ViewStyle['borderRightWidth'];
|
|
210
|
+
borderBottomWidth: ViewStyle['borderBottomWidth'];
|
|
211
|
+
borderLeftWidth: ViewStyle['borderLeftWidth'];
|
|
212
|
+
opacity: ViewStyle['opacity'];
|
|
213
|
+
overflow: ViewStyle['overflow'];
|
|
214
|
+
transform: ViewStyle['transform'];
|
|
215
|
+
aspectRatio: ViewStyle['aspectRatio'];
|
|
216
|
+
display: ViewStyle['display'];
|
|
217
|
+
elevation: ViewStyle['elevation'];
|
|
218
|
+
zIndex: ViewStyle['zIndex'];
|
|
219
|
+
absoluteFill?: boolean; // shortcut - position: absoulte, t,r,b,l: 0
|
|
220
|
+
center?: boolean; // shortcut - justifyContent, alignItems: center
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
type ThemedTextStyleProps = {
|
|
224
|
+
fontFamily: TextStyle['fontFamily'];
|
|
225
|
+
fontSize: TextStyle['fontSize'];
|
|
226
|
+
fontStyle: TextStyle['fontStyle'];
|
|
227
|
+
fontWeight: TextStyle['fontWeight'];
|
|
228
|
+
weight: TextStyle['fontWeight']; // fontWeight
|
|
229
|
+
letterSpacing: TextStyle['letterSpacing'];
|
|
230
|
+
lineHeight: TextStyle['lineHeight'];
|
|
231
|
+
textAlign: TextStyle['textAlign'];
|
|
232
|
+
align: TextStyle['textAlign']; // textAlign
|
|
233
|
+
textDecorationLine: TextStyle['textDecorationLine'];
|
|
234
|
+
textDecorationStyle: TextStyle['textDecorationStyle'];
|
|
235
|
+
textShadowOffset: TextStyle['textShadowOffset'];
|
|
236
|
+
textShadowRadius: TextStyle['textShadowRadius'];
|
|
237
|
+
textTransform: TextStyle['textTransform'];
|
|
238
|
+
userSelect: TextStyle['userSelect'];
|
|
239
|
+
includeFontPadding: TextStyle['includeFontPadding'];
|
|
240
|
+
typography: Token<'typography'>;
|
|
241
|
+
t: Token<'typography'>; // typography
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
type BaseSxProps = Partial<
|
|
245
|
+
ThemedViewStyleProps &
|
|
246
|
+
ThemedSpaceTokenProps &
|
|
247
|
+
ThemedSizeTokenProps &
|
|
248
|
+
ThemedColorTokenProps &
|
|
249
|
+
ThemedRadiiTokenProps
|
|
250
|
+
>;
|
|
251
|
+
|
|
252
|
+
type BaseTextSxProps = BaseSxProps & Partial<ThemedColorTokenTextProps & ThemedTextStyleProps>;
|
|
253
|
+
|
|
254
|
+
export type SxProps = BaseSxProps & { sx?: BaseSxProps };
|
|
255
|
+
export type TextSxProps = BaseTextSxProps & { sx?: BaseTextSxProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ColorsValue, RadiiValue, SizesValue, SpaceValue, TypographyValue } from './Token';
|
|
2
|
+
|
|
3
|
+
export interface ThemedDict {
|
|
4
|
+
space: Record<string | number, SpaceValue>;
|
|
5
|
+
sizes: Record<string | number, SizesValue>;
|
|
6
|
+
colors: Record<string | number, ColorsValue>;
|
|
7
|
+
radii: Record<string | number, RadiiValue>;
|
|
8
|
+
typography: Record<string | number, TypographyValue>;
|
|
9
|
+
}
|
|
10
|
+
export const emptyThemedDict = {
|
|
11
|
+
space: {},
|
|
12
|
+
colors: {},
|
|
13
|
+
sizes: {},
|
|
14
|
+
radii: {},
|
|
15
|
+
typography: {},
|
|
16
|
+
} satisfies ThemedDict;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ColorsValue, RadiiValue, SizesValue, SpaceValue } from './Token';
|
|
2
|
+
|
|
3
|
+
export interface ThemedTypings {
|
|
4
|
+
space: SpaceValue | `${number}` | `${number}px` | `${any}px`;
|
|
5
|
+
sizes: SizesValue | `${number}` | `${number}px` | `${any}px`;
|
|
6
|
+
colors: ColorsValue;
|
|
7
|
+
radii: RadiiValue | `${number}` | `${number}px` | `${any}px`;
|
|
8
|
+
typography: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TextStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { ThemedTypings } from './ThemedTypings';
|
|
4
|
+
|
|
5
|
+
export type Token<ThemeKey extends keyof ThemedTypings> = ThemeKey extends keyof ThemedTypings
|
|
6
|
+
? ThemedTypings[ThemeKey]
|
|
7
|
+
: never;
|
|
8
|
+
|
|
9
|
+
export type SpaceValue = number | 'auto' | `${number}%` | null;
|
|
10
|
+
export type SizesValue = number | 'auto' | `${number}%` | null;
|
|
11
|
+
export type ColorsValue = string;
|
|
12
|
+
export type RadiiValue = number;
|
|
13
|
+
export type TypographyValue = {
|
|
14
|
+
fontFamily?: TextStyle['fontFamily'];
|
|
15
|
+
fontSize?: TextStyle['fontSize'];
|
|
16
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
17
|
+
lineHeight?: TextStyle['lineHeight'];
|
|
18
|
+
letterSpacing?: TextStyle['letterSpacing'];
|
|
19
|
+
textAlign?: TextStyle['textAlign'];
|
|
20
|
+
fontStyle?: TextStyle['fontStyle'];
|
|
21
|
+
};
|