soveran / hypertext

Hypertext authoring with Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

You can have the ☀️ with hypertext and SVG

microspino opened this issue · comments

I'm sure I have an addiction for this gem because it's like "Nutella", a cream we have here in Italy 🇮🇹:
when you taste a little of it you can't stop spreading it on the bread. 🤣

I've recently discovered that if you want, you can get "the sun" with you library.

require "hypertext"
svg = Hypertext.new do |s|
  s.tag :svg, xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width" => 2, "stroke-linecap" => "round", "stroke-linejoin" => "round", class: "sun" do
    s.tag :circle, cx: 12, cy: 12, r: 5
    s.tag :line, x1: 12, y1: 1, x2: 12, y2: 3
    s.tag :line, x1: 12, y1: 21, x2: 12, y2: 23
    s.tag :line, x1: 4.22, y1: 4.22, x2: 5.64, y2: 5.64
    s.tag :line, x1: 18.36, y1: 18.36, x2: 19.78, y2: 19.78
    s.tag :line, x1: 1, y1: 12, x2: 3, y2: 12
    s.tag :line, x1: 21, y1: 12, x2: 23, y2: 12
    s.tag :line, x1: 4.22, y1: 19.78, x2: 5.64, y2: 18.36
    s.tag :line, x1: 18.36, y1: 5.64, x2: 19.78, y2: 4.22
  end
end

File.write("sun.svg", svg)

@soveran I'm not sure about the right place to handle this example. Maybe this could be added to the README. Maybe I have to rewrite it using an augmented version of your, newly introduced, DSL. What about a new domain specific class to handle just the svg.

NB: I'm not an designer, credits for the image needs to go to the author of feathericons a library I'm very fond of.

That's excellent, Daniele! I will add it to the README, but I will also think about ways to inject DSLs so that users of hypertext can customize the set of available tags.