2018-04-16 22:19:43 +03:00
|
|
|
module Examples.Dropdown exposing (Msg, State, Value, example, init, update)
|
|
|
|
|
|
|
|
{-|
|
|
|
|
|
2018-09-26 17:02:10 +03:00
|
|
|
@docs Msg, State, Value, example, init, update
|
2018-04-16 22:19:43 +03:00
|
|
|
|
|
|
|
-}
|
|
|
|
|
2018-10-23 19:55:30 +03:00
|
|
|
import Html.Styled
|
2018-04-16 22:19:43 +03:00
|
|
|
import ModuleExample exposing (Category(..), ModuleExample)
|
2018-10-23 19:55:30 +03:00
|
|
|
import Nri.Ui.Dropdown.V2
|
2018-04-16 22:19:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
type alias Value =
|
|
|
|
String
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
type Msg
|
|
|
|
= ConsoleLog String
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
type alias State value =
|
2018-10-23 19:55:30 +03:00
|
|
|
List (Nri.Ui.Dropdown.V2.ViewOptionEntry value)
|
2018-04-16 22:19:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
example : (Msg -> msg) -> State Value -> ModuleExample msg
|
|
|
|
example parentMessage state =
|
2019-05-10 21:11:44 +03:00
|
|
|
{ name = "Nri.Ui.Dropdown.V2"
|
2018-04-16 22:19:43 +03:00
|
|
|
, category = Inputs
|
|
|
|
, content =
|
2018-10-23 19:55:30 +03:00
|
|
|
[ Html.Styled.map parentMessage (Nri.Ui.Dropdown.V2.view "All the foods!" state ConsoleLog)
|
2018-04-16 22:19:43 +03:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
init : State Value
|
|
|
|
init =
|
|
|
|
[ { isSelected = False, val = "Burrito", displayText = "Burrito" }
|
|
|
|
, { isSelected = False, val = "Nacho", displayText = "Nacho" }
|
|
|
|
, { isSelected = False, val = "Horchata", displayText = "Horchata" }
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
update : Msg -> State Value -> ( State Value, Cmd Msg )
|
|
|
|
update msg state =
|
|
|
|
case msg of
|
|
|
|
ConsoleLog message ->
|
|
|
|
let
|
|
|
|
_ =
|
|
|
|
Debug.log "DropdownExample" message
|
|
|
|
in
|
|
|
|
( state, Cmd.none )
|