Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 61x 61x 1887x 1887x 1887x 1887x 15x 1872x 552x 1887x 61x 646x 646x 1x 645x 1x 644x 80x 564x 1x 646x 61x 647x 647x 647x 647x | import { getGlobalStyles } from 'src/global-styles'; const { fontSize: fontSizeSchema, } = getGlobalStyles(); export const scaleFactor = props => { const { sizeVariants: { sm: schemaSm, lg: schemaLg } } = fontSizeSchema; let value = null; const { sm, lg } = props; if (lg) { value = schemaLg; } else if (sm) { value = schemaSm; } return value; }; const getUnit = (size, defaultUnit) => { // Get the unit of measurement let unit = defaultUnit; if (size.toString().indexOf('%') !== -1) { unit = '%'; } else if (size.toString().indexOf('px') !== -1) { unit = 'px'; } else if (size.toString().indexOf('rem') !== -1) { unit = 'rem'; } else if (size.toString().indexOf('em') !== -1) { unit = 'em'; } return unit; }; export const scaleFont = (size, factor = 1, defaultSize = 1, defaultUnit = 'rem') => { // Convert the font size and scale factor to floats for calculation const floatSize = parseFloat(size) || defaultSize; const floatScaleFactor = parseFloat(factor); const unit = size ? getUnit(size, defaultUnit) : defaultUnit; // Calculate the final font size return (floatSize * floatScaleFactor).toString() + unit; }; |