Skip to content

Commit 4c84e7d

Browse files
authored
Merge pull request #2389 from wahidrahim/fix-custom-properties
fix(custom-properties): use default key name if pluralize returns empty
2 parents 2d8bfc3 + 91f14e9 commit 4c84e7d

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

packages/custom-properties/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function makeCustomProperties(theme: Theme, prefix?: string) {
1414

1515
const generateProperties = (object: object, previousKey?: string) => {
1616
Object.entries(object).forEach(([key, value]) => {
17-
let formattedKey = pluralize(key, 1)
17+
let formattedKey = pluralize(key, 1) || key
1818

1919
if (
2020
process.env.NODE_ENV !== 'production' &&

packages/custom-properties/test/__snapshots__/test.mjs.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ exports[`transforms a theme config to CSS custom properties 1`] = `
1818
"--fontWeight-heading": 700,
1919
"--lineHeight-0": 1.5,
2020
"--lineHeight-1": 1.125,
21+
"--radius-l": "0.5em",
22+
"--radius-m": "0.25em",
23+
"--radius-s": "0.125em",
2124
"--size-0": "10em",
2225
"--size-1": "20em",
2326
"--size-2": "30em",
@@ -49,6 +52,9 @@ exports[`transforms a theme config to CSS custom properties with prefix 1`] = `
4952
"--🍭-fontWeight-heading": 700,
5053
"--🍭-lineHeight-0": 1.5,
5154
"--🍭-lineHeight-1": 1.125,
55+
"--🍭-radius-l": "0.5em",
56+
"--🍭-radius-m": "0.25em",
57+
"--🍭-radius-s": "0.125em",
5258
"--🍭-size-0": "10em",
5359
"--🍭-size-1": "20em",
5460
"--🍭-size-2": "30em",

packages/custom-properties/test/test.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const theme = {
3737
lineHeights: [1.5, 1.125],
3838
space: [0, 2, 3, 4, 5, 6],
3939
size: ['10em', '20em', '30em', '40em'],
40+
radii: {
41+
s: '0.125em',
42+
m: '0.25em',
43+
l: '0.5em',
44+
},
4045
}
4146

4247
it('transforms a theme config to CSS custom properties', () => {

0 commit comments

Comments
 (0)