Icons Registry Module

adnan - 3 months ago

Sharing my experience building a module, icons-module, that can be used to manage icon definitions from the Control Panel. I'm developing this as part of a client project I am currently working on, but if anyone is interested I can open source it,


There was quite a bit of learning I had to do to achieve the end-result with minimum code by avoiding overriding/extending views and classes unnecessarily,

The module uses a stream to store entries of the Icons Registry. This stream gets seeded when the module is installed. I had to get access to the default Stream Platform Icons Registry list of icons which was a protected property, .. so I had to do this.

Each icon in the Grid view is selectable so that an action, delete etc, can be triggered. This and the animations were achieved by styling the checkbox element, c-checkbox alone,

The other challenging tasks I had to overcome were, to inject assets and select different partial views dynamically, based on the current Table view. I did that by extending the functionality of the TableBuilder so that it considers Table view assets and options (options to change limit of entries).

The Grid view uses two different partial views ( header and body), but instead of overriding the table.twig just so that I can change the partials, I decided to dynamically override the view from the module service provider by overriding the getOverrides function.

I am sure I've done some of this right, and some wrong, but the good news it works. Please feel free to correct or advice on any of the methods I used to achieve the final result,

Happy coding :)

ryanthompson - 3 months ago

So cool! I am sorry about earlier I wasn't understanding exactly what you needed regarding icon access. Perhaps this will help you clean things up: https://github.com/anomalylabs/streams-platform/commit/51443913cfbd01fb486d2b09ca0bf7ad99203843#diff-a5a8584a37573e3e581a6ad471db6d15R181

adnan - 3 months ago

No issue there, and that helps for sure, thanks Ryan, ..

And while you're here, .... Is there room in the Streams Platform for smaller packaging structs than a module (it has views, so not an extension, not full module nor plugin / field type) to share such work? .. maybe an "Entity" addon type?

I am finding myself working on similar stuff (recently a calendar, see below), it's mainly a Stream migrations, Entity classes, a controller, some servicer provider stuff (routes, views etc), but I can see it being plug-able in other projects,


This calendar uses default Pyro TableBuilder with minimum changes, and all the logic is done in the view (smashing all MVC conventions against the wall, i know) but awesome to see how much can be achieved with the Streams and Twig, ..

Plus now I know when the week starts, ... , Monday or Sunday? hh

ryanthompson - 3 months ago

@adnan extensions would be perfect for that. Extensions can provide views.

For example you could have the extension ONLY provide it's UI namespace/views similar to core tables or forms.. So you can have this calendar builder in the extension and just .. use it all the same. Does that make sense?

adnan - 3 months ago

Absolutely, thanks for that Ryan ..

adnan - 3 months ago

If you like this, here's the source code, https://github.com/websemantics/icons-module