Skip to content

Commit

Permalink
refactor: Keyed
Browse files Browse the repository at this point in the history
  • Loading branch information
srghma committed Jul 31, 2020
1 parent 08a5bd3 commit 404c95e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
28 changes: 16 additions & 12 deletions src/Halogen/Svg/Elements.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ element = coe Core.element
-> ElemName -> Array (IProp r i) -> Array (HTML p i) -> HTML p i
coe = unsafeCoerce

-- | Nodes

svg :: forall p i. Node I.SVGsvg p i
svg = element (ElemName "svg")

Expand All @@ -34,18 +36,6 @@ circle = element (ElemName "circle")
circle_ :: forall w i. Array (HTML w i) -> HTML w i
circle_ = circle []

ellipse :: forall p i. Leaf I.SVGellipse p i
ellipse props = element (ElemName "ellipse") props []

rect :: forall p i. Leaf I.SVGrect p i
rect props = element (ElemName "rect") props []

path :: forall p i. Leaf I.SVGpath p i
path props = element (ElemName "path") props []

line :: forall p i. Leaf I.SVGline p i
line props = element (ElemName "line") props []

text :: forall p i. Node I.SVGtext p i
text = element (ElemName "text")

Expand All @@ -69,3 +59,17 @@ defs = element (ElemName "defs")

defs_ :: forall p i. Array (HTML p i) -> HTML p i
defs_ = defs []

-- | Leafs

ellipse :: forall p i. Leaf I.SVGellipse p i
ellipse props = element (ElemName "ellipse") props []

rect :: forall p i. Leaf I.SVGrect p i
rect props = element (ElemName "rect") props []

path :: forall p i. Leaf I.SVGpath p i
path props = element (ElemName "path") props []

line :: forall p i. Leaf I.SVGline p i
line props = element (ElemName "line") props []
16 changes: 9 additions & 7 deletions src/Halogen/Svg/Elements/Keyed.purs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module Halogen.Svg.Elements.Keyed where
-- Like Halogen.HTML.Elements

import Prelude

import Halogen.Svg.Core as Core

Expand All @@ -24,11 +21,16 @@ keyedElement = coe Core.keyedElement
-> ElemName -> Array (IProp r i) -> Array (Tuple String (HTML p i)) -> HTML p i
coe = unsafeCoerce

-- | Nodes

svg :: forall p i. KeyedNode I.SVGsvg p i
svg = keyedElement $ ElemName "svg"
svg = keyedElement (ElemName "svg")

g :: forall p i. KeyedNode I.SVGg p i
g = keyedElement $ ElemName "g"
g = keyedElement (ElemName "g")

circle :: forall p i. KeyedNode I.SVGcircle p i
circle = keyedElement (ElemName "circle")

text :: forall p i. KeyedNode I.SVGtext p i
text = keyedElement (ElemName "text")
Expand All @@ -39,5 +41,5 @@ foreignObject = keyedElement (ElemName "foreignObject")
marker :: forall p i. KeyedNode I.SVGmarker p i
marker = keyedElement (ElemName "marker")

defs :: forall p i. Array (Tuple String (HTML p i)) -> HTML p i
defs = keyedElement (ElemName "defs") []
defs :: forall p i. KeyedNode I.SVGdefs p i
defs = keyedElement (ElemName "defs")

0 comments on commit 404c95e

Please sign in to comment.