Project

General

Profile

Actions

Feature #23980

open

Replace images with icon fonts or SVG images

Added by Marius BĂLTEANU almost 8 years ago. Updated 7 days ago.

Status:
New
Priority:
Normal
Category:
UI
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Icon fonts have some advantages over the classical images:
- being vector graphics, they are scalable an can be resized without losing quality.
- can be customized directly from CSS (size, colour, etc)
- less HTTP requests to server because they are loaded only with one or a few requests. Now, Redmine make a request for each image.
- some of the current custom themes already use icon fonts (Abacus theme, Minelab, PurpleMine2, our custom theme and I think the theme from plan.io).

We're interested to contribute with a patch that implements the FontAwesome icons, but because there are at least two ways to implement them, we want some feedback before from Redmine contributors and/or users.

1. Using i tags:

Advantages:
  • Is the recommended way on their official page
  • We can use all the build-in rules available in the FontAwesome CSS.
Disadvantages:
  • it'll be required to add the i elements in views.

2. Only from css

Advantages:
  • the views will not be modified
Disadvantages:
  • The build-in rules must be reimplemented in the current CSS
  • The icons will be defined using their unicode. For example, the fa-pencil icon (similar with the current images for icon-edit) has the unicode f040.

Only for demo purposes, I've attached a patch that replaces the icons from issue page with font awesome icons (using i tags).


Files

font_awesome_icons.patch (15.3 KB) font_awesome_icons.patch Marius BĂLTEANU, 2016-10-04 02:06
font_awesome.png (263 KB) font_awesome.png Marius BĂLTEANU, 2016-10-04 02:19
use_font_awesome_icons_for_all_elements_that_use_icon_class.patch (399 KB) use_font_awesome_icons_for_all_elements_that_use_icon_class.patch Marius BĂLTEANU, 2016-10-09 12:11
replace_images_with_fa_icons.patch (15 KB) replace_images_with_fa_icons.patch Marius BĂLTEANU, 2016-11-29 01:33
font-mfizz.zip (243 KB) font-mfizz.zip Marius BĂLTEANU, 2016-11-29 02:05
fonts_folder.png (92.8 KB) fonts_folder.png Marius BĂLTEANU, 2016-11-29 02:06
admin_fa.png (142 KB) admin_fa.png Marius BĂLTEANU, 2016-11-29 02:09
issue_fa.png (236 KB) issue_fa.png Marius BĂLTEANU, 2016-11-29 02:09
activity_fa.png (293 KB) activity_fa.png Marius BĂLTEANU, 2016-11-29 02:09
overview_fa.png (191 KB) overview_fa.png Marius BĂLTEANU, 2016-11-29 02:10
projects_fa.png (124 KB) projects_fa.png Marius BĂLTEANU, 2016-11-29 02:10
issues_fa.png (319 KB) issues_fa.png Marius BĂLTEANU, 2016-11-29 02:10
repository_fa.png (324 KB) repository_fa.png Marius BĂLTEANU, 2016-11-29 02:10
roadmap_fa.png (211 KB) roadmap_fa.png Marius BĂLTEANU, 2016-11-29 02:10
replace_images_with_fa_icons_v2.patch (15.6 KB) replace_images_with_fa_icons_v2.patch Marius BĂLTEANU, 2016-11-29 02:40
gitlab.png (50.4 KB) gitlab.png Marius BĂLTEANU, 2019-05-20 08:46
before.png (50.5 KB) before.png Marius BĂLTEANU, 2019-09-25 21:45
after.png (43.6 KB) after.png Marius BĂLTEANU, 2019-09-25 21:45
issue.png (114 KB) issue.png Marius BĂLTEANU, 2021-10-10 20:15
0001-Replace-icon-images-with-inline-SVG-icons.patch (29.8 KB) 0001-Replace-icon-images-with-inline-SVG-icons.patch Marius BĂLTEANU, 2021-10-10 20:16
0001-Add-tag-helper-patch.patch (31.5 KB) 0001-Add-tag-helper-patch.patch Takashi Kato, 2022-03-21 22:31
0002-Add-svg-icons.patch (98.7 KB) 0002-Add-svg-icons.patch Takashi Kato, 2022-03-21 22:31
0003-Support-expand-collapse-with-svg-icons.patch (21.8 KB) 0003-Support-expand-collapse-with-svg-icons.patch Takashi Kato, 2022-03-21 22:32
0004-Support-jsToolbar.patch (7.77 KB) 0004-Support-jsToolbar.patch Takashi Kato, 2022-03-21 22:32
0005-Replace-tags-with-helper.patch (19.3 KB) 0005-Replace-tags-with-helper.patch Takashi Kato, 2022-03-21 22:32
0006-Add-a-temporary-svg-icon-to-the-plugin-template.patch (2.04 KB) 0006-Add-a-temporary-svg-icon-to-the-plugin-template.patch Takashi Kato, 2022-03-21 22:33
svg-icon.png (325 KB) svg-icon.png Takashi Kato, 2022-03-21 22:37
css#mask.png (163 KB) css#mask.png Marius BĂLTEANU, 2024-07-15 01:27
svg#use.png (566 KB) svg#use.png Marius BĂLTEANU, 2024-07-15 01:28

