Support SVG icon in action menu#10757
Conversation
|
Hi there @bjarnef, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
|
I've looked at this a few times now and to be honest I'm not crazy about introducing new properties. I was thinking if we could check if the file with prefix |
|
@nul800sebastiaan yeah, not ideal but I think it is the only way without a breaking change since it currently expect the Ideally it should have required the full icon name, but it was not the case as it currently always expect |
|
@nul800sebastiaan another approach could be introducing an Not sure it is better or easier though. Currently the challence is that with the data passed in to the property, er don't know if the full icon name should be prefixed with |
…nto v8/feature/umb-content-menu-svg-icon # Conflicts: # src/Umbraco.Web.UI.Client/src/views/components/application/umb-contextmenu.html # src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html
|
@nul800sebastiaan I found a few places in code, which have Not a big deal with date picker, but context menu as fixed in this PR and For example @mattbrailsford might want to use These are the only places I have found, which is inconsistent. |
…nto v8/feature/umb-content-menu-svg-icon
Not sure that's an issue - getting all icons from IconService.GetAllIcons will return a cached dictionary, so overhead will be minimal. Dictionary is keyed by icon name, so |
|
@nathanwoulfe the chosen icon is specified in the controller. Ideally the full icon name would be specified, but it was not the case. If you wanted to use the icon This is different from pretty much all other part of UI where we deal with full icon name. So e.g. with "coffee-cup" it need to know if it should use |
|
@bjarnef gotcha. Sounds like a new property would be the way around this, like you suggested. Something to configure ignoring/removing the default icon- prefix |
|
@nathanwoulfe yeah, I think that if what we can do for now to support custom SVG and font icons, which may not be prefixed with We also have other parts in code regarding legacy format, Or try search on |
…nto v8/feature/umb-content-menu-svg-icon
|
@ronaldbarendse @madsrasmussen I have a few open PR regarding missing parts to support SVG icons, but unfortunely unlike other part of UI, these icons didn't included full icon name. So to support SVG and not break developers existing implementations of custom actions I have used Do you have any better suggestions to handle this? |
|
We could also keep this approach using |
|
FYI: we're not changing anything in the frontend for v9, we want existing |
|
That's fine :) But to solve this we still need a way to identify whether the icon is a core icon, custom font icon or SVG icon. Checking if the physical file exists on dish won't work for font icons. To avoid breaking existing stuff, it need to include I considered adding a |
|
@nul800sebastiaan is this still relevant. It seems no more new features will be added to v8, so it would be great if we close this if it isn't accepted for v8. Then we would settle for SVG icons can't be used for tree actions and property actions in v8 and consider implement this in v9. |
|
Hi there @bjarnef! Thanks for the contribution here and apologies if it has been a while since you heard from us. We have been in the very fortunate position of having lots of work to do. With this in mind, we are writing to let you know that with the release of the Long Term Support (LTS) version, 8.18, we have now moved into the support phase of Umbraco 8. You can read all about that here but to surmise, we will be keeping Umbraco 8 safe and well by releasing patching for security or regression issues if they arise but no longer will we do that for bug fixes. The same is still true for features, although we stopped merging those some time ago. We'd love for you to keep contributing and while we are not able to merge this to Umbraco 8, if this is still something you'd like to see in Umbraco 9, please take a look and either create an issue to say so or find an issue that already exists. We'll be happy to give you some input around how you can adjust your pull request to target Umbraco 9. Even better, it might be something that Umbraco 9 already does or has. In which case, enjoy! Once again, a huge thank you for the time you have spent working with us. #H5YR |
Prerequisites
Description
I noticed it wasn't possible to use a custom SVG icon in a custom action menu.
In
umb-editor-menuI also fixed a typo inseparator(I guess this part has never worked).Example code:
Icon only work with old font icons and not is using a custom SVG icon in App_Plugins folder. Another issue is that it expect the icons to contain
icon-in name, which it not neccessary has with a custom font icon or SVG icon.It would of course work if developers updated code from
Icon = "coffee"toIcon = "icon-coffee", but that would be a breaking change. In this case I have a custom SVG iconcoffee-cupwhere is it enough withIcon = "coffee", but won't in the view because of theicon-prefix unless I renamed it toicon-coffee-cup.svg.To make this work I have a property
UseLegacyIcon(true by default) toMenuItemto still work the old format and the new format.Maybe there's a better name for this like
UseCustomIconor something else, but we would need something to track if the current (old) format should be used or the new format. In pretty much all other part of Umbraco UI the icon property includesicon-in name, but not here.Before
After
I have attached the folder with the custom
coffee-cup.svgicon here, so extract this folder to App_Plugins:CustomIcons.zip