2018-04-17 01:39:57 +03:00
|
|
|
module Examples.Select
|
|
|
|
exposing
|
|
|
|
( Msg
|
|
|
|
, State
|
|
|
|
, Value
|
|
|
|
, example
|
|
|
|
, init
|
|
|
|
, update
|
|
|
|
)
|
|
|
|
|
|
|
|
{-|
|
|
|
|
|
|
|
|
@docs Msg
|
|
|
|
@docs State
|
|
|
|
@docs Value
|
|
|
|
@docs example
|
|
|
|
@docs init
|
|
|
|
@docs update
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
import Html
|
|
|
|
import ModuleExample exposing (Category(..), ModuleExample)
|
2018-04-18 17:58:19 +03:00
|
|
|
import Nri.Ui.Select.V2
|
2018-04-17 01:39:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
type alias Value =
|
|
|
|
String
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
type Msg
|
|
|
|
= ConsoleLog String
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
type alias State value =
|
2018-04-18 17:58:19 +03:00
|
|
|
Nri.Ui.Select.V2.Config value
|
2018-04-17 01:39:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
example : (Msg -> msg) -> State Value -> ModuleExample msg
|
|
|
|
example parentMessage state =
|
|
|
|
{ filename = "ui/src/Nri/Select.elm"
|
|
|
|
, category = Inputs
|
|
|
|
, content =
|
2018-04-18 17:58:19 +03:00
|
|
|
[ Html.map (parentMessage << ConsoleLog) (Nri.Ui.Select.V2.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" }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
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 )
|