File tree Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 4
4
"version" : " 0.3.0" ,
5
5
"main" : " dist/index.js" ,
6
6
"module" : " dist/index.esm.js" ,
7
+ "source" : " src/index.ts" ,
8
+ "types" : " dist/index.d.ts" ,
7
9
"author" :
" John Otander <[email protected] >" ,
8
10
"license" : " MIT" ,
9
11
"scripts" : {
10
- "prepare" : " microbundle --no-compress" ,
11
- "watch" : " microbundle watch --no-compress"
12
+ "prepare" : " microbundle --no-compress --tsconfig tsconfig.json " ,
13
+ "watch" : " microbundle watch --no-compress --tsconfig tsconfig.json "
12
14
},
13
15
"devDependencies" : {
14
16
"babel-polyfill" : " ^6.26.0" ,
27
29
" style"
28
30
],
29
31
"repository" : " system-ui/theme-ui" ,
30
- "gitHead" : " 5681b24d36f81fddd0d1d82cbb85136cc15dcd4c"
32
+ "gitHead" : " 5681b24d36f81fddd0d1d82cbb85136cc15dcd4c" ,
33
+ "dependencies" : {
34
+ "@theme-ui/core" : " ^0.3.1"
35
+ }
31
36
}
Original file line number Diff line number Diff line change 1
- const KEY_MAPPING = {
1
+ import { Theme } from '@theme-ui/core'
2
+
3
+ const KEY_MAPPING : {
4
+ readonly [ Key : string ] : string | string [ ]
5
+ } = {
2
6
space : 'spacing' ,
3
7
radii : 'borderRadius' ,
4
8
fonts : 'fontFamily' ,
@@ -12,23 +16,26 @@ const KEY_MAPPING = {
12
16
zIndices : 'zIndex' ,
13
17
}
14
18
15
- export default ( theme , config = { } ) => {
16
- const transformedTheme = Object . entries ( theme ) . reduce ( ( acc , [ key , value ] ) => {
17
- if ( ! KEY_MAPPING [ key ] ) {
19
+ export default ( theme : Theme , config : { [ Key : string ] : unknown } = { } ) => {
20
+ const transformedTheme = Object . entries ( theme ) . reduce < {
21
+ [ Key : string ] : unknown
22
+ } > ( ( acc , [ key , value ] ) => {
23
+ const matchingKey = KEY_MAPPING [ key ]
24
+ if ( ! matchingKey ) {
18
25
return {
19
26
...acc ,
20
27
[ key ] : value ,
21
28
}
22
- } else if ( Array . isArray ( KEY_MAPPING [ key ] ) ) {
23
- KEY_MAPPING [ key ] . forEach ( twKey => {
29
+ } else if ( Array . isArray ( matchingKey ) ) {
30
+ matchingKey . forEach ( twKey => {
24
31
acc [ twKey ] = value
25
32
} )
26
33
27
34
return acc
28
35
} else {
29
36
return {
30
37
...acc ,
31
- [ KEY_MAPPING [ key ] ] : value ,
38
+ [ matchingKey ] : value ,
32
39
}
33
40
}
34
41
} , { } )
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "resolveJsonModule" : true ,
4
+ "esModuleInterop" : true ,
5
+ "moduleResolution" : " node" ,
6
+ "strict" : true
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments