Тип иконки SiteSetting

I am trying to add a SiteSetting to my plugin that can control the icons displayed for some components. The component itself was already going to be user customizable, so I wanted to add the SiteSetting as a way for staff to define the default icon. I know there is emoji_list type for SiteSettings, but there doesn’t seem to be one for SVG icons?

From what I can see, most plugins/TC use either image upload or plain string for icon settings. Am I missing a type/validator I can use? It feels weird to tell people to look up the styleguide and type the name of the icon.

3 лайка

I think it’s a case where we don’t have any icon based site settings, so we haven’t added a type for it. We have an icon picker component that’s made its way into other parts of the app, but nothing currently in site settings.

1 лайк

That makes sense. I can’t really imagine any specific scenario where core would require it, as probably only Themes/TCs and plugins would have a use for an extremely UI focused setting.

I am using the icon picker component in other places more easily accessible for ordinary users, but the specific use case I have in mind would be for stuff like setting a default icon. Combined with the object SiteSetting type, it would make templating certain features easier for admins.

Would the team be open to adding an icon_type type to SiteSettings in core, even without any core site settings using it? I don’t mind reopening this topic as a Feature request if need be.

1 лайк

Any update on this? I noticed that reactions will be added to core, and that plugin currently has the Discourse reactions like icon setting where you need to enter the icon name manually.

3 лайка

No plans at the moment, but maybe that’s a good opportunity for it. I’ll pass the idea along.

2 лайка

yea it would be great to be able to use this in component settings, especially object type settings - can this be added please?

similar request also mentioned here:

3 лайка

Теперь доступен тип иконки в настройках сайта.

7 лайков

Это здорово! Я предполагаю, что это можно использовать и для TC? Пора начать обновлять некоторые из них с помощью этого!

Я не уверен, что это так. Здесь нет типа иконки

Думаю, вы тоже не можете использовать тип настройки эмодзи из настроек сайта, например «Запрещённый список эмодзи», в темах.

По-моему, пока нет (по крайней мере, у меня не получилось заставить это работать).

Есть ли планы по поддержке type: icon внутри объектных схем для компонентов темы, например так?

    links:
        type: objects
        schema:
          name: menu_link
          identifier: text
          properties:
            icon:
              type: icon
              required: true
            text:
              type: string
              required: true
              validations:
                min_length: 1
                max_length: 100
            url:
              type: string
              required: true
              validations:
                min_length: 1
                max_length: 500
...
5 лайков