Add themes

This commit is contained in:
Tessa Kelly 2020-09-28 11:19:28 -07:00
parent 9eaa87708d
commit 2f8845f414

View File

@ -6,6 +6,7 @@ module Nri.Ui.ClickableSvg.V1 exposing
, width, height , width, height
, disabled , disabled
, withBorder , withBorder
, primary, secondary, danger
, custom, css , custom, css
, withTooltipAbove, withTooltipBelow , withTooltipAbove, withTooltipBelow
) )
@ -44,6 +45,8 @@ module Nri.Ui.ClickableSvg.V1 exposing
## Customization ## Customization
@docs withBorder @docs withBorder
@docs primary, secondary, danger
@docs custom, css @docs custom, css
@ -193,6 +196,33 @@ withBorder =
set (\config -> { config | hasBorder = True }) set (\config -> { config | hasBorder = True })
type Theme
= Primary
| Secondary
| Danger
{-| -}
primary : Attribute msg
primary =
set (\attributes -> { attributes | theme = Primary })
{-| -}
secondary : Attribute msg
secondary =
set
(\attributes ->
{ attributes | theme = Secondary }
)
{-| -}
danger : Attribute msg
danger =
set (\attributes -> { attributes | theme = Danger })
{-| Use this helper to add custom attributes. {-| Use this helper to add custom attributes.
Do NOT use this helper to add css styles, as they may not be applied the way Do NOT use this helper to add css styles, as they may not be applied the way
@ -306,6 +336,7 @@ build label icon =
, customStyles = [] , customStyles = []
, tooltip = Nothing , tooltip = Nothing
, hasBorder = False , hasBorder = False
, theme = Primary
} }
@ -324,6 +355,7 @@ type alias ButtonOrLinkAttributes msg =
, customStyles : List Style , customStyles : List Style
, tooltip : Maybe (TooltipSettings msg) , tooltip : Maybe (TooltipSettings msg)
, hasBorder : Bool , hasBorder : Bool
, theme : Theme
} }
@ -405,7 +437,15 @@ buttonOrLinkStyles config =
( Colors.gray75, Colors.gray75, Css.notAllowed ) ( Colors.gray75, Colors.gray75, Css.notAllowed )
else else
( Colors.azure, Colors.azureDark, Css.pointer ) case config.theme of
Primary ->
( Colors.azure, Colors.azureDark, Css.pointer )
Secondary ->
( Colors.navy, Colors.navy, Css.pointer )
Danger ->
( Colors.red, Colors.red, Css.pointer )
in in
[ Css.property "transition" [ Css.property "transition"
"background-color 0.2s, color 0.2s, border-width 0s, border-color 0.2s" "background-color 0.2s, color 0.2s, border-width 0s, border-color 0.2s"