mirror of
https://github.com/correl/elm-mdl.git
synced 2025-03-30 01:03:43 -09:00
Fixes #14
This commit is contained in:
parent
7eecb28745
commit
8e7a62dfa3
2 changed files with 143 additions and 0 deletions
73
examples/Demo/Template.elm
Normal file
73
examples/Demo/Template.elm
Normal file
|
@ -0,0 +1,73 @@
|
|||
module Demo.Template where
|
||||
|
||||
import Effects exposing (Effects, none)
|
||||
import Html exposing (..)
|
||||
|
||||
import Markdown
|
||||
|
||||
import Material.Template as Template
|
||||
import Material exposing (lift, lift')
|
||||
|
||||
|
||||
-- MODEL
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ template : Template.Model
|
||||
}
|
||||
|
||||
|
||||
model : Model
|
||||
model =
|
||||
{ template = Template.model
|
||||
}
|
||||
|
||||
|
||||
-- ACTION, UPDATE
|
||||
|
||||
|
||||
type Action
|
||||
= TemplateAction Template.Action
|
||||
|
||||
|
||||
update : Action -> Model -> (Model, Effects Action)
|
||||
update action model =
|
||||
case action of
|
||||
TemplateAction action' -> lift .template (\m x -> {m|template=x}) TemplateAction Template.update action' model
|
||||
|
||||
|
||||
-- VIEW
|
||||
|
||||
|
||||
|
||||
view : Signal.Address Action -> Model -> Html
|
||||
view addr model =
|
||||
div []
|
||||
[ intro
|
||||
, Template.view (Signal.forwardTo addr TemplateAction) model.template
|
||||
]
|
||||
|
||||
|
||||
|
||||
intro : Html
|
||||
intro = """
|
||||
# TEMPLATE
|
||||
|
||||
From the
|
||||
[Material Design Lite documentation](https://www.getmdl.io/components/index.html#TEMPLATE-section).
|
||||
|
||||
> ...
|
||||
|
||||
#### See also
|
||||
|
||||
- [Demo source code](https://github.com/debois/elm-mdl/blob/master/examples/Demo/TEMPLATE.elm)
|
||||
- [elm-mdl package documentation](http://package.elm-lang.org/packages/debois/elm-mdl/latest/Material-TEMPLATE)
|
||||
- [Material Design Specification](https://www.google.com/design/spec/components/TEMPLATE.html)
|
||||
- [Material Design Lite documentation](https://www.getmdl.io/components/index.html#TEMPLATE)
|
||||
|
||||
#### Demo
|
||||
|
||||
""" |> Markdown.toHtml
|
||||
|
||||
|
||||
|
70
src/Material/Template.elm
Normal file
70
src/Material/Template.elm
Normal file
|
@ -0,0 +1,70 @@
|
|||
module Material.Template
|
||||
( Model, model
|
||||
, Action, update
|
||||
, view
|
||||
) where
|
||||
|
||||
-- TEMPLATE. Copy this to a file for your component, then update.
|
||||
|
||||
{-| From the [Material Design Lite documentation](http://www.getmdl.io/components/#TEMPLATE-section):
|
||||
|
||||
> ...
|
||||
|
||||
See also the
|
||||
[Material Design Specification]([https://www.google.com/design/spec/components/TEMPLATE.html).
|
||||
|
||||
# Component
|
||||
@docs Model, model, Action, update
|
||||
|
||||
# View
|
||||
@docs view
|
||||
|
||||
-}
|
||||
|
||||
|
||||
import Effects exposing (Effects, none)
|
||||
import Html exposing (..)
|
||||
|
||||
|
||||
-- MODEL
|
||||
|
||||
|
||||
{-| Component model.
|
||||
-}
|
||||
type alias Model =
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
{-| Default component model constructor.
|
||||
-}
|
||||
model : Model
|
||||
model =
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
-- ACTION, UPDATE
|
||||
|
||||
|
||||
{-| Component action.
|
||||
-}
|
||||
type Action
|
||||
= MyAction
|
||||
|
||||
|
||||
{-| Component update.
|
||||
-}
|
||||
update : Action -> Model -> (Model, Effects Action)
|
||||
update action model =
|
||||
(model, none)
|
||||
|
||||
|
||||
-- VIEW
|
||||
|
||||
|
||||
{-| Component view.
|
||||
-}
|
||||
view : Signal.Address Action -> Model -> Html
|
||||
view addr model =
|
||||
div [] [ h1 [] [ text "TEMPLATE" ] ]
|
Loading…
Add table
Reference in a new issue