dwyl/elm-criteria/1.0.0

NOTE: the latest version is 2.2.1

Criteria

This package help you create a hierarchy of "filters" contained in a dropdown

Have a look at a live example and its code

View

view : Config msg filter -> State -> List filter -> Html msg

The view function which take the configuration the state and a list of filters

Config

type Config msg filter

Configuration for displaying the hierarchy of filters

{ title : String
, toMsg : State -> msg
, toId : filter -> String
, toString : filter -> String
, getSubFilters : filter -> List filter
}
-> Config msg filter

Create the configuation to pass in your view.

  • title — A string displayed for the button text
  • toMsg — The message which is responsible for updating the Criteria.State in your model
  • toId — A function taking a filter and returning a unique string which represent the filter
  • tostring — A function taking a filter and returning a string which will be used as label in the hierarchy
  • getSubFilters — A fuction taking a filter and returning the a list of its sub-filters

State

type State

Define if the hierarchy of filters is open and the set of the selected filters

State False Set.empty

Initialise the state, ie filters are hidden and no filter selected yet

import Criteria


Criteria.init

Helpers

selectedIdFilters : State -> Set String

Return the set of the selected filters' id