diff --git a/examples/Demo/Template.elm b/examples/Demo/Template.elm new file mode 100644 index 0000000..36ad65d --- /dev/null +++ b/examples/Demo/Template.elm @@ -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 + + + diff --git a/src/Material/Template.elm b/src/Material/Template.elm new file mode 100644 index 0000000..e987d52 --- /dev/null +++ b/src/Material/Template.elm @@ -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" ] ]