Created
August 9, 2016 21:15
-
-
Save knewter/fb78ea234b5a7dd6f2fd340c4cc483f5 to your computer and use it in GitHub Desktop.
Introduction to elm-mdl - 6
This file contains hidden or 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
type alias Model = | |
{ count : Int | |
, mdl : | |
Material.Model | |
-- Boilerplate: model store for any and all Mdl components you use. | |
, selectedTab : Int | |
} | |
model : Model | |
model = | |
{ count = 0 | |
, mdl = | |
Material.model | |
-- Boilerplate: Always use this initial Mdl model store. | |
, selectedTab = 0 | |
} | |
update : Msg -> Model -> ( Model, Cmd Msg ) | |
update msg model = | |
case msg of | |
-- ... | |
SelectTab num -> | |
{ model | selectedTab = num } ! [] | |
viewBody : Model -> Html Msg | |
viewBody model = | |
case model.selectedTab of | |
0 -> | |
viewCounter model | |
1 -> | |
text "something else" | |
_ -> | |
text "404" | |
-- Renamed again! | |
viewCounter : Model -> Html Msg | |
viewCounter model = | |
-- ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment