import React from 'react' import { Sprinkles } from '../../css/sprinkles.css' import { Box } from '../Box/Box' import { Truncate, Props as TruncateProps } from '../private/Truncate/Truncate' import * as styles from './styles.css' // `as?: styles.Variants['level']` was producing a type error so pulled this out // to a separate type. type Levels = 'h1' | 'h2' | 'h3' | 'h4' type Alignments = 'center' type Props = React.PropsWithChildren & Pick & { align?: Alignments as?: Levels level?: Levels lines?: TruncateProps['lines'] } export const Heading: React.FC = ({ align, as, children, level = 'h2', lines, ...props }) => { const content = lines ? ( {children} ) : ( children ) return ( {content} ) }