noredink-ui/styleguide-app/Examples/Select.elm

76 lines
1.2 KiB
Elm
Raw Normal View History

2018-09-26 17:02:10 +03:00
module Examples.Select exposing
( Msg
, State
, Value
, example
, init
, update
)
2018-04-17 01:39:57 +03:00
{-|
@docs Msg
@docs State
@docs Value
@docs example
@docs init
@docs update
-}
2018-07-11 03:50:39 +03:00
import Html.Styled
2018-04-17 01:39:57 +03:00
import ModuleExample exposing (Category(..), ModuleExample)
import Nri.Ui.Select.V5 as Select
2018-04-17 01:39:57 +03:00
{-| -}
type alias Value =
String
{-| -}
type Msg
= ConsoleLog String
{-| -}
type alias State value =
2018-07-11 03:50:39 +03:00
Select.Config value
2018-04-17 01:39:57 +03:00
{-| -}
example : (Msg -> msg) -> State Value -> ModuleExample msg
example parentMessage state =
2018-07-11 03:56:20 +03:00
{ filename = "Nri.Ui.Select.V3"
2018-04-17 01:39:57 +03:00
, category = Inputs
, content =
2018-07-11 03:50:39 +03:00
[ Html.Styled.map (parentMessage << ConsoleLog) (Select.view state)
2018-04-17 01:39:57 +03:00
]
}
{-| -}
init : State Value
init =
{ current = ""
, choices =
[ { label = "Tacos", value = "Tacos" }
, { label = "Burritos", value = "Burritos" }
, { label = "Enchiladas", value = "Enchiladas" }
]
, id = Nothing
, valueToString = identity
2018-04-17 01:39:57 +03:00
}
{-| -}
update : Msg -> State Value -> ( State Value, Cmd Msg )
update msg state =
case msg of
ConsoleLog message ->
let
_ =
Debug.log "SelectExample" message
in
( state, Cmd.none )