An Elm library to help you implement a color picker tool.
Opaque type. Needs to be added to your model. You will also need to store a Color
in your model
type alias Model =
{ myColour : Color
, colorPicker : ColorPicker.Model
}
Opaque type. These messages are handled by ColorPicker.update
empty : State
Initial ColorPicker state
init =
{ myColour = Color.red
, colorPicker = ColorPicker.empty
}
update : Msg -> Color -> State -> ( State, Maybe Color )
On each update, ColorPicker returns its model and (where appropriate) the new selected colo(u)r.
ColorPickerMsg msg ->
let
(cp, col) =
ColorPicker.update msg model.colorPicker
in
{ model | colorPicker = cp, myColor = Maybe.withDefault model.myColor col }