NoRedInk/noredink-ui/22.12.0

NOTE: the latest version is 35.9.3

Nri.Ui.Accordion.V3

Changes from V2

  • Do not render collapsed content
  • Allow disclosure indicator to be top-aligned
  • Allow fully-customizable carets
  • Removes as many default styles as possible
  • Change header resets to inline styles
  • Replace custom passed-in styles with a class-based styling approach (for performance reasons -- getting elm-css class names is too slow.)
  • Prevent default browser event on arrow keys (so that the page doesn't scroll when the focus changes)
  • Support multiple levels of accordions

Example

view : Model -> Html Msg
view model =
    div []
        [ Accordion.view
            { entries =
                [ AccordionEntry
                    { caret = Accordion.defaultCaret
                    , content = \() -> text "Accordion Content"
                    , entryClass = "a-class-distinguishing-this-accordion-from-others-on-the-page"
                    , headerContent = text "Accordion Header"
                    , headerId = "a-unique-id-for-this-accordion-header-button"
                    , headerLevel = Accordion.H1
                    , isExpanded = model.isAccordionOpen
                    , toggle = Just ToggleAccordion
                    }
                    []
                ]
            , focus = Focus
            }
        , Accordion.styleAccordion
            { entryStyles = []
            , entryExpandedStyles = []
            , entryClosedStyles = []
            , headerStyles = []
            , headerExpandedStyles = []
            , headerClosedStyles = []
            , contentStyles = []
            }
        ]
{ entries : List (AccordionEntry msg)
, focus : String -> msg
}
-> Html msg
= H1
| H2
| H3
| H4
| H5
| H6

Corresponds to h1, h2, h3 etc. Choose the correct header level given your page context.

= AccordionEntry (Entry msg) (List (AccordionEntry msg))
type alias Entry msg =
{ caret : Bool -> Html msg
, content : () -> Html msg
, entryClass : String
, headerContent : Html msg
, headerId : String
, headerLevel : HeaderLevel
, isExpanded : Bool
, toggle : Maybe (Bool -> msg)
}
type alias StyleOptions =
{ entryStyles : List Style
, entryExpandedStyles : List Style
, entryClosedStyles : List Style
, headerStyles : List Style
, headerExpandedStyles : List Style
, headerClosedStyles : List Style
, contentStyles : List Style
}
styleAccordion : StyleOptions -> Html msg
defaultCaret : Bool -> Html msg

Modules