Use attribute helpers to build the link

This commit is contained in:
Tessa Kelly 2020-03-09 10:31:11 -07:00
parent 4ece9ee8ea
commit 0424d15cd3
2 changed files with 7 additions and 9 deletions

View File

@ -48,13 +48,11 @@ button name attributes icon =
{-| -}
link : String -> Svg -> Html msg
link url svg =
Html.a
[ Attributes.href url
]
[ Svg.toHtml svg
]
link : String -> List (Attribute msg) -> Svg -> Html msg
link name attributes icon =
(set (\a -> { a | label = name }) :: attributes)
|> List.foldl (\(Attribute attribute) b -> attribute b) (build icon)
|> renderLink

View File

@ -51,11 +51,11 @@ example unnamedMessages state =
[ ClickableSvg.onClick (parentMessages.showItWorked "You clicked the button!") ]
]
, Html.div [ Attributes.css [ Css.displayFlex ] ]
[ viewCode "ClickableSvg.link \"#some_link\""
[ viewCode "ClickableSvg.link \"Back\" \n\t[ ClickableSvg.href \"#some_link\" ]"
, UiIcon.arrowLeft
|> Svg.withWidth (Css.px 100)
|> Svg.withHeight (Css.px 100)
|> ClickableSvg.link "#some_link"
|> ClickableSvg.link "Back" [ ClickableSvg.href "#some_link" ]
]
]
}