Created
February 12, 2018 00:52
-
-
Save rebelwarrior/08f2fee4068ffb8c7209c25402f25f07 to your computer and use it in GitHub Desktop.
SlightlyLessSimpleDropdown.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (on, targetValue) | |
import Json.Decode | |
main = | |
beginnerProgram { model = "", view = view, update = update } | |
view model = | |
div [] | |
[ select [ on "change" valueDecoder ] | |
[ option [value "strawberry" ] [ text "strawberry" ] | |
, option [value "chocolate" ] [ text "chocolate" ] | |
, option [value "vanilla" ] [ text "vanilla" ] | |
] | |
, div [] [ text (model) ] | |
] | |
update msg model = | |
toString msg | |
flavorToUpcase value = | |
value | |
|> String.toUpper | |
|> Json.Decode.succeed | |
valueDecoder = | |
Html.Events.targetValue | |
|> Json.Decode.andThen flavorToUpcase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment