diff --git a/Makefile b/Makefile index 67d7dd1..7f208e4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PAGES=../../elm-mdl-gh-pages +PAGES=../elm-mdl-gh-pages comp: elm-make examples/Component.elm --warn --output elm.js @@ -10,11 +10,11 @@ docs: elm-make --docs=docs.json wip-pages : - (cd demo; elm-make Demo.elm --output $(PAGES)/wip.js) + (cd demo; elm-make Demo.elm --output ../$(PAGES)/wip.js) (cd $(PAGES); git commit -am "Update."; git push origin gh-pages) pages : - elm-make examples/Demo.elm --output $(PAGES)/elm.js + (cd demo; elm-make Demo.elm --output ../$(PAGES)/elm.js) (cd $(PAGES); git commit -am "Update."; git push origin gh-pages) cleanish : diff --git a/demo/Demo/Page.elm b/demo/Demo/Page.elm index c10bd6b..06ffc25 100644 --- a/demo/Demo/Page.elm +++ b/demo/Demo/Page.elm @@ -152,8 +152,10 @@ body1 t srcUrl contents links demo = ] +body2 : String -> String -> Html -> List (String, String) -> List Html -> Html body2 = body1 + body3 : String -> String -> Html -> List (String, String) -> List Html -> Html body3 t srcUrl contents links demo = div diff --git a/demo/Demo/Textfields.elm b/demo/Demo/Textfields.elm index d47afb7..d19e93a 100644 --- a/demo/Demo/Textfields.elm +++ b/demo/Demo/Textfields.elm @@ -160,7 +160,7 @@ view addr model = |> List.map (\c -> cell [size All 4, offset Desktop 1] - [c.view addr model.mdl] + [c.view addr model.mdl []] ) |> List.intersperse (cell [size All 1] []) |> grid [] diff --git a/src/Material/Textfield.elm b/src/Material/Textfield.elm index b0ab571..ad43d72 100644 --- a/src/Material/Textfield.elm +++ b/src/Material/Textfield.elm @@ -46,6 +46,7 @@ import Html.Events exposing (..) import Effects import Material.Helpers exposing (filter) +import Material.Style as Style exposing (cs, cs', Style) import Material.Component as Component exposing (Indexed) @@ -138,25 +139,23 @@ update action model = {-| Component view. -} -view : Signal.Address Action -> Model -> Html --- TODO: Should take Style argument. -view addr model = +view : Signal.Address Action -> Model -> List Style -> Html +view addr model styles = let hasFloat = model.label |> Maybe.map .float |> Maybe.withDefault False hasError = model.error |> Maybe.map (always True) |> Maybe.withDefault False labelText = model.label |> Maybe.map .text in - filter div - [ classList - [ ("mdl-textfield", True) - , ("mdl-js-textfield", True) - , ("is-upgraded", True) - , ("mdl-textfield--floating-label", hasFloat) - , ("is-invalid", hasError) - , ("is-dirty", model.value /= "") - , ("is-focused", model.isFocused && not model.isDisabled) - , ("is-disabled", model.isDisabled) - ] - ] + filter Style.div + ( cs "mdl-textfield" + :: cs "mdl-js-textfield" + :: cs "is-upgraded" + :: cs' "mdl-textfield--floating-label" hasFloat + :: cs' "is-invalid" hasError + :: cs' "is-dirty" (model.value /= "") + :: cs' "is-focused" (model.isFocused && not model.isDisabled) + :: cs' "is-disabled" model.isDisabled + :: styles + ) [ Just <| input [ class "mdl-textfield__input" , style [ ("outline", "none") ] @@ -191,7 +190,7 @@ type alias Container c = {-| -} type alias Instance container obs = - Component.Instance Model container Action obs Html + Component.Instance Model container Action obs (List Style -> Html) {-| Component constructor. See module `Material`. @@ -199,7 +198,7 @@ type alias Instance container obs = instance : Int -> (Component.Action (Container c) obs -> obs) - -> Model + -> Model -> List (Component.Observer Action obs) -> Instance (Container c) obs