Skip to content

Commit 52e7504

Browse files
authored
feat(preset-typography): suppor set null & {} to remove default value (#5115)
1 parent 91ee3a5 commit 52e7504

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

packages-presets/preset-typography/src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ export const presetTypography = definePreset(<Theme extends TypographyTheme = Ty
3535
const resolvedSizeScheme = resolveSizeScheme(options?.sizeScheme)
3636
const extended = (entries: TypographyCSSObject, theme: Theme) => {
3737
const extend = typeof options?.cssExtend === 'function' ? options?.cssExtend(theme) : options?.cssExtend
38-
return mergeDeep(entries, extend ?? {})
38+
const merged = mergeDeep(entries, extend ?? {})
39+
40+
for (const key in merged) {
41+
const value = merged[key as keyof TypographyCSSObject]
42+
if (value == null || (typeof value === 'object' && Object.keys(value).length === 0)) {
43+
delete merged[key as keyof TypographyCSSObject]
44+
}
45+
}
46+
47+
return merged
3948
}
4049
const normalizeSelector = (s: string) => {
4150
if (typeof options?.important === 'string') {

0 commit comments

Comments
 (0)