import React, { FunctionComponent, JSXElementConstructor, CSSProperties, } from 'react' import cn from 'classnames' import s from './Text.module.css' interface Props { variant?: Variant className?: string style?: CSSProperties children: React.ReactNode | any } type Variant = 'heading' | 'body' | 'pageHeading' const Text: FunctionComponent = ({ style, className = '', variant = 'body', children, }) => { const componentsMap: { [P in Variant]: React.ComponentType | string } = { body: 'p', heading: 'h1', pageHeading: 'h1', } const Component: | JSXElementConstructor | React.ReactElement | React.ComponentType | string = componentsMap![variant!] return ( {children} ) } export default Text