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 : String -> List (Attribute msg) -> Svg -> Html msg
link url svg = link name attributes icon =
Html.a (set (\a -> { a | label = name }) :: attributes)
[ Attributes.href url |> List.foldl (\(Attribute attribute) b -> attribute b) (build icon)
] |> renderLink
[ Svg.toHtml svg
]

View File

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