Skip to content

Instantly share code, notes, and snippets.

@knewter
knewter / Main.elm
Created August 9, 2016 21:18
Introduction to elm-mdl - 10
view : Model -> Html Msg
view model =
Material.Scheme.topWithScheme Color.Teal Color.LightGreen <|
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
, Layout.selectedTab model.selectedTab
, Layout.onSelectTab SelectTab
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]
@knewter
knewter / Main.elm
Created August 9, 2016 21:18
Introduction to elm-mdl - 9
view : Model -> Html Msg
view model =
Material.Scheme.topWithScheme Color.Teal Color.LightGreen <|
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
, Layout.selectedTab model.selectedTab
, Layout.onSelectTab SelectTab
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]
@knewter
knewter / Main.elm
Created August 9, 2016 21:17
Introduction to elm-mdl - 8
import Material.Color as Color
view : Model -> Html Msg
view model =
Material.Scheme.topWithScheme Color.Teal Color.LightGreen <|
Layout.render Mdl
-- ...
@knewter
knewter / Main.elm
Created August 9, 2016 21:16
Introduction to elm-mdl - 7
view : Model -> Html Msg
view model =
Material.Scheme.top <|
Layout.render Mdl
-- ...
@knewter
knewter / Main.elm
Created August 9, 2016 21:15
Introduction to elm-mdl - 6
type alias Model =
{ count : Int
, mdl :
Material.Model
-- Boilerplate: model store for any and all Mdl components you use.
, selectedTab : Int
}
model : Model
@knewter
knewter / Main.elm
Created August 9, 2016 21:15
Introduction to elm-mdl - 5
type Msg
-- ...
| SelectTab Int
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
-- ...
SelectTab num ->
@knewter
knewter / Main.elm
Created August 9, 2016 21:14
Introduction to elm-mdl - 4
view : Model -> Html Msg
view model =
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]
, drawer = []
, tabs = ( [ text "Milk", text "Oranges" ], [] )
, main = [ viewBody model ]
@knewter
knewter / Main.elm
Created August 9, 2016 21:13
Introduction to elm-mdl - 3
import Material.Layout as Layout
view : Model -> Html Msg
view model =
Layout.render Mdl
model.mdl
[ Layout.fixedHeader
]
{ header = [ h1 [ style [ ( "padding", "2rem" ) ] ] [ text "Counter" ] ]
, drawer = []
@knewter
knewter / Main.elm
Created August 9, 2016 21:11
Introduction to elm-mdl - 2
{- This file re-implements the Elm Counter example (1 counter) with elm-mdl
buttons. Use this as a starting point for using elm-mdl components in your own
app.
-}
module Main exposing (..)
import Html.App as App
import Html exposing (..)
@knewter
knewter / intro.sh
Created August 9, 2016 21:09
Introduction to elm-mdl - 1
mkdir mdl-playground
cd mdl-playground
elm package install -y debois/elm-mdl
vim Main.elm