natefaubion / purescript-spork

Elm-like for PureScript
MIT License
157 stars 9 forks source link

Is it possible to draw SVG? #27

Closed i-am-the-slime closed 6 years ago

natefaubion commented 6 years ago

Since both Halogen and Spork use halogen-vdom, you would do it the same way as you would in Halogen https://github.com/kwohlfahrt/purescript-halogen-svg

natefaubion commented 6 years ago

Specifically, you just want to create an element with the svg namespace https://github.com/kwohlfahrt/purescript-halogen-svg/blob/master/src/Svg/Core.purs#L14

i-am-the-slime commented 6 years ago

Okay it took me a while to figure this out but I'll leave this here for posterity (I needed the tip you gave here: https://github.com/slamdata/purescript-halogen/issues/363 about using attr over prop).

  H.elemWithNS
    ns
    "svg"
    [ H.attr "width" "200"
    , H.attr "height" "200"
    ]
    [ H.elemWithNS ns "circle"
      [ H.attr "cx" "10"
      , H.attr "cy" "10"
      , H.attr "r" "2"
      , H.attr "fill" "red"
      ] []
    ]
  where 
    ns = Just $ Namespace "http://www.w3.org/2000/svg"