import classNames from 'classnames'; import { Link } from 'react-router-dom'; import { polymorphicForwardRef } from '@/types/polymorphic'; import classes from './styles.module.scss'; interface WrapperProps extends Omit< React.ComponentPropsWithoutRef<'div'>, 'title' > { icon?: React.ReactNode; sideContent?: React.ReactNode; } /** * A basic list item component that can be used as a base for more bespoke list items. * * Choose the child of the wrapper component based on needed interactivity: * `ListItemContent` for a non-interactive item, `ListItemButton` or `ListItemLink` * for interactive items. */ export const ListItemWrapper: React.FC = ({ icon, sideContent, children, className, ...otherProps }) => { return (
{icon}
{children}
{sideContent && ( {sideContent} )}
); }; interface ContentProps { subtitle?: React.ReactNode; subtitleId?: string; } export const ListItemContent = polymorphicForwardRef<'h3', ContentProps>( ( { as: Component = 'h3', subtitle, subtitleId, children, ...otherProps }, ref, ) => { return ( <> {children} {subtitle && (
{subtitle}
)} ); }, ); interface LinkProps extends React.ComponentPropsWithoutRef, ContentProps {} export const ListItemLink = polymorphicForwardRef<'h3', LinkProps>( ({ as, subtitle, children, className, ...otherProps }, ref) => { return ( {children} ); }, ); interface ButtonProps extends React.ComponentPropsWithoutRef<'button'>, ContentProps {} export const ListItemButton = polymorphicForwardRef<'h3', ButtonProps>( ({ as, subtitle, children, className, ...otherProps }, ref) => { return ( ); }, );