Skip to content

Commit 1d44ef6

Browse files
authored
Merge pull request #67 from p-chan/feature/fix-leaf-object-key-is-not-converted-to-kebab-case
Fix leaf object key is not converted to kebab case
2 parents 0a0b477 + 148b717 commit 1d44ef6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/index.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ describe('Custom Properties', () => {
4444
toCustomPropertiesArray({
4545
strongBlack: { 100: '#999999', 900: '#000000' },
4646
strongWhite: { 100: '#ffffff', 900: '#aaaaaa' },
47+
black: { primary: '#000000', secondaryLight: '#111111' },
48+
white: { primary: '#ffffff', secondaryDark: '#eeeeee' },
4749
})
4850
).toEqual([
4951
{ key: '--strong-black-100', value: '#999999' },
5052
{ key: '--strong-black-900', value: '#000000' },
5153
{ key: '--strong-white-100', value: '#ffffff' },
5254
{ key: '--strong-white-900', value: '#aaaaaa' },
55+
{ key: '--black-primary', value: '#000000' },
56+
{ key: '--black-secondary-light', value: '#111111' },
57+
{ key: '--white-primary', value: '#ffffff' },
58+
{ key: '--white-secondary-dark', value: '#eeeeee' },
5359
])
5460
})
5561

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ const toCSSVariables = (object: CSSObject, options?: Options) => {
3737
addCSSVariable(value, [...parentKeys, paramCase(key)])
3838
} else {
3939
cssVariables.push({
40-
key: `--${(options && options.prefix && `${options.prefix}-`) || ''}${[...parentKeys, key].join('-')}`,
40+
key: `--${(options && options.prefix && `${options.prefix}-`) || ''}${[...parentKeys, paramCase(key)].join(
41+
'-'
42+
)}`,
4143
value,
4244
})
4345
}

0 commit comments

Comments
 (0)