diff --git a/frontend/src/tw-components/Typography.tsx b/frontend/src/tw-components/Typography.tsx index 4f3a7e23..0f2e3bad 100644 --- a/frontend/src/tw-components/Typography.tsx +++ b/frontend/src/tw-components/Typography.tsx @@ -1,4 +1,24 @@ import React from "react"; +import clsx from "clsx"; + +const baseStyles = "font-sans leading-[137%]"; + +const TypographyStyles = { + Title1: "text-[48px] font-bold", + Title2: "text-[36px] font-bold", + Title3: "text-[28px] font-bold", + Title4: "text-[24px] font-bold", + Title5: "text-[20px] font-bold", + Title6: "text-[16px] font-bold", + Title7: "text-[14px] font-bold", + Paragraph1: "text-[20px]", + Paragraph2: "text-[18px]", + Paragraph3: "text-[16px]", + Paragraph4: "text-[15px]", + Paragraph5: "text-[14px]", + HyperlinkBold: "text-[16px] font-bold underline", + Hyperlink: "text-[14px] underline", +}; type TypographyProps = { children: React.ReactNode; @@ -10,107 +30,38 @@ type HyperlinkProps = { } & TypographyProps & React.AnchorHTMLAttributes; -const Typography = { - Title1: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), - Title2: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), - Title3: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), - Title4: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), - Title5: ({ children, className = "", ...props }: TypographyProps) => ( -
- {children} -
- ), - Title6: ({ children, className = "", ...props }: TypographyProps) => ( -
- {children} -
- ), - Title7: ({ children, className = "", ...props }: TypographyProps) => ( -
- {children} -
- ), - Paragraph1: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), - Paragraph2: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), - Paragraph3: ({ children, className = "", ...props }: TypographyProps) => ( -

+const createTypography = ( + Tag: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p", + size: (typeof TypographyStyles)[keyof typeof TypographyStyles], +) => { + const Component = ({ children, className, ...props }: TypographyProps) => ( + {children} -

- ), - Paragraph4: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), - Paragraph5: ({ children, className = "", ...props }: TypographyProps) => ( -

- {children} -

- ), + + ); + + Component.displayName = `Typography.${Tag}`; + + return Component; +}; + +const Typography = { + Title1: createTypography("h1", TypographyStyles.Title1), + Title2: createTypography("h2", TypographyStyles.Title2), + Title3: createTypography("h3", TypographyStyles.Title3), + Title4: createTypography("h4", TypographyStyles.Title4), + Title5: createTypography("h5", TypographyStyles.Title5), + Title6: createTypography("h6", TypographyStyles.Title6), + Title7: createTypography("h6", TypographyStyles.Title7), + Paragraph1: createTypography("p", TypographyStyles.Paragraph1), + Paragraph2: createTypography("p", TypographyStyles.Paragraph2), + Paragraph3: createTypography("p", TypographyStyles.Paragraph3), + Paragraph4: createTypography("p", TypographyStyles.Paragraph4), + Paragraph5: createTypography("p", TypographyStyles.Paragraph5), HyperlinkBold: ({ children, className, href, ...props }: HyperlinkProps) => ( {children} @@ -119,7 +70,7 @@ const Typography = { Hyperlink: ({ children, className, href, ...props }: HyperlinkProps) => ( {children}