import { CSSProperties, useContext, useEffect, useRef, useState } from 'react'; import { ThemeContext } from 'styled-components'; import { Box, Code, Flex, List, Section, Text } from '../../components'; import { UIComponentProps } from '../../components/types'; import { ITheme, IThemeFont, IThemeFontVariant } from '../../theme'; type Props = { }; export type TypographyProps = UIComponentProps; const TypographyItem = (props: { variant: IThemeFontVariant, size: CSSProperties['fontSize'] | {} }) => { const ref = useRef(null); const [px, setPx] = useState('0px'); useEffect(() => { function onResize() { if (ref.current) { setPx(window.getComputedStyle(ref.current).fontSize); } } onResize(); window.addEventListener('resize', onResize); return () => window.removeEventListener('resize', onResize); }, []); return ( {props.variant} {typeof props.size === 'string' ? props.size : JSON.stringify(props.size)} {px} ); }; export const Typography = (props: TypographyProps) => { const theme = useContext(ThemeContext) as ITheme; return (
{Object.entries(theme.font).map(([key, value]: [string, IThemeFont | undefined]) => { if (value) { return ( {value.family && {value.family}} ); } else { return null; } })}
); };