Skip to content

Commit bed0d9b

Browse files
committed
fix(themes): check for excluded keys after kebab-case conversion
1 parent 1954189 commit bed0d9b

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

core/src/utils/test/theme.spec.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,24 @@ describe('generateCSSVars', () => {
233233
components: {},
234234
};
235235

236-
const css = generateCSSVars(theme);
236+
const css = generateCSSVars(theme).replace(/\s/g, '');
237237

238-
expect(css).toContain('--ion-border-width-sm: 4px;');
239-
expect(css).toContain('--ion-spacing-md: 12px;');
240-
expect(css).toContain('--ion-scaling-0: 0;');
241-
expect(css).toContain('--ion-radii-lg: 8px;');
242-
expect(css).toContain('--ion-dynamic-font: -apple-system-body;');
243-
expect(css).toContain('--ion-font-family: Roboto, "Helvetica Neue", sans-serif;');
244-
expect(css).toContain('--ion-font-weights-semi-bold: 600;');
245-
expect(css).toContain('--ion-font-sizes-sm: 14px;');
246-
expect(css).toContain('--ion-font-sizes-sm-rem: 0.875rem;');
247-
expect(css).toContain('--ion-font-sizes-md: 16px;');
248-
expect(css).toContain('--ion-font-sizes-md-rem: 1rem;');
249-
expect(css).toContain('--ion-line-heights-sm: 1.2;');
238+
const expectedCSS = `
239+
--ion-border-width-sm: 4px;
240+
--ion-spacing-md: 12px;
241+
--ion-scaling-0: 0;
242+
--ion-radii-lg: 8px;
243+
--ion-dynamic-font: -apple-system-body;
244+
--ion-font-family: Roboto, "Helvetica Neue", sans-serif;
245+
--ion-font-weights-semi-bold: 600;
246+
--ion-font-sizes-sm: 14px;
247+
--ion-font-sizes-sm-rem: 0.875rem;
248+
--ion-font-sizes-md: 16px;
249+
--ion-font-sizes-md-rem: 1rem;
250+
--ion-line-heights-sm: 1.2;
251+
`.replace(/\s/g, '');
252+
253+
expect(css).toBe(expectedCSS);
250254
});
251255
});
252256

core/src/utils/theme.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ export const generateCSSVars = (theme: any, prefix: string = CSS_PROPS_PREFIX):
8181
return [];
8282
}
8383

84-
// Do not generate CSS variables for excluded keys
85-
const excludedKeys = ['enabled', 'ripple-effect', 'form-highlight'];
86-
if (excludedKeys.includes(key)) {
87-
return [];
88-
}
89-
9084
// if key is camelCase, convert to kebab-case
9185
if (key.match(/([a-z])([A-Z])/g)) {
9286
key = key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
9387
}
9488

89+
// Do not generate CSS variables for excluded keys
90+
const excludedKeys = ['enabled'];
91+
if (excludedKeys.includes(key)) {
92+
return [];
93+
}
94+
9595
// Special handling for 'base' property - don't add suffix
9696
if (key === 'base') {
9797
return [`${prefix.slice(0, -1)}: ${val};`];

0 commit comments

Comments
 (0)