Last active
June 25, 2017 22:05
-
-
Save kuon/12a144ec3307834b7a3f2152e075dac0 to your computer and use it in GitHub Desktop.
Use SVG sprite from elm with webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (Html, text, a, i, div, br) | |
import Html.Attributes exposing (class, value, href) | |
import Html exposing (Attribute) | |
import Json.Decode as Json | |
import Svg | |
import Svg.Attributes as SvgAttr | |
import Style.Icon as Style | |
import Html.CssHelpers | |
import Css.Helpers | |
import Style.Constants as Constants | |
type Icon | |
= BrokenHeart | |
| Heart | |
| Logo | |
icon : Icon -> Html msg | |
icon icon = | |
Svg.svg | |
[ SvgAttr.class "icon" | |
] | |
[ Svg.use [ SvgAttr.xlinkHref ("#" ++ (iconToString icon)) ] [] | |
] | |
iconToString : Icon -> String | |
iconToString icon = | |
case icon of | |
BrokenHeart -> | |
"brokenHeart" | |
Heart -> | |
"heart" | |
Logo -> | |
"logo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment