export enum FontFamily { Primary = "PT Root UI", Secondary = "Roboto", } export enum FontWeight { ExtraLight = 100, Light = 300, Regular = 400, Medium = 500, Bold = 700, } export enum HeadingTypes { H1 = "Header/H1", H2 = "Header/H2", H3 = "Header/H3", H4 = "Header/H4", } export enum TextTypes { P = "p", SPAN = "span", LINK = "link", IMAGE_TEXT = "IMAGE_TEXT", } export enum FontStyle { NORMAL = "normal", ITALIC = "italic", } export enum FontVersion { VERSION_2020 = 2020, VERSION_2022 = 2022, } export const textLevels = { ...HeadingTypes, ...TextTypes, } as const; export type TextLevel = typeof textLevels[keyof typeof textLevels]; export const textTags = { H1: "h1", H2: "h2", H3: "h3", H4: "h4", P: "p", Pre: "pre", Span: "span", } as const; export type TextTag = typeof textTags[keyof typeof textTags]; export type TextSizes = { fontFamily: FontFamily; fontWeight: FontWeight; fontStyle: FontStyle; fontSize: string; lineHeight: string; letterSpacing?: string; }; export type TextStyle = TextSizes & { htmlTag: TextTag }; type TextVersion = { [fontVersion in FontVersion]: TextStyle; }; type TextStyleList = { [textLevel in TextLevel]: TextVersion; }; export const textStyle: TextStyleList = { [textLevels.H1]: { [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Bold, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H1, fontSize: "32px", lineHeight: "38px", }, [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Bold, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H1, fontSize: "32px", lineHeight: "38px", }, }, [textLevels.H2]: { [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H2, fontSize: "27px", lineHeight: "32px", }, [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H2, fontSize: "27px", lineHeight: "32px", } }, [textLevels.H3]: { [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Light, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H3, fontSize: "24px", lineHeight: "28px", }, [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Light, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H3, fontSize: "24px", lineHeight: "28px", } }, [textLevels.H4]: { [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H4, fontSize: "18px", lineHeight: "21px", letterSpacing: "0", }, [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.H4, fontSize: "18px", lineHeight: "21px", letterSpacing: "0", } }, [textLevels.P]: { [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.P, fontSize: "16px", lineHeight: "24px", }, [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.P, fontSize: "16px", lineHeight: "24px", } }, [textLevels.SPAN]: { [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontSize: "13px", lineHeight: "17px", fontWeight: FontWeight.Light, fontStyle: FontStyle.NORMAL, htmlTag: textTags.Span, }, [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Secondary, fontSize: "16px", lineHeight: "16px", fontWeight: FontWeight.ExtraLight, fontStyle: FontStyle.NORMAL, htmlTag: textTags.Span, } }, [textLevels.LINK]: { [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.Span, fontSize: "16px", lineHeight: "24px", }, [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontWeight: FontWeight.Regular, fontStyle: FontStyle.NORMAL, htmlTag: textTags.Span, fontSize: "16px", lineHeight: "24px", } }, [textLevels.IMAGE_TEXT]: { [FontVersion.VERSION_2020]: { fontFamily: FontFamily.Primary, fontSize: "14px", lineHeight: "18px", fontWeight: FontWeight.Regular, fontStyle: FontStyle.ITALIC, htmlTag: textTags.Span, }, [FontVersion.VERSION_2022]: { fontFamily: FontFamily.Primary, fontSize: "14px", lineHeight: "18px", fontWeight: FontWeight.Regular, fontStyle: FontStyle.ITALIC, htmlTag: textTags.Span, } }, }; export const getTextSizes = ( level: TextLevel, version?: FontVersion ): TextSizes => { const { htmlTag, ...textSizes } = textStyle[level][version || FontVersion.VERSION_2022]; return textSizes; }; export type LabelPosition = "none" | "top" | "aside" | "right"; export type LabelType = "default" | "full" | "stretch";