primait/pyxis-components/9.0.0

NOTE: the latest version is 9.0.3

Prima.Pyxis.ListChooser

Configuration

type Config

Represent the configuration of the component.

type State

Represent the component State.

type Msg
= ToggleViewMode
| ChooseItem String

Represents the messages dispatched by the ListChooser Component

Represent a single item which can be selected via ListChooser's API.

= All
| Partial

Defines the mode in which the list must be shown. It's possible to choose between the full list of items (viewModeAll) or a limited set of items (viewModePartial). In this case the number of items to be shown is expressed via shownItems.

Configuration Methods

config : Int -> String -> String -> Config

Create the configuration of the ListChooser.

...


myConfig : ListChooser.Config
myConfig =
    let
        shownItems =
            5


        viewAllLabel =
            "Show all"


        viewPartialLabel =
            "Show first " ++ (String.fromInt shownItems) ++ " elements"
    in
    ListChooser.config shownItems viewAllLabel viewPartialLabel


...

Creates the State record of a ListChooser.

Updates the state of the component when a Msg is received.

createItem : String -> String -> Bool -> ChooserItem

Creates a representation of a ChooserItem.

...


myItem : ListChooser.ChooserItem
myItem =
    let
        slug =
            "my_item_slug"


        content =
            "Lorem ipsum dolor sit amet."


        isSelected =
            False
    in
    ListChooser.createItem (slug, content, isSelected)


...

Rendering

render : State -> Config -> Html Msg

Renders the component by receiving a State and a Config.

Options

withId : String -> Config -> Config

Adds an id Html.Attribute to the ListChooser.

withAttribute : Attribute Msg -> Config -> Config

Adds a generic Html.Attribute to the ListChooser.

Adds items to the ListChooser instance State record.

withItemClass : String -> Config -> Config

Adds a class for every item into the Config.

Adds an id Html.Attribute to the ListChooser.

Adds a class for the selected items to the Config.

Adds a class for the wrapper to the Config.