Skip to content

Commit a9f991b

Browse files
committed
fix(theme): check window
1 parent 88bfce3 commit a9f991b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

core/src/utils/theme.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,16 @@ const baselineUnit = 'rem';
649649
* @returns The calculated CSS value string.
650650
*/
651651
export const dynamicFont = (size: number, unit: string | undefined = baselineUnit): string => {
652-
const baselinePixelSize = parseFloat((window as any).Ionic?.config?.get?.('theme')?.fontSizes?.root ?? 16);
652+
let baselinePixelSize = 16;
653+
654+
if (typeof window !== 'undefined') {
655+
const configRootFontSize = (window as any)?.Ionic?.config?.get?.('theme')?.fontSizes?.root;
656+
657+
const parsedSize = parseFloat(configRootFontSize);
658+
if (!isNaN(parsedSize)) {
659+
baselinePixelSize = parsedSize;
660+
}
661+
}
653662

654663
return `${size / baselinePixelSize}${unit}`;
655664
};

0 commit comments

Comments
 (0)