Merge pull request #57 from NoRedInk/add-custom-button

Add custom button
This commit is contained in:
Jasper Woudenberg 2018-05-17 09:54:59 +02:00 committed by GitHub
commit 5c203314c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ module Nri.Ui.Button.V2
, button , button
, buttonDeprecated , buttonDeprecated
, copyToClipboard , copyToClipboard
, customButton
, delete , delete
, link , link
, linkExternal , linkExternal
@ -178,6 +179,13 @@ This button will be Disabled if the button state is:
-} -}
button : ButtonConfig msg -> ButtonContent -> Html msg button : ButtonConfig msg -> ButtonContent -> Html msg
button config content = button config content =
customButton [] config content
{-| Exactly the same as button but you can pass in a list of attributes
-}
customButton : List (Html.Attribute msg) -> ButtonConfig msg -> ButtonContent -> Html msg
customButton attributes config content =
let let
buttonStyle = buttonStyle =
case content.state of case content.state of
@ -220,12 +228,14 @@ button config content =
True True
in in
Html.button Html.button
[ buttonClass config.size config.width buttonStyle ([ buttonClass config.size config.width buttonStyle
, onClick config.onClick , onClick config.onClick
, Html.Attributes.disabled disabled , Html.Attributes.disabled disabled
, Html.Attributes.type_ "button" , Html.Attributes.type_ "button"
, widthStyle config.width , widthStyle config.width
] ]
++ attributes
)
[ viewLabel content.icon content.label ] [ viewLabel content.icon content.label ]