poppa / sveltekit-svg

SvelteKit plugin that makes it possible to import SVG files as Svelte components, inline SVG code or urls
MIT License
235 stars 23 forks source link

Add a hook to allow plugin users to modify the resulting component #41

Closed paoloricciuti closed 1 year ago

paoloricciuti commented 1 year ago

We are currently using this in out application but we've runned into the issue of not being able to dynamically set the title of the svg for accessibility reasons.

Given that the resulting import is a svelte component this would be very easy to do if we could modify the string returned from the vite plugin before the transform.

I can make a PR for this, and i'll probably start to work on this tomorrow so is you have any concern regarding this feel free to hit me up.

poppa commented 1 year ago

Sorry for the delay @paoloricciuti, it's been vacation time and stuff so I've mostly been afk.

I had an earlier PR laying around which conflicted with your PR. So, I took the freedom to re-implement your concept, which now can be found in a feature branch: https://github.com/poppa/sveltekit-svg/tree/feature/42-tranformComponenHook

If this is still of your interest, please take a look at the feature and let me know if it satisfies your needs.

paoloricciuti commented 1 year ago

Sorry for the delay @paoloricciuti, it's been vacation time and stuff so I've mostly been afk.

I had an earlier PR laying around which conflicted with your PR. So, I took the freedom to re-implement your concept, which now can be found in a feature branch: https://github.com/poppa/sveltekit-svg/tree/feature/42-tranformComponenHook

If this is still of your interest, please take a look at the feature and let me know if it satisfies your needs.

I like your approach: having both the raw SVG and the parts make it really easy to compose them. And yes this definitely suit my need. Thanks a lot.

poppa commented 1 year ago

Alright, this feature should now be available in 4.1.0

Thank you for the input :)