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

Commit a8d9167

Browse files
committed
feat(helper.ts): Defined a new applyCssValue function
1 parent 5b616f0 commit a8d9167

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/_internal/utils/helper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ export const isWindowDefined = typeof window !== 'undefined';
66
export const isDocumentDefined = typeof document !== 'undefined';
77
export const isInDevelopment = process.env.NODE_ENV === 'development';
88

9-
export const exception = ['line-height', 'font-weight', 'opacity', 'scale', 'z-index'];
9+
const exception = ['line-height', 'font-weight', 'opacity', 'scale', 'z-index'];
10+
11+
export const applyCssValue = (value: string | number, cssProp: string): string => {
12+
if (typeof value === 'number') {
13+
return exception.includes(cssProp) ? value.toString() : value + 'px';
14+
}
15+
return value;
16+
};
1017

1118
export const isClassesObjectType = (object: object): object is ClassesObjectType => {
1219
return typeof object === 'object' && !Array.isArray(object);

0 commit comments

Comments
 (0)