Files
web/packages/design-system/lib/components/Typography/Typography.tsx
Erik Tiekstra 4ff44311a9 feat(SW-1968): Alternate opening hours for restaurants
Approved-by: Matilda Landström
2025-03-26 08:04:37 +00:00

21 lines
488 B
TypeScript

import { cloneElement, isValidElement } from 'react'
import { variants } from './variants'
import type { TypographyProps } from './types'
export function Typography({ variant, className, children }: TypographyProps) {
if (!isValidElement(children)) return null
const classNames = variants({
variant,
})
return cloneElement(children, {
...children.props,
className: [className, children.props.className, classNames]
.filter(Boolean)
.join(' '),
})
}