2020-03-31 22:43:32 +03:00
|
|
|
module Examples.Dropdown exposing (Msg, State, example)
|
2018-04-16 22:19:43 +03:00
|
|
|
|
|
|
|
{-|
|
|
|
|
|
2020-03-31 22:43:32 +03:00
|
|
|
@docs Msg, State, example
|
2018-04-16 22:19:43 +03:00
|
|
|
|
|
|
|
-}
|
|
|
|
|
2020-03-24 03:33:42 +03:00
|
|
|
import Category exposing (Category(..))
|
2020-03-31 23:20:03 +03:00
|
|
|
import Example exposing (Example)
|
2018-10-23 19:55:30 +03:00
|
|
|
import Html.Styled
|
|
|
|
import Nri.Ui.Dropdown.V2
|
2018-04-16 22:19:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
|
|
|
type Msg
|
|
|
|
= ConsoleLog String
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
2020-03-31 22:43:32 +03:00
|
|
|
type alias State =
|
|
|
|
List (Nri.Ui.Dropdown.V2.ViewOptionEntry String)
|
2018-04-16 22:19:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
2020-03-31 23:20:03 +03:00
|
|
|
example : Example State Msg
|
2020-03-31 22:43:32 +03:00
|
|
|
example =
|
2019-05-10 21:11:44 +03:00
|
|
|
{ name = "Nri.Ui.Dropdown.V2"
|
2020-03-31 22:43:32 +03:00
|
|
|
, state = init
|
|
|
|
, update = update
|
2020-03-31 22:48:26 +03:00
|
|
|
, subscriptions = \_ -> Sub.none
|
2020-03-31 22:43:32 +03:00
|
|
|
, view =
|
|
|
|
\state ->
|
|
|
|
[ Nri.Ui.Dropdown.V2.view "All the foods!" state ConsoleLog
|
|
|
|
]
|
|
|
|
, categories = [ Inputs ]
|
2018-04-16 22:19:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
2020-03-31 22:43:32 +03:00
|
|
|
init : State
|
2018-04-16 22:19:43 +03:00
|
|
|
init =
|
|
|
|
[ { isSelected = False, val = "Burrito", displayText = "Burrito" }
|
|
|
|
, { isSelected = False, val = "Nacho", displayText = "Nacho" }
|
|
|
|
, { isSelected = False, val = "Horchata", displayText = "Horchata" }
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
2020-03-31 22:43:32 +03:00
|
|
|
update : Msg -> State -> ( State, Cmd Msg )
|
2018-04-16 22:19:43 +03:00
|
|
|
update msg state =
|
|
|
|
case msg of
|
|
|
|
ConsoleLog message ->
|
|
|
|
let
|
|
|
|
_ =
|
|
|
|
Debug.log "DropdownExample" message
|
|
|
|
in
|
|
|
|
( state, Cmd.none )
|