2016-03-25 23:09:07 +00:00
|
|
|
module Demo.Template where
|
|
|
|
|
|
|
|
import Effects exposing (Effects, none)
|
|
|
|
import Html exposing (..)
|
|
|
|
|
|
|
|
import Material.Template as Template
|
2016-04-12 22:13:43 +00:00
|
|
|
import Material.Helpers exposing (map1st)
|
|
|
|
import Material
|
|
|
|
|
|
|
|
import Demo.Page as Page
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- MODEL
|
|
|
|
|
|
|
|
|
2016-04-12 22:13:43 +00:00
|
|
|
type alias Mdl =
|
|
|
|
Material.Model
|
|
|
|
|
|
|
|
|
2016-03-25 23:09:07 +00:00
|
|
|
type alias Model =
|
2016-04-12 22:13:43 +00:00
|
|
|
{ mdl : Material.Model
|
2016-03-25 23:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
model : Model
|
|
|
|
model =
|
2016-04-12 22:13:43 +00:00
|
|
|
{ mdl = Material.model
|
2016-03-25 23:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- ACTION, UPDATE
|
|
|
|
|
|
|
|
|
|
|
|
type Action
|
2016-04-12 22:13:43 +00:00
|
|
|
= TemplateAction
|
|
|
|
| MDL (Material.Action Action)
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
update : Action -> Model -> (Model, Effects Action)
|
|
|
|
update action model =
|
|
|
|
case action of
|
2016-04-12 22:13:43 +00:00
|
|
|
TemplateAction ->
|
|
|
|
(model, Effects.none)
|
|
|
|
|
|
|
|
MDL action' ->
|
|
|
|
Material.update MDL action' model.mdl
|
|
|
|
|> map1st (\m -> { model | mdl = m })
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- VIEW
|
|
|
|
|
|
|
|
|
2016-04-12 22:13:43 +00:00
|
|
|
template =
|
|
|
|
Template.instance 0 MDL Template.model
|
|
|
|
[ Template.fwdTemplate TemplateAction ]
|
|
|
|
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
view : Signal.Address Action -> Model -> Html
|
|
|
|
view addr model =
|
2016-04-12 22:13:43 +00:00
|
|
|
[ div
|
|
|
|
[]
|
|
|
|
[ template.view addr model.mdl []
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|> Page.body2 "TEMPLATE" srcUrl intro references
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
intro : Html
|
2016-04-12 22:13:43 +00:00
|
|
|
intro =
|
|
|
|
Page.fromMDL "https://www.getmdl.io/components/index.html#TEMPLATE-section" """
|
2016-03-25 23:09:07 +00:00
|
|
|
> ...
|
2016-04-12 22:13:43 +00:00
|
|
|
"""
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
|
2016-04-12 22:13:43 +00:00
|
|
|
srcUrl : String
|
|
|
|
srcUrl =
|
|
|
|
"https://github.com/debois/elm-mdl/blob/master/demo/Demo/TEMPLATE.elm"
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
|
2016-04-12 22:13:43 +00:00
|
|
|
references : List (String, String)
|
|
|
|
references =
|
|
|
|
[ Page.package "http://package.elm-lang.org/packages/debois/elm-mdl/latest/Material-TEMPLATE"
|
|
|
|
, Page.mds "https://www.google.com/design/spec/components/TEMPLATE.html"
|
|
|
|
, Page.mdl "https://www.getmdl.io/components/index.html#TEMPLATE"
|
|
|
|
]
|
2016-03-25 23:09:07 +00:00
|
|
|
|
|
|
|
|