Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module Editor.ControlBar exposing (Button, Config, view)
import Animation exposing (Interpolation, Property, State, percent, px)
import Html exposing (Html, div, i, li, span, text, ul)
import Html.Attributes exposing (class, href)
import Html.Events exposing (onClick)
type alias Config msg =
{ buttons : List Button
, barDivClass : String
, style : List Animation.Property
, easing : Interpolation
, onSelectName : String -> msg
}
type alias Button =
{ name : String, iconClass : String }
view : Config msg -> Maybe Animation.State -> Html msg
view { buttons, barDivClass, onSelectName } maybeAnimation =
let
baseStyles =
case maybeAnimation of
Just state ->
Animation.render state
Nothing ->
[]
in
div
(baseStyles ++ [ class barDivClass ])
(List.map (viewButton onSelectName) buttons)
-- INTERNAL --
viewButton : (String -> msg) -> Button -> Html msg
viewButton onSelectName { name, iconClass } =
i [ class iconClass, onClick (onSelectName name) ] []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment