import CHEVRON_RIGHT_ICON from "@material-symbols/svg-700/outlined/chevron_right.svg"; import clsx from "clsx"; import { type Component, createSignal, type JSXElement, Match, Show, Suspense, Switch } from "solid-js"; import UKIcon from "../icon/UKIcon"; import UKIconButton from "../iconButton/UKIconButton.tsx"; import UKText from "../text/UKText"; import styles from "./UKStackItem.module.scss"; interface LeadingIconOrImage { type: "image" | "icon"; value: string; alt?: string; } interface LeadingIconButton { type: "iconButton"; value: string; alt: string; onClick: () => void; } const UKStackItem: Component<{ onClick?: () => void; onExpand?: () => void; onCollapse?: () => void; inlineComponent?: JSXElement; expandedComponent?: JSXElement; defaultExpanded?: boolean; leading?: LeadingIconOrImage | LeadingIconButton; labelText?: string; supportingText?: string; }> = (props) => { const [expanded, setExpanded] = createSignal(props.defaultExpanded ?? false); if (!!props.expandedComponent && props.onClick) { console.error("Cannot have a UKStackItem with both expandedComponent & onClick"); return <>Incompatible props, check console!; } if (!props.expandedComponent) { if (props.onExpand) { console.error("Cannot have a UKStackItem with onExpand without expandedComponent"); return <>Incompatible props, check console!; } if (props.onCollapse) { console.error("Cannot have a UKStackItem with onCollapse without expandedComponent"); return <>Incompatible props, check console!; } } return (
{props.leading?.type === "icon" && {props.leading.value}} {props.leading?.type === "image" && {props.leading.alt} {(props.labelText || props.supportingText) && (
... } > {props.labelText && ( {props.labelText} )} ... } > {props.supportingText && ( {props.supportingText} )}
)} {props.inlineComponent}
{props.expandedComponent}
); }; export default UKStackItem;