Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit bf32ea7

Browse files
committed
fix(css-codegen*): Fixed an issue where px was not added to normal media selector value other Add font-weight to the exception
1 parent 5b385ba commit bf32ea7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/_internal/utils/css-codegen-sheet.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function cssCodeGenSheet(object: ClassesObjectType | CustomHTMLType, base
4141
if (typeof value === 'string' || typeof value === 'number') {
4242
const CSSProp = camelToKebabCase(property);
4343
const applyValue =
44-
typeof value === 'number' && (CSSProp === 'line-height' || CSSProp === 'opacity' || CSSProp === 'scale')
44+
typeof value === 'number' && (CSSProp === 'line-height' || CSSProp === 'opacity' || CSSProp === 'scale' || CSSProp === 'font-weight')
4545
? value
4646
: typeof value === 'number'
4747
? value + 'px'
@@ -60,7 +60,7 @@ export function cssCodeGenSheet(object: ClassesObjectType | CustomHTMLType, base
6060

6161
for (const mediaProp in value as PropertyType) {
6262
if (Object.prototype.hasOwnProperty.call(value, mediaProp)) {
63-
const mediaValue = value[mediaProp as keyof PropertyType] as PropertyType;
63+
const mediaValue = value[mediaProp] as PropertyType;
6464
const mediaClassIndex = pseudo.classes.indexOf(mediaProp);
6565
const isMediaClassInc = pseudo.classes.includes(mediaProp);
6666
const isMediaElementInc = pseudo.elements.includes(mediaProp);
@@ -76,7 +76,14 @@ export function cssCodeGenSheet(object: ClassesObjectType | CustomHTMLType, base
7676
}
7777
nestedRules += selector(indent + className, colon + kebabMediaProp, pseudoClassRule, innerIndent);
7878
} else {
79-
regularRules += rules(innerIndent + ' ', value, mediaProp);
79+
const CSSProp = camelToKebabCase(mediaProp);
80+
const applyValue =
81+
typeof mediaValue === 'number' && (CSSProp === 'line-height' || CSSProp === 'opacity' || CSSProp === 'scale' || CSSProp === 'font-weight')
82+
? mediaValue
83+
: typeof mediaValue === 'number'
84+
? mediaValue + 'px'
85+
: mediaValue;
86+
regularRules += rules(innerIndent + ' ', { [mediaProp]: applyValue }, mediaProp);
8087
}
8188
}
8289
}

src/_internal/utils/css-codegen-style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function cssCodeGenStyle<T extends CustomCSSProperties>(object: T, base62
3333
} else if (typeof value === 'string' || typeof value === 'number') {
3434
const CSSProp = camelToKebabCase(property);
3535
const applyValue =
36-
typeof value === 'number' && (CSSProp === 'line-height' || CSSProp === 'opacity' || CSSProp === 'scale')
36+
typeof value === 'number' && (CSSProp === 'line-height' || CSSProp === 'opacity' || CSSProp === 'scale' || CSSProp === 'font-weight')
3737
? value
3838
: typeof value === 'number'
3939
? value + 'px'

0 commit comments

Comments
 (0)