Skip to content

Instantly share code, notes, and snippets.

@kuon
Last active June 25, 2017 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuon/12a144ec3307834b7a3f2152e075dac0 to your computer and use it in GitHub Desktop.
Save kuon/12a144ec3307834b7a3f2152e075dac0 to your computer and use it in GitHub Desktop.
Use SVG sprite from elm with webpack
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