Module

Halogen.Widgets.VAccordion

Package
purescript-halogen-widgets
Repository
afcondon/purescript-halogen-widgets

A vertical disclosure header — the reference instance of the library contract (see CONTRACT.md). Panels stack top-to-bottom; the header is always a full-width horizontal bar, and collapsing hides the parent's body and flips the chevron (▾ → ▸). This is the common web accordion, and the one to reach for unless you are laying panels out as side-by-side columns (then use HAccordion).

The PARENT owns open and renders the panel BODY itself (if open then [body] else []). A multi-panel accordion is N of these sharing a parent-owned open-set (exactly Triggerfish's collapsed :: Array String).

#component Source

Re-exports from Halogen.Widgets.Accordion.Internal

#Query Source

data Query a

Imperative escape hatch. Rarely needed — Input is the main channel — but present so every widget's Slot has the same shape. SetOpen requests a value just as a click would.

Constructors

#Output Source

data Output

A request, not a fact: the user asked for this new open value.

Constructors

#Input Source

type Input = { debounce :: Milliseconds, disabled :: Boolean, label :: String, motion :: Motion, open :: Boolean, sub :: Maybe String }

Controlled input. The parent owns open; everything else is config.

#defaultInput Source

defaultInput :: String -> Input

A sensible starting Input; override the fields you care about. The 120 ms default coalesces a double-dispatched click into one Toggled. motion defaults to NoMotion — the header snaps, as it always has; opt into eased chevron rotation by overriding it (and pair with Accordion.body for an eased body reveal).

#body Source

body :: forall w i. { motion :: Motion, open :: Boolean } -> Array (HTML w i) -> HTML w i

Tier-2 chrome (CONTRACT.md rule 5): an OPTIONAL animated wrapper for the panel body the parent renders. The accordion component is only the header; the body has always been the parent's, written if open then [body] else []. That form unmounts the body when collapsed, which is exactly why it cannot animate. body keeps the content mounted and eases its height with the CSS grid-rows 0fr1fr trick, so it slides.

The trade-off, made explicit: the body stays in the DOM while collapsed (at height 0). For a presentational body that costs nothing; for a body of live, expensive children, weigh it — the plain if open then … unmount is still the right call when you want the collapsed body genuinely gone, and is lighter when you are not animating at all. Reach for body when you want the reveal eased (pass the same motion you gave the header).

It is action-polymorphic, like Panel/Modal: your body content threads straight through, so it carries your interactive children untouched.