elm-mdl/src/Material/Helpers.elm
2016-03-16 06:32:41 +01:00

37 lines
764 B
Elm

module Material.Helpers where
import Html
import Html.Attributes
import Effects exposing (Effects)
filter : (a -> List b -> c) -> a -> List (Maybe b) -> c
filter elem attr html =
elem attr (List.filterMap (\x -> x) html)
mapWithIndex : (Int -> a -> b) -> List a -> List b
mapWithIndex f xs =
let
loop k ys =
case ys of
[] -> []
y :: ys -> f k y :: loop (k+1) ys
in
loop 0 xs
effect : Effects b -> a -> (a, Effects b)
effect e x = (x, e)
pure : a -> (a, Effects b)
pure = effect Effects.none
clip : comparable -> comparable -> comparable -> comparable
clip lower upper k = Basics.max lower (Basics.min k upper)
blurOn : String -> Html.Attribute
blurOn evt =
Html.Attributes.attribute ("on" ++ evt) <| "this.blur()"