import { JSX, JSXElement } from 'solid-js'; import { COLORS } from 'src/colors'; type SSChipBaseProps = { children: JSXElement; color?: (typeof COLORS)[number]; class?: string; style?: string; }; type SSChipClickableProps = { onclick: JSX.EventHandlerUnion; ondismiss?: never; }; type SSChipDismissableProps = { ondismiss: () => void; onclick?: never; }; type SSChipDisplayProps = { onclick?: never; ondismiss?: never; }; type SSChipProps = SSChipBaseProps & (SSChipClickableProps | SSChipDismissableProps | SSChipDisplayProps); function SSChip(props: SSChipProps) { const commonClass = `ss_chip ss_chip--${props.color ?? 'blue'} ${props.class ?? ''}`; if ('onclick' in props && props.onclick) { return ( ); } return (
{props.children} {'ondismiss' in props && props.ondismiss && ( )}
); } export { SSChip };