import { createMemo, createSignal, onMount, splitProps, type Component, type JSX, type ParentComponent, type Signal } from "solid-js"; import { listItemContentStyle, listItemStyle, listItemSubtitleStyle, listItemHeadlineStyle } from "./list-item.css"; import { Ripple } from "../ripple"; import { Dynamic } from "solid-js/web"; import { mergeRefs } from "@solid-primitives/refs"; import clsx from "clsx/lite"; import { Focus } from "../focus"; export type ListItemType = "text" | "button" | "link"; type BaseListItemProps = { type?: ListItemType; leading?: JSX.Element; headline: JSX.Element; subtitle?: JSX.Element; trailing?: JSX.Element; } export type ListItemProps = { href?: string; target?: string; } & BaseListItemProps & Omit, "children">; export const ListItem: Component = (props) => { // let ref!: HTMLElement; const [ref, setRef] = createSignal() as Signal; const [local, others] = splitProps( props, [ "ref", "class", "type", "leading", "headline", "subtitle", "trailing", ], ); const type = createMemo((): ListItemType => local.type ?? "href" in others ? "link" : "text"); const tag = createMemo(() => { switch(type()) { case "text": return "li"; case "button": return "button"; case "link": return "a"; } }); return ( {local.leading}
{props.headline} {props.subtitle}
{local.trailing}
) // switch(tag()) { // case "li": return ( //
  • // {children} //
  • // ); // case "button": return ( // // ); // case "a": return ( // // {children} // // ); // } }