-
-
Save rtfeldman/5d924692825552c40b676356a39f206e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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