natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
1.09k stars 59 forks source link

Change size property to allow strings #227

Closed nullish-cat closed 3 weeks ago

nullish-cat commented 3 months ago

What version of astro-icon are you using?

v1.1.0

Astro Info

Astro                    v4.11.5
Node                     v22.4.1
System                   Linux (x64)
Package Manager          yarn
Output                   static
Adapter                  none
Integrations             @astrojs/starlight
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Currently, the "size" property of the component is a number, which doesn't indicate what measurement it uses - is it pixels, percentage, em? It also doesn't allow said measurements, which can be limiting based on use case. (Mine being replacing the cards in starlight to use custom icons. Cards use the size 1.333em instead of a "static" size.)

This is actually possible right now - if you change the property to be a string and write something like "1.333em", TypeScript will complain about it, but the actual code itself works perfectly fine. Therefore the only thing needed is to add the string type to the property, so code using string sizes can be built.

What's the expected result?

To be allowed to use more advanced sizes like 2em and 25%.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-652cgt?file=src%2Fpages%2Findex.astro

ac-lebrun commented 2 months ago

Related PR https://github.com/natemoo-re/astro-icon/pull/219