mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2025-01-04 20:56:47 +03:00
Adds withCss custom svg helper
This commit is contained in:
parent
74a7a8aef4
commit
7142cf64e6
@ -1,13 +1,13 @@
|
||||
module Nri.Ui.Svg.V1 exposing
|
||||
( Svg
|
||||
, withColor, withLabel, withWidth, withHeight
|
||||
, withColor, withLabel, withWidth, withHeight, withCss
|
||||
, fromHtml, toHtml
|
||||
)
|
||||
|
||||
{-|
|
||||
|
||||
@docs Svg
|
||||
@docs withColor, withLabel, withWidth, withHeight
|
||||
@docs withColor, withLabel, withWidth, withHeight, withCss
|
||||
@docs fromHtml, toHtml
|
||||
|
||||
-}
|
||||
@ -26,6 +26,7 @@ type Svg
|
||||
, color : Maybe Color
|
||||
, width : Maybe Css.Px
|
||||
, height : Maybe Css.Px
|
||||
, css : List Css.Style
|
||||
, label : Maybe String
|
||||
}
|
||||
|
||||
@ -39,6 +40,7 @@ fromHtml icon =
|
||||
, color = Nothing
|
||||
, height = Nothing
|
||||
, width = Nothing
|
||||
, css = []
|
||||
, label = Nothing
|
||||
}
|
||||
|
||||
@ -72,6 +74,13 @@ withHeight height (Svg record) =
|
||||
Svg { record | height = Just height }
|
||||
|
||||
|
||||
{-| Css for the SVG's container.
|
||||
-}
|
||||
withCss : List Css.Style -> Svg -> Svg
|
||||
withCss css (Svg record) =
|
||||
Svg { record | css = css }
|
||||
|
||||
|
||||
{-| Render an svg.
|
||||
-}
|
||||
toHtml : Svg -> Html msg
|
||||
@ -83,6 +92,7 @@ toHtml (Svg record) =
|
||||
, Maybe.map Css.width record.width
|
||||
, Maybe.map Css.height record.height
|
||||
]
|
||||
++ record.css
|
||||
|
||||
attributes =
|
||||
List.filterMap identity
|
||||
|
Loading…
Reference in New Issue
Block a user