Related issues

Related to Redmine - Feature #5830: Replace famfamfam icons with the fugue setNew2010-07-07

Actions
Related to Redmine - Feature #11757: Add support for HDPI screens (retina)New

Actions
Related to Redmine - Feature #30229: Optimization: all UI icons collapsed into a single spriteClosed

Actions
Actions #1

Updated by Marius BĂLTEANU almost 8 years ago

Marius BALTEANU wrote:

2. Only from css

Advantages:
  • the views will not be modified
Disadvantages:
  • The build-in rules must be reimplemented in the current CSS
  • The icons will be defined using their unicode. For example, the fa-pencil icon (similar with the current images for icon-edit) has the unicode f040.

The "disadvantages" word should be after the first advantage. Like is in this comment.

Actions #2

Updated by Marius BĂLTEANU almost 8 years ago

Attached a screenshot also.

Actions #3

Updated by Jan from Planio www.plan.io almost 8 years ago

Hi Marius, thanks for proposing this. I think replacing the current icon set with an icon font is a great idea. As you noticed, we're using Font Awesome for the new Planio design.

Marius BALTEANU wrote:

because there are at least two ways to implement them, we want some feedback

Before implementing our new design, we were discussing this intensively. We decided against using <i> tags and in favour of adding new CSS rules, for the following reasons:

  • Changing all icons in Redmine to <i> tags would be a very large patch touching almost all views in Redmine (as you probably already noticed while preparing your demo patch).
  • Using <i> tags would require all plugin developers to change plugins as well and there would be a (potentially long) period where plugins would still use the "old" icons while Redmine is already usig "new" icons making the overall user experience inconsistent.

Implementing new CSS rules for all icons using Font Awesome, however, would be less of a change to existing Redmine code (we would be able to leave views alone) and would apply to all existing plugins using standard Redmine icons (like edit, delete, etc.) at once, so plugin developers would have few things to change or nothing at all.

To respond to the disadvantages mentioned:

The build-in rules must be reimplemented in the current CSS

I actually see this as an advantage: implementing Icon style can be encapsulated in a defined place within the CSS and does not happen all over the place.

The icons will be defined using their unicode. For example, the fa-pencil icon (similar with the current images for icon-edit) has the unicode f040.

From our experience in working with Font Awesome in our new UI, it isn't much of a problem. The icons can be looked up easily via http://fontawesome.io/icons/ and we could use CSS comments to note the Font Awesome icon names next to the unicodes.

One sidenote: At Planio, we're using Rails' Asset Pipeline with Redmine and are thus using SCSS and the fontawesome-rails gem which is a tremendous help.

Actions #4

Updated by Marius BĂLTEANU almost 8 years ago

Jan from Planio www.plan.io wrote:

Hi Marius, thanks for proposing this. I think replacing the current icon set with an icon font is a great idea. As you noticed, we're using Font Awesome for the new Planio design.

Marius BALTEANU wrote:

because there are at least two ways to implement them, we want some feedback

