Create interactive controls for complex data structures.
An interactive control that produces a value a
.
value : a -> Control a
A Control
that has a static value (and no UI).
bool : Basics.Bool -> Control Basics.Bool
A Control
that toggles a Bool
with a checkbox UI.
string : String -> Control String
A Control
that allows text input.
values : (a -> String) -> a -> List a -> Control a
A Control
that chooses between a list of values with a dropdown UI.
The first value will be the initial value.
maybe : Basics.Bool -> Control a -> Control (Maybe a)
A Control
that wraps another control in a Maybe
, which a checkbox UI.
The Bool
parameter is the initial value, where False
is Nothing
,
and True
is Just
with the value of the nested control.
choice : ( String, Control a ) -> List ( String, Control a ) -> Control a
A Control
that chooses between a list of nested controls.
This will crash if you provide an empty list.
The first entry will be the initial value.
list : Control a -> Control (List a)
A Control
that provides a list of selected length.
record : a -> Control a
Create a Control
representing a record with multiple fields.
This uses an API similar to elm-decode-pipeline.
You will use this with field
.
import Debug.Control exposing (field, record, string)
type alias Point =
{ x : String
, y : String
}
pointControl : Control Point
pointControl =
record Point
|> field "x" (string "initial x value")
|> field "y" (string "initial y value")
field : String -> Control a -> Control (a -> b) -> Control b
Used with record
to create a Control
representing a record.
See record
.
map : (a -> b) -> Control a -> Control b
Transform the value produced by a Control
.
view : (Control a -> msg) -> Control a -> Html msg
Renders the interactive UI for a Control
.
currentValue : Control a -> a
Gets the current value of a Control
.
allValues : Control a -> List a
TODO: revise API