yawaramin/dream-html

add svg tags and attributes

Closed this issue · 3 comments

When adding an icon to a ui, I found that the svg tags and attributes are missing. I can work around this using the base helpers:

  let arrow_up =
    std_tag "svg"
      [
        string_attr "xmlns" "http://www.w3.org/2000/svg";
        string_attr "fill" "none";
        string_attr "viewbox" "0 0 24 24";
        string_attr "stroke-width" "1.5";
        string_attr "stroke" "currentColor";
        class_ "w-6 h-6";
      ]
      [
        std_tag "path"
          [
            string_attr "stroke-linecap" "round";
            string_attr "stroke-linejoin" "round";
            string_attr "d" "M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18";
          ]
          [];
      ]

But any reason not to add them to the lib?

Hmm, good question. No special reason, I had originally intended to cover only HTML, but there's no strong reason to exclude SVG. I am open to putting all the tags and attrs in an SVG nested module.

I've actually decided to make a backward-incompatible change and move all the HTML attributes and tags into a new Dream_html.HTML nested module. So under this scheme the nested modules are:

  • HTML
  • Hx
  • (Planned) SVG

Closing for now because we have some basic SVG support. But please feel to contribute more!