Before implementing our new design, we were discussing this intensively. We decided against using <i> tags and in favour of adding new CSS rules, for the following reasons:

  • Changing all icons in Redmine to <i> tags would be a very large patch touching almost all views in Redmine (as you probably already noticed while preparing your demo patch).
  • Using <i> tags would require all plugin developers to change plugins as well and there would be a (potentially long) period where plugins would still use the "old" icons while Redmine is already usig "new" icons making the overall user experience inconsistent.

Implementing new CSS rules for all icons using Font Awesome, however, would be less of a change to existing Redmine code (we would be able to leave views alone) and would apply to all existing plugins using standard Redmine icons (like edit, delete, etc.) at once, so plugin developers would have few things to change or nothing at all.

To respond to the disadvantages mentioned:

The build-in rules must be reimplemented in the current CSS

I actually see this as an advantage: implementing Icon style can be encapsulated in a defined place within the CSS and does not happen all over the place.

The icons will be defined using their unicode. For example, the fa-pencil icon (similar with the current images for icon-edit) has the unicode f040.

From our experience in working with Font Awesome in our new UI, it isn't much of a problem. The icons can be looked up easily via http://fontawesome.io/icons/ and we could use CSS comments to note the Font Awesome icon names next to the unicodes.

Totally agree with you, I'll try to create a patch using only CSS.

One sidenote: At Planio, we're using Rails' Asset Pipeline with Redmine and are thus using SCSS and the fontawesome-rails gem which is a tremendous help.

I know that were some discussions about the Rails' Asset Pipeline (I can't find the ticket now) and enabling this feature is not an option because will add some complexity. If I'm wrong, I'll be very happy to use that gem.

Thanks for your feedback.

Actions #5

Updated by Marius BĂLTEANU almost 8 years ago

I've attached a first patch which:
  • adds the Font Awesome fonts
  • replaces the images icons with font awesome icons for all elements that have icon and icon-* classes

Some observations:

1. Currently, there are some specific programming images for file types like text-x-php, text-x-c, text-x-java and so on. Because FontAwesome doesn't have these types of icons, I see 3 ways to solve this problem:
1.1 use the current images
1.2 use the generic file code icon provided by FontAwesome for all of these files.
1.3 add Font-Mfizz which is an extension of FontAwesome icons and provides the required icons.

IMHO, I prefer the second solution because:
  • it doesn't add new fonts
  • it doesn't require to keep the rules related to background images in icon class
  • it doesn't require maintenance when a new type of files appears (in this patch I've added a new class named "application-javascript" in order to recognize the javascript files)

2. I'll add separate patches that replaces the current images with FontAwesome icons in other pages like: administration, project overview, etc..
3. In the last patch, I'll remove the unused images.

Any feedback is appreciated.

Actions #6

Updated by Alexander Meindl almost 8 years ago

I would prefer the Font-Mfizz solution. It does not require much more server load using it (there are a lot less server requests compared to the background image solution). Main reason for this solutions is, that the usability and the user acceptance would be higher. A lot of technical teams are working with Redmine and SCM, and these people will be certainly happy to see file type specific icons.

Actions #7

Updated by Toshi MARUYAMA over 7 years ago

  • Description updated (diff)
Actions #8

Updated by Marius BĂLTEANU over 7 years ago

We discussed internally in Zitec and we are going to implement the solution with Font-Mfizz but for the moment we are waiting for some feedback on issue #24313 because having that ticket commited, it will be much easier for us to implement this one.

Actions #9

Updated by Go MAEDA over 7 years ago

  • Related to Feature #5830: Replace famfamfam icons with the fugue set added
Actions #10

Updated by Go MAEDA over 7 years ago

  • Target version set to Candidate for next major release

#24313 has been implemented.
I am looking forward to seeing this feature in 3.4.0. Setting target version to "Candidate for next major release".

Actions #11

Updated by Marius BĂLTEANU over 7 years ago

Go MAEDA wrote:

#24313 has been implemented.
I am looking forward to seeing this feature in 3.4.0. Setting target version to "Candidate for next major release".

