diff --git a/libs/@guardian/source-foundations/src/utils/typography.ts b/libs/@guardian/source-foundations/src/utils/typography.ts index 7b8832b7d..5efba090e 100644 --- a/libs/@guardian/source-foundations/src/utils/typography.ts +++ b/libs/@guardian/source-foundations/src/utils/typography.ts @@ -1,10 +1,15 @@ -const REGEX_FONT_SIZE = /font-size:\s(\d+\.\d+)rem/; +/* + * Convert font size in typography preset from default rem value to pixels + */ export const presetToPx = (preset: string) => { + const REGEX_FONT_SIZE = /font-size:\s(\d+\.\d+)rem/; + const matches = preset.match(REGEX_FONT_SIZE); if (matches?.[1]) { const pxVal = parseFloat(matches[1]) * 16; return preset.replace(REGEX_FONT_SIZE, `font-size: ${pxVal}px`); } + return preset; };