import { createEffect, createUniqueId, on } from "solid-js" export interface MorphChevronProps { expanded: boolean class?: string } const COLLAPSED = "M4 6L8 10L12 6" const EXPANDED = "M4 10L8 6L12 10" export function MorphChevron(props: MorphChevronProps) { const id = createUniqueId() let path: SVGPathElement | undefined let expandAnim: SVGAnimateElement | undefined let collapseAnim: SVGAnimateElement | undefined createEffect( on( () => props.expanded, (expanded, prev) => { if (prev === undefined) { // Set initial state without animation path?.setAttribute("d", expanded ? EXPANDED : COLLAPSED) return } if (expanded) { expandAnim?.beginElement() } else { collapseAnim?.beginElement() } }, ), ) return ( ) }