Category Icons

Yes sorry should have updated my post. I have figured out with Font Awesome had to add them to Setup.

And recently learned as you said need to create an svg sprite file to upload to icons-sprites.

Still learning a lot of new things. Appreciate the help in evolving my knowledge. Thank you

2 Likes

The category icons on our site have looked great, until I logged in today. it appears that the padding in between the icon and the category title has no padding, when displayed. Anyone else having this issue?

e.gā€¦

2020-03-17_21-45-10 (1)

3 Likes

Iā€™m seeing that as well, Iā€™m sure Penar will fix it, but for now this will fix it

.select-kit .select-kit-header .selected-name .name .d-icon {
    margin-right: .25em;
}
3 Likes

Thanks both, this should be fixed now.

8 Likes

Is it possible to use other icons that Font Awesome? My forum is about travelling and i need very specific icons that donā€™t exist there. Can we use a regular png icon file for example? as we do with categories? thanks!

3 Likes

You can use custom icons if you convert them to SVGs and add them to your theme via an SVG sprite. See the ā€œCreate an SVG spritesheetā€ section of this guide on how to add custom icons to your site which you can then use in this component (and throughout your Discourse site).

7 Likes

Works great!
Is it possible for me to tweak it so that the icon appears after the category title?
Bonus question: is it possible to add a tooltip/alt-text?

(Background: Iā€™m hiding the pad lock icon and instead use this component to add an icon to the few public categories I have. And I would like for users to have way to find out what the symbol stands for.)

1 Like

I am having trouble to use my custom icons. I didnā€™t get anything that could tell me should I use a prefix or not. Hereā€™s what I am doing.

Screenshot_23

Hereā€™s the SVG Iā€™m using - https://andronixforumupload.ams3.digitaloceanspaces.com/original/1X/bdabc28a604dc98bb25ce8af2ef6f8dc7c9f2626.svg

As you can see I canā€™t see the arch icon at all.

1 Like
  1. Create a SVG spritesheet: Replace Discourse's default SVG icons with custom icons in a theme
  2. In your theme component, upload your spritesheet and set the variable name to icons-sprite:
    image
  3. In the component settings, use the id of the desired icon from your spreadsheet. For example if I have an icon id named my-icon in my spreadsheet, I write this:
    image

Result:
image

6 Likes

@Canapin That doesnā€™t work. Hereā€™s my sprite file - Sprite File

The image id I am trying - Here

Hereā€™s what I am doing-


Am I doing something wrong?

1 Like

In your spritesheet, try replacing:

<svg width="0" height="0" class="hidden">

By:

<svg xmlns="http://www.w3.org/2000/svg">

Also there is no need to add the icon id in the svg icons setting fields all your custom icons are already availables from your uploaded spritesheet.

I believe svg icons setting is meant to load additional Font Awesome icons as Discourse only loads a defined, small set by default.

5 Likes

@Canapin Thank you! it worked like a charm. I have one more question though, is this sprite file exclusive to a particular component or I can access the icons with their ids anywhere?

2 Likes

When you upload a file to a used theme or a theme component, you can use it in any other, so I guess you can use your icon ids anywhere.

1 Like

Hey Penar, will this support the new Font Awesome Pro plugin? Or is there some way to use it already that Iā€™m missing? Thanks!

1 Like

It should work with the Pro plugin, yes. Are you seeing non-Pro svgs for category icons only?

2 Likes

Yes, after removing my sprite only the non-pro display. Also the non-pro do not follow the fa_icon_style setting for light icons, etc.

Hmm, this works fine on my local site.

image

Thatā€™s the cog icon, using the plugin with the ā€œLightā€ style selected. Compare that to the regular style below.

image

But maybe Iā€™m not checking the right thingā€¦ let me know if there is a specific icon that isnā€™t displaying correctly for you.

4 Likes

Hereā€™s an example with it set to light. Image Critiques has the icon comment-alt-edit and does not display (which is a pro icon), Image Showcase has the icon images which is not pro, but is displaying the regular version, not light. Discussions is showing the solid version of comments, and Community is showing the light version of users as expected.

I tried changing one of them to cog, and it works as expected with the proper light version, lots of oddness going on here!

2 Likes

Did you try with far-comment-alt-edit?

3 Likes

Okay I got it now, the key is having far- in the category icon list, not svg icons. So for light icons I have to change them all to fal- and it does not follow the site setting for fa icon style correct?

2 Likes