Skip to content

Commit dd9a2ea

Browse files
author
kj
committed
Separates all custom properties into their own :root sections so they can be used standalone.
1 parent bc3a4e8 commit dd9a2ea

5 files changed

+19
-9
lines changed

properties.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ export default function properties(state={}) {
55
if (Object.keys(properties)) {
66
output = /*css*/`
77
/*** Custom Properties ***/
8+
:root {
89
`
910
output += Object.keys(properties).map(key => `--${key}:${properties[key]};/* ${key} */`).join('\n')
1011

1112
output += `
13+
}
1214
`
1315
}
1416

space-scale-properties.mjs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { generateSpaceScaleProperties } from './lib/scales.mjs'
33
export default function spaceScaleProperties({ config }) {
44
const { spaceScale } = config
55
let output = ''
6-
6+
77
if (spaceScale) {
88
output = /*css*/`
99
/*** Space Scale ***/
10+
:root {
1011
`
1112
output += generateSpaceScaleProperties(spaceScale)
13+
output += `
14+
}
15+
`
1216
}
1317

1418
return output

theme-color.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export default function themeColor({ config }) {
2121
--${name}-900: hsl(${hue}, ${saturation}%, ${Math.floor(luminance - 40)}%);
2222
`
2323
}
24+
2425
return /*css*/`
2526
/*** Theme Colors ***/
27+
:root {
2628
${Object.keys(theme).map(name => {
2729
if (name === 'light' || name === 'dark') {
2830
return ` --${name}: ${theme[name]};`
@@ -33,6 +35,7 @@ else {
3335
}
3436
}).join('\n')}
3537
${Object.keys(color).map(name => ` --${name}: ${color[name]};`).join('\n')}
38+
}
3639
`
3740

3841
}

theme.mjs

+4-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ import spaceScaleProperties from './space-scale-properties.mjs'
1313

1414
export default function theme(config) {
1515
return /*css*/`
16-
/*** Theme ***/
17-
:root {
18-
${themeColor({config})}
19-
${properties({config})}
20-
${typeScaleProperties({config})}
21-
${spaceScaleProperties({config})}
22-
}
16+
${themeColor({config})}
17+
${properties({config})}
18+
${typeScaleProperties({config})}
19+
${spaceScaleProperties({config})}
2320
${reset()}
2421
${typeface({config})}
2522
${smoothing({config})}

type-scale-properties.mjs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { generateTypeScaleProperties } from './lib/scales.mjs'
33
export default function typeScaleProperties({ config }) {
44
const { typeScale } = config
55
let output = ''
6-
6+
77
if (typeScale) {
88
output = /*css*/`
99
/*** Type Scale ***/
10+
:root {
1011
`
1112
output += generateTypeScaleProperties(typeScale)
13+
output += `
14+
}
15+
`
1216
}
1317

1418
return output

0 commit comments

Comments
 (0)