mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-16 09:23:52 +03:00
55ce63dbfc
The style guide is currently for V4.
69 lines
1.1 KiB
Elm
69 lines
1.1 KiB
Elm
module Examples.SegmentedControl exposing (Msg, State, example, init, update)
|
|
|
|
{-|
|
|
|
|
@docs Msg, State, example, init, update,
|
|
|
|
-}
|
|
|
|
import Html
|
|
import ModuleExample exposing (Category(..), ModuleExample)
|
|
import Nri.Ui.SegmentedControl.V4
|
|
|
|
|
|
{-| -}
|
|
type Msg
|
|
= Select Id
|
|
|
|
|
|
{-| -}
|
|
type alias State =
|
|
Nri.Ui.SegmentedControl.V4.Config Id Msg
|
|
|
|
|
|
{-| -}
|
|
example : (Msg -> msg) -> State -> ModuleExample msg
|
|
example parentMessage state =
|
|
{ filename = "Nri/Ui/SegmentedControl/V4.elm"
|
|
, category = Behaviors
|
|
, content =
|
|
[ Html.map parentMessage (Nri.Ui.SegmentedControl.V4.view state)
|
|
]
|
|
}
|
|
|
|
|
|
{-| -}
|
|
init : State
|
|
init =
|
|
{ onClick = Select
|
|
, options =
|
|
[ { icon = Nothing
|
|
, id = "a"
|
|
, label = "Option A"
|
|
, value = "a"
|
|
}
|
|
, { icon = Nothing
|
|
, id = "b"
|
|
, label = "Option B"
|
|
, value = "b"
|
|
}
|
|
]
|
|
, selected = "a"
|
|
}
|
|
|
|
|
|
{-| -}
|
|
update : Msg -> State -> ( State, Cmd Msg )
|
|
update msg state =
|
|
case msg of
|
|
Select id ->
|
|
( { state | selected = id }, Cmd.none )
|
|
|
|
|
|
|
|
-- INTERNAL
|
|
|
|
|
|
type alias Id =
|
|
String
|