-
Notifications
You must be signed in to change notification settings - Fork 45
Supporting rem as fontSize and lineheight #121
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I'm looking into supporting 'rem' as a unit for our design system, and migrating away from pixel values.
Currently, if I want to do that, I have to override the outputs provided from capsize like so:
export const textCrop = ({
lineHeight,
fontSize,
fontMetrics,
}: TextCropProps) => {
const fontSizeAsNumber = parseFloat(fontSize);
const leading = lineHeight * fontSizeAsNumber;
const capsizeStyles = createStyleObject({
fontSize: fontSizeAsNumber,
leading,
fontMetrics,
});
capsizeStyles.fontSize = fontSize;
capsizeStyles.lineHeight = lineHeight.toString();
return capsizeStyles;
};
with arguments as an example:fontSize: '2rem' lineHeight: 1.5
Looking into the source code - it seems like pixels are only needed for rounding – I assume if I wanted to use capHeight as a pixel value, and lineGap?
Is there any potential issue with me:
a) passing values in as rem - my assumption is not due to the relative nature of all the calculations
b) overriding the output back to a rem unit?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request