Skip to content

Instantly share code, notes, and snippets.

@rtfeldman
Created January 15, 2018 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtfeldman/5d924692825552c40b676356a39f206e to your computer and use it in GitHub Desktop.
Save rtfeldman/5d924692825552c40b676356a39f206e to your computer and use it in GitHub Desktop.
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