-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
63 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,20 @@ | ||
module Blueprint::HTML::SVG | ||
private def svg(**attributes) : Nil | ||
svg(**attributes) { } | ||
end | ||
|
||
private def svg(**attributes, &) : Nil | ||
render SVGComponent.new(**attributes) do |component| | ||
with component yield | ||
end | ||
end | ||
|
||
private struct SVGComponent(T) | ||
include Blueprint::HTML | ||
struct Blueprint::HTML::SVG(T) | ||
include Blueprint::HTML | ||
|
||
@attributes : T | ||
@attributes : T | ||
|
||
def self.new(**kwargs) : SVGComponent | ||
new kwargs | ||
end | ||
|
||
macro finished | ||
{% for tag in %w(a animate animateMotion animateTransform circle clipPath defs desc discard ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter foreignObject g image line linearGradient marker mask metadata mpath path pattern polygon polyline radialGradient rect script set stop style svg switch symbol text textPath title tspan use view) %} | ||
register_element {{tag}} | ||
{% end %} | ||
end | ||
macro finished | ||
{% for tag in %w(a animate animateMotion animateTransform circle clipPath defs desc discard ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter foreignObject g image line linearGradient marker mask metadata mpath path pattern polygon polyline radialGradient rect script set stop style svg switch symbol text textPath title tspan use view) %} | ||
register_element {{tag}} | ||
{% end %} | ||
end | ||
|
||
def initialize(attributes : T) | ||
{% T.raise "Expected T be NamedTuple, but got #{T}." unless T <= NamedTuple %} | ||
@attributes = attributes | ||
end | ||
def initialize(**@attributes : **T) | ||
end | ||
|
||
private def blueprint(&) : Nil | ||
element :svg, **@attributes do | ||
yield | ||
end | ||
private def blueprint(&) : Nil | ||
element :svg, **@attributes do | ||
yield | ||
end | ||
end | ||
end |