Skip to content

Commit

Permalink
Merge pull request #2082 from system-ui/lachlanjc-tw3
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus authored Jan 30, 2022
2 parents 8894506 + 3ded464 commit f30b1cf
Show file tree
Hide file tree
Showing 7 changed files with 930 additions and 30,878 deletions.
4 changes: 2 additions & 2 deletions packages/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"license": "MIT",
"scripts": {},
"devDependencies": {
"@theme-ui/css": "0.13.0",
"@theme-ui/css": "0.13.1",
"babel-polyfill": "^6.26.0",
"execa": "^5.0.0",
"tailwindcss": "^1.0.4"
"tailwindcss": "^3.0.15"
},
"publishConfig": {
"access": "public"
Expand Down
12 changes: 8 additions & 4 deletions packages/tailwind/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const KEY_MAPPING: {
space: 'spacing',
radii: 'borderRadius',
fonts: 'fontFamily',
breakpoints: 'screens',
borderStyles: 'borderStyle',
shadows: 'boxShadow',
fontSizes: 'fontSize',
Expand All @@ -21,21 +22,24 @@ export default (theme: Theme, config: { [Key: string]: unknown } = {}) => {
[Key: string]: unknown
}>((acc, [key, value]) => {
const matchingKey = KEY_MAPPING[key]
const valueAsObj = Array.isArray(value)
? Object.fromEntries(Object.entries(value))
: value
if (!matchingKey) {
return {
...acc,
[key]: value,
[key]: valueAsObj,
}
} else if (Array.isArray(matchingKey)) {
matchingKey.forEach(twKey => {
acc[twKey] = value
matchingKey.forEach((twKey) => {
acc[twKey] = valueAsObj
})

return acc
} else {
return {
...acc,
[matchingKey]: value,
[matchingKey]: valueAsObj,
}
}
}, {})
Expand Down
Loading

0 comments on commit f30b1cf

Please sign in to comment.