'use client'; import { cn } from 'lib/utils'; import React, { CSSProperties, FunctionComponent, JSXElementConstructor } from 'react'; interface TextProps { variant?: Variant; className?: string; style?: CSSProperties; children?: React.ReactNode | any; html?: string; onClick?: () => any; } type Variant = | 'heading' | 'body' | 'pageHeading' | 'productHeading' | 'sectionHeading' | 'label' | 'paragraph' | 'listChildHeading'; const Text: FunctionComponent = ({ style, className = '', variant = 'body', children, html, onClick }) => { const componentsMap: { [P in Variant]: React.ComponentType | string; } = { body: 'div', heading: 'h1', pageHeading: 'h1', productHeading: 'h1', sectionHeading: 'h2', listChildHeading: 'h3', label: 'div', paragraph: 'p' }; const Component: | JSXElementConstructor | React.ReactElement | React.ComponentType | string = componentsMap![variant!]; const htmlContentProps = html ? { dangerouslySetInnerHTML: { __html: html } } : {}; return ( {children} ); }; export default Text;