The patch that replaces the images with fa icons is ready, but I want to take some feedback from our users regarding the icons color. Now all the icons have the same color (# 169). Please let me know if you want to test it as it is now.

Actions #12

Updated by Marius BĂLTEANU over 7 years ago

The attached patch (replace_images_with_fa_icons.patch) replaces the images for all regular icons (that have the classes "icon icon-*") with font-awesome icons.

Because the git binary diffs are not supported by the patch command, I wasn't able to add the required fonts as patches, but I've documented bellow the necessary steps:
1. Create a folder fonts in the public directory from redmine.
2. Unzip the attached font-mfizz.zip in the new fonts folder.
3. Because the font-awesome archive is bigger than the maximum allowed size for attachments (600kb), the zip can be downloaded from here. If the official link is preferred, the fonts must be extracted from the archive (folder fonts) to a folder named font-awesome in the same folder fonts from public directory.

At the end, the fonts folder from public should have 2 directories:
  • font-awesome
  • font-mfizz

There are still some elements that are using images (like classes expander, asc, desc), but I think that is safer to replace them with FA icons in another ticket (requires more changes). Also, I think the images should be removed in a later major release (for plugins compatibility).

Any feedback on the chosen icons is welcome.

Actions #14

Updated by Marius BĂLTEANU over 7 years ago

Updated to include a fix for the responsive mode (the left padding is no more required).

Actions #15

Updated by Marius BĂLTEANU over 7 years ago

Any feedback on this patch? FTR, I tried to create a single patch with all the changes with Subversion too but it didn't work.

Actions #16

Updated by Go MAEDA over 7 years ago

  • Assignee set to Jean-Philippe Lang

Screenshots looks nice for me.
Jean-Phillipe, is there any possibility that this patch will be merged?

Actions #17

Updated by Marius BĂLTEANU over 7 years ago

Jean-Philippe, do you have any feedback on this?

Actions #18

Updated by Go MAEDA over 7 years ago

  • Related to Feature #11757: Add support for HDPI screens (retina) added
Actions #19

Updated by Bernhard Rohloff over 6 years ago

This patch is a great improvement to Redmine. It extends the variety of icons available to developers of plugins and Redmine itself. It's a pitty that there hasn't been more discussion about this improvement for a year now.

Unfortunately this patch doesn't work anymore.
Marius Ionescu BALTEANU is it possible to update this patch to a recent revision of Redmine? I would really love to see this patch applied in 4.0.0 or 4.1.0.

+1 for this!

Actions #20

Updated by Marius BĂLTEANU over 6 years ago

Bernhard Rohloff wrote:

Marius Ionescu BALTEANU is it possible to update this patch to a recent revision of Redmine? I would really love to see this patch applied in 4.0.0 or 4.1.0.

Sure, I'll try to do it this month (including the update to Font Awesome 5).

Actions #21

Updated by Anonymous over 6 years ago

GitHub changed from Icon fonts to SVG icons.
Icon fonts is not bad, but I think it will be better if you change to SVG icons.

Actions #22

Updated by Bernhard Rohloff over 6 years ago

Taiki IKEGAME wrote:

GitHub changed from Icon fonts to SVG icons.
Icon fonts is not bad, but I think it will be better if you change to SVG icons.

This also sounds very interesting to me and seems to be more versatile than icon fonts. It could be nice to load custom icons in a plugin and use them with the same helper method as the core icons. Or just to install a custom icon pack as a plugin. Just a few thoughts. I'm not so well informed about this topic right now. So are there some other opinions about preferring SVG icons over icon fonts?

Actions #23

Updated by Anonymous over 6 years ago

Fontawesome 5 recommends JS with SVG.
Sorry for not checking well.

Actions #24

Updated by Anonymous over 5 years ago

Yey! This asap pls!
+1

Actions #25

Updated by Marius BĂLTEANU over 5 years ago

  • Related to Feature #30229: Optimization: all UI icons collapsed into a single sprite added
Actions #26

Updated by Marius BĂLTEANU over 5 years ago

Max Johansson wrote:

Yey! This asap pls!
+1

Max, I'll be very happy to update my patch if Jean-Philippe agrees to replace the current icons with FA icons.

Actions #27

Updated by Anonymous over 5 years ago

Marius,
Jean-Philippe, could you please let us know your opinion about this?

Actions #28

Updated by Anonymous over 5 years ago

Marius, maybe it will be easier to update the patch and sneak-commit it with help of Go? Then we could cross fingers and hope that Jean-Philippe might not notice it :D

Actions #29

Updated by Go MAEDA over 5 years ago

Max Johansson wrote:

Marius, maybe it will be easier to update the patch and sneak-commit it with help of Go?

I will not commit such a big change without Jean-Philippe's consent. I never forget that he is the owner of this software and we can use Redmine thanks to him and his many years of efforts.

Actions #30

Updated by Jan from Planio www.plan.io over 5 years ago

Go MAEDA wrote:

I will not commit such a big change without Jean-Philippe's consent. I never forget that he is the owner of this software and we can use Redmine thanks to him and his many years of efforts.

Absolutely agree!

Actions #31

Updated by Bernhard Rohloff over 5 years ago

Basically I agree with Go and Jan. It's not an option to make decisions behind JP's back. As much as I share this opinion I can understand Max's intention. This issue is nearly three years old and no decisions are made. So has anybody a better idea on how to get at least a yes, no, maybe from Redmine's kahuna?

Actions #32

Updated by Anonymous over 5 years ago

So has anybody a better idea on how to get at least a yes, no, maybe from Redmine's kahuna?

I guess the only way I could come up with is to bump this ticket with a message mentioning JPL and urgent to be visible in the activity log of Redmine.org next time a commit streak from JPL will occur. And it can be detected with help of #redmine-commits channel on our Discord, but if RSS tracker bot will not logout again (Discord been having problems with bots logging out lately, but they are working on fixing it afaik) and there will be anyone available or online to bump this message in that perfect moment :)

Actions #33

Updated by Anonymous over 5 years ago

Bump! Jean-Philippe, this ticket is ultra-urgent to many, please share your consent.

Actions #34

Updated by Marius BĂLTEANU over 5 years ago

Max Johansson wrote:

Bump! Jean-Philippe, this ticket is ultra-urgent to many, please share your consent.

Max, let be honest, it is not so ultra-urgent, it is just a nice UI improvement for the core and for the theme developers. I'll update my patch to Font Awesome 5 and then I'll share my thoughts regarding this feature.

Actions #35

Updated by Marius BĂLTEANU over 5 years ago

But I partially agree, a feedback from Jean-Philippe could be useful to not work in the wrong direction.

Actions #36

Updated by Marius BĂLTEANU about 5 years ago

Here is an updated version of my patch. Because the size of the patch is too big, you need to download it from my gitlab instance (screenshot attached for those who are not familiar with GitLab - gitlab.png).

The patch includes now the latest version of Font Awesome (5.8.2) and replaces the images with font icons only for elements with 'icon icon-*' classes. I'll add very soon another patch for the rest of the elements.

Please test it and let me know what do you think.

Actions #37

Updated by Go MAEDA about 5 years ago

Marius BALTEANU wrote:

Here is an updated version of my patch.

Since the page requires authentication, I could not get the patch.

Actions #38

Updated by Marius BĂLTEANU about 5 years ago

Go MAEDA wrote:

Marius BALTEANU wrote:

Here is an updated version of my patch.

Since the page requires authentication, I could not get the patch.

Sorry, I didn't know that the project is private. I made it public now, you should have access.

Actions #39

Updated by Marius BĂLTEANU about 5 years ago

  • Target version changed from Candidate for next major release to 4.1.0

I've have updated my patch to include the latest changes made in #31433 and #31496.

Considering that most of the icons are now replaced with font awesome icons, I'm assigning this to 4.1.0 in order to take a feedback from Jean-Philippe.

There are still some images that can be replaced with FA icons, but we can do it in a later version. I'm really sure that it'll be a great improvement to deliver this for everyone (users, theme developers, plugin developers, 3rd party saas providers like Plan.io).

Actions #40

Updated by Mizuki ISHIKAWA almost 5 years ago

+1

I hope this feature will be released as soon as possible.
The current icon is hard to see due to its small size and is not kind to the user.

Actions #41

Updated by Marius BĂLTEANU almost 5 years ago

Updated the patch and added a new commit to replace the images from JS Toolbar with FA icons.

Toolbar with current images:

Toolbar with FA icons*:

*The icons for Inline code, H1, H2 and H3 are not really icons because FA doesn't have such icons, are just text.

The patches (2 commits) can be found here.

Actions #42

Updated by Jean-Philippe Lang over 4 years ago

  • Target version changed from 4.1.0 to 5.0.0

This is a major change for plugins and themes, reassigning to 5.0.

Actions #43

Updated by Marius BĂLTEANU over 3 years ago

  • Assignee changed from Jean-Philippe Lang to Marius BĂLTEANU
Actions #44

Updated by Marius BĂLTEANU about 3 years ago

I've started to look again on this and I think it's better to move from icon fonts to svgs if we really do this step. Most of the major apps that I use did this and Github wrote a very nice article about this (https://github.blog/2016-02-22-delivering-octicons-with-svg/).

I will post in a few days a PoC for this change which allows easy customisation by plugin developers or to keep the existing functionality.

Actions #45

Updated by Marius BĂLTEANU almost 3 years ago

I made a demo patch that adds SVGs instead of icon fonts for issue page: ​
  • rendering SVG inline (in HTML) make them fully customisable from CSS (size, fill, stroke, etc)
  • added a Helper class to render all icons/SVGs. This means that are easily customisable/extendable.
  • plugin developers can use this new class to render the icons using the existing SVGs or they can add new SVGs
  • the SVGs used are from Font Awesome (latest 5.* version).

Actions #46

Updated by Bernhard Rohloff almost 3 years ago

Marius BALTEANU wrote:

I made a demo patch that adds SVGs instead of icon fonts for issue page: ​

Marius I've tested your patch. IMHO it looks really nice. I would love to see this landing in v5.0.0.

Actions #47

Updated by Mizuki ISHIKAWA over 2 years ago

Marius BALTEANU wrote:

I made a demo patch that adds SVGs instead of icon fonts for issue page

That looks very good.

I know of a few themes that replace icon images with icon fonts.
For those themes, you can continue to use your own icons without making any major changes by applying the following CSS.

.icon-svg svg {display: none;}

This change looks like it could be released without breaking the theme too much.

Actions #48

Updated by Marius BĂLTEANU over 2 years ago

  • Target version changed from 5.0.0 to Candidate for next major release
Actions #49

Updated by Takashi Kato over 2 years ago

I'm very much looking forward to its introduction.

Although svg icons may require more effort than icon fonts, they can be implemented using only standard technology.

On the other hand, I see the following issues with the current proposal (I understand that the attached patch is for verification purposes).

  1. Inline svg images do not cache svg files.
  2. The new helper would require significant modifications, including plugins.
  3. We need a mechanism to add icons in themes and plugins.
  4. We need a way to add/remove svg icons with javascript.
  5. It is tedious to check and obtain updates of external resources that distribute svg icons.

I am attaching patches to solve the problem. Icons are from fontawesome and material design using a service called iconify. Note that it does not work in IE11.

For consistency of icons with themes and plugins, this feature can be disabled in the configuration file. After applying patches, We must set `config.redmine_enable_svg_icon` to true in "config/application.rb" to enable it.

1 Inline svg images do not cache svg files.

  • We can use svg from another file by adding a symbol element to svg and using "href" in the use element.
  • Stylesheets can control the size and the color of the icons.

2 The new helper would require significant modifications, including plugins.

  • I patched to tag helper to add icons, check classes and add necessary svg icons if icon class or icon-only class is present.
  • link_to and content_tag do not need to be modified since they use the tag helper internally.
  • Rewrite the part of the html in the view with a helper (we must notify the plugin authors).

3 We need a mechanism to add icons from themes and plugins.

  • Prepare common.yml ("class name ⇒ svg" correspondence).
  • common.yml prepared by plugin and theme will be merged into icon data in Redmine at startup.
  • svg icon is generated by default when We generate a new plugin.

4 We need a way to add/remove svg icons with javascript.

  • create addSVGIcon and removeSVGIcon method.
  • It is necessary to announce to plugin/theme authors that the method of toggling icon display by simply adding/removing CSS classes is not available.

5. It is tedious to check and obtain updates of external resources that distribute svg icons.

  • rake icon:fetch to fetch required icons at once.

patches can be applied to r21487

Actions #50

Updated by pasquale [:dedalus] 8 months ago

Marius BĂLTEANU Go MAEDA
I think that modernizing the graphic aspect of redmine is a way to increase its diffusion. This ticket has been stalled since version 3.4. The default theme icons are really outdated. Is it possible in your opinion to foresee a release in version 6.0?

Actions #51

Updated by Marius BĂLTEANU 7 days ago

  • Tracker changed from Patch to Feature
  • Subject changed from Replace images with icon fonts to Replace images with icon fonts or SVG images

Thanks, Takashi, for the patch series. I like your solution, but at the same time, it adds some code complexity that I'm not sure is really necessary.

I've started working on this again, as I really want to ship this change in Redmine 6.0.0. However, after multiple attempts in my environment (all based on SVG icons), I'm still unsure which is the best solution, so I would appreciate to get some feedback.

I'm splitting the discussion in two points:

1. How to fetch/update the SVG icons

1.1 The easiest way is to add all the SVG icons from the Font Awesome free pack (or another set like Heroicons) to app/assets/images/.
Advantages:
  • Very easy to update: we just need to replace all the existing icons with the new versions
  • It will be very easy for theme/plugin developers to use the icons that are part of the pack (FA 6.5.2 offers 1,555 icons)
Disadvantages:
  • The codebase increases by 1,555 icons, and many of them probably won't be used
  • To render the SVG icons inline, it will be necessary to add the naming from the icon set to the core code. For example, the name of the image for icon-edit is currently edit.png, but in FA it will be pencil.svg. In the future, if we want to move to another icon set (which is less likely), a lot of changes will be required again. Also, plugin/theme developers should learn which image to use for each icon. To avoid this, he have the second option inspired from Takashi patch:
1.2 Add a rake task (available only in development mode) to fetch the images and save them using the naming from Redmine based on a mapping. So instead of pencil.svg to have edit.svg.
Advantages:
  • Still very easy to update the icons or migrate to another icon set
  • We keep or own naming so it will be easy to know what to use
  • We ship only the icons required by Redmine core. The rake task can be used by themes/plugins in their scope as well so each plugin / theme will have their own mapping to fetch the icons
  • Depending on how we will render the SVG icons, we can extend the rake task to generate a sprite for each mapping (Redmine core will have a sprite with all SVG images, plugin A will have its own sprite and so on) where the ID is the actual icon class.
Disadvantages:
  • I don't see a real disadvantage, maybe only the work required to develop and maintain this rake task and all the cases.

My conclusion after all the tests I made is to go with the second solution.

2. How to render the SVG icons
I experimented two options, one that requires only CSS changes and another one that requires to touch all the files that contain icons.

2.1 Use CSS mask with ::before pseudo-element to render the icon
Advantages:
  • It requires to change only the CSS lines related to icons
  • We keep all the existing classes
  • Very easy to maintain / extend / override by theme / plugins developers
  • Icons are cacheable by the browser
Disadvantages:
  • The mask attribute is newly available and it may not work as expected on some old browsers
  • I didn't find an easy way to not break the icons that have not been updated

2.2. Render the SVG inline
Initially (as I proposed three years ago), I tried to render the SVG fully inline, but I gave up in the last weeks because I don't find it elegant to render all the content of the SVG in the HTML markup. What I tried and liked is to render only the SVG tag with use to reference the icon.

Advantages:
  • Is fully supported by the browser
  • The icons are cacheable by the browser
  • It works nicely in parallel with the old icons
Disadvantages:
  • It requires to modify all the files that contain code related to icons

Because I'm not very sure about the CSS mask attribute, I fell like we should have SVG sprites generated with a rake tasks (1.2) rendered inline using svg and use. Also, if we still have to change a lot of files, we will introduce helper methods to render the icons with labels and to make it easier to improve this in the future.

I'll post soon some working code for the above solution.

As a side note, for sure I didn't cover all the advantages / disadvantages of each solution.

Actions #52

Updated by Marius BĂLTEANU 7 days ago

SVG icons with CSS mask attribute:

SVG icons rendered inline using svg and use:

Actions

Also available in: Atom PDF