fix: default variation size
If we use an icon like this, without setting up global icon preferences
```svelte
<AcademicCap variation="mini" />
```
you would expect size to be defaulted to the variation size, like viewBox, but it is not.
```html
<svg xmlns="http://www.w3.org/2000/svg" role="img" width="24" height="24" fill="none" aria-label="academic cap" viewBox="0 0 20 20" stroke-width="1.5">
...
</svg>
```
This PR fixes the above issue, assuming this is not intended behaviour.
<details><summary>Issue Details</summary>
<br>
The issue lies in these size default assignments for the different variations
https://github.com/shinokada/svelte-heros-v2/blob/b1a805748a81954bc305e5996c0b8c908c593bd1/src/lib/AcademicCap.svelte#L24-L25
since size is never falsy as it is defaulted to '24' when declaring props, size is never asigned '20'
https://github.com/shinokada/svelte-heros-v2/blob/b1a805748a81954bc305e5996c0b8c908c593bd1/src/lib/AcademicCap.svelte#L7-L8
</details>
<details><summary>Proposal Details</summary>
<br>
This patch does a few things:
- removes the size prop default assignments to '24'
https://github.com/shinokada/svelte-heros-v2/blob/7a60c02bfe63ee7132e50461fe38ef65d33f643c/src/lib/AcademicCap.svelte#L7-L8
- instead of using an $effect, derive viewBox and variationSize from the variation prop
https://github.com/shinokada/svelte-heros-v2/blob/7a60c02bfe63ee7132e50461fe38ef65d33f643c/src/lib/AcademicCap.svelte#L22-L31
- default width and height to variationSize if size isn't set (either by the consumer component or global context)
https://github.com/shinokada/svelte-heros-v2/blob/7a60c02bfe63ee7132e50461fe38ef65d33f643c/src/lib/AcademicCap.svelte#L38-L39
</details>
合并状态:未合并 关闭于 2024-07-28 4 条评论