Category Icons

I’ve done a theme component to add the icon in the Events plugin calendar view.

It uses the category-icon widget, that do not display icon for subcategories. I’ve needed to add a “force mode” this way:

  api.createWidget("category-icon", {
    tagName: "div.category-icon-widget",
    html(attrs) {
      let iconItem = getIconItem(attrs.category.slug);
      let force_display = ('force_display' in attrs);
      if(iconItem && (!attrs.category.parent_category_id || force_display)) {
        let itemColor = iconItem[2] ? `color: ${iconItem[2]}` : "";
        let itemIcon = iconItem[1] != '' ? iconNode(iconItem[1]) : "";
        return h("span.category-icon", { "style": itemColor }, itemIcon);
      }
    }
  });

Do you see any way I can achieve the same result without this hack?
If not, would you consider add that in the code?

Thanks in advance.

2 Likes