westerveltco / wagtail-heroicons

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

Slim down package #54

Open joshuadavidthomas opened 6 months ago

joshuadavidthomas commented 6 months ago

IMO, this package is a bit heavy for what it does -- provide an easy way to use Heroicons throughout your Wagtail admin. Odds are, someone doesn't need ALL the heroicons at their disposal, just a handful of either specific icons or just a specific style. Right now this package includes all of the heroicons for every style which adds roughly 2 MB to the package.

wagtail-heroicons/src/wagtail_heroicons on  main [$]  v3.12.1 (heroicons-3.12) 
➜ du -h
932K    ./templates/wagtail_heroicons/solid
932K    ./templates/wagtail_heroicons/outline
1.9M    ./templates/wagtail_heroicons
1.9M    ./templates
1.9M    .

This will be further exacerbated when we start using Heroicons v2 (#48) as it has not two, but four different styles of icons. So it could go to up as much as 4 or 5 MB just for the SVG templates alone.

We could either go the route described in #29 and have a different namespace package for each icon style and have them installable via extras -- python -m pip install wagtail-heroicons[solid] OR we could provide a way to opt in somehow to selecting individual icons. Perhaps a management command that allows someone to specifically select an icon to download and have it put in the templates directory of the user's project (or wherever they want it).

joshuadavidthomas commented 6 months ago

Alternatively, as also discussed in #29, we could write a template loader that can load templates from a zip file and use https://github.com/adamchainz/heroicons for the icons, since that's how that package provides the icons. Obviously this would be a bit more complex, and would require the user to add the template loader to their settings, but it's something to think about.

joshuadavidthomas commented 6 months ago

Though looking at django-template-partials source, it doesn't seem too difficult -- https://github.com/carltongibson/django-template-partials/blob/main/src/template_partials/loader.py