import * as React from "react"; import { PolymorphicWithRef } from "../types"; import { CardTitleWrapper, CardTitleBase } from "../base-components"; // import { TitleTypography } from "../TitleTypography"; import { BodyTypography } from "../BodyTypography"; type CardTitleProps = PolymorphicWithRef< T, { renderTitle?: ( Title: typeof BodyTypography, props: React.ComponentProps ) => React.ReactElement; renderSubtitle?: ( Subtitle: typeof BodyTypography, props: React.ComponentProps ) => React.ReactElement; } >; type CardTitleElement = ( props: CardTitleProps ) => React.ReactElement>; const CardTitle: CardTitleElement = React.forwardRef( ( props: CardTitleProps, innerRef: typeof props.ref ) => { const { component, children, renderTitle, renderSubtitle, ...rest } = props; if (renderTitle && !renderSubtitle) { return ( {renderTitle(BodyTypography, { size: "large", component: "h2", })} ); } if (renderTitle && renderSubtitle) { return ( {renderTitle(BodyTypography, { size: "large", component: "h2", })} {renderSubtitle(BodyTypography, { size: "medium", component: "h3", })} ); } else { return ( {children} ); } } ); export default CardTitle;