luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.59k stars 156 forks source link

Add macro to inline SVG files #1761

Closed wout closed 1 year ago

wout commented 1 year ago

Purpose

Adds a macro to inline SVG files at compile time.

Description

SVG logos and icons can be inlined with the inline_svg macro in pages and components:

button
  inline_svg("buttons/round.svg")
end

This will:

Icons can then be styled with:

[data-inline-svg] {
  fill: none;
  stroke: #222;
  stroke-width: 2px;
}

Or:

[data-inline-svg="buttons/round.svg"] {
  fill: #f03;
}

I realise Lucky does not use annotations a lot, but I think they are helpful in this case. The settings defined by the annotations are reasonable defaults, I think, but if necessary, users can jump in and override the defaults.

This PR implements #1760.

Checklist

wout commented 1 year ago

Forgot to mention I'll add the necessary documentation on the website as well when this is approved.