westerveltco / wagtail-heroicons

Add Heroicons to the Wagtail admin.
Other
5 stars 2 forks source link

Move to native namespace packages for sifferent icon types #29

Open joshuadavidthomas opened 1 year ago

joshuadavidthomas commented 1 year ago

Related to #28, in the heroicon package the icons are actually stored in a zip file to save space. This poses a problem for how Wagtail deals with SVG icons, as it expects the SVG to be a template somewhere where a template loader can find it.

As far as I can tell, Django does not come with a way to load templates from a zip. We may need to write a custom one, utilizing heroicons._load_icon or heroicons._render_icon in some way.

https://docs.djangoproject.com/en/4.1/ref/templates/api/#custom-loaders

joshuadavidthomas commented 1 year ago

On second thought, for such a simple package, maybe writing a custom template loader would be overkill to mainly slim down the package.

I wonder if using extra packages would be another way to slim it down to only include the icons a person could want, e.g.:

pip install wagtail-heroicons[outline,solid]  # for Heroicons v1.x
pip install wagtail-heroicons[mini,outline,solid]  # for Heroicons v2.x
joshuadavidthomas commented 3 months ago

Native namespace packages is I think the right way to do this (probably), provided you can install them as extras. I think you can, but testing will need to be done to check.