New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SVG icons in ModelAdmin menu items #6402
Conversation
Manage this branch in SquashTest this branch here: https://modeladmin-menu-item-svg-icons-ypjnd.squash.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, thank you. Very nice touch to have the backwards compatibility with FontAwesome as well.
- I’ve made a small note of a documentation update I will need to do as part of merging this.
- I wondered whether there should be tests for this, would say yes ideally, but there are no existing tests for any of this so this doesn’t feel strictly needed.
@@ -599,7 +599,7 @@ def get_app_label_from_subitems(self): | |||
return '' | |||
|
|||
def get_menu_icon(self): | |||
return self.menu_icon or 'icon-folder-open-inverse' | |||
return self.menu_icon or 'folder-open-inverse' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: will need a corresponding doc update (cosmetic).
Support is already present in the MenuItem and SubmenuMenuItem classes that ModelAdminMenuItem and GroupMenuItem subclass (and their respective templates), but those two subclasses needed to be updated to pass the new `icon_name` kwarg. This commit retains support for the popular wagtail-fontawesome package by checking for `menu_icon` properties beginning with `fa-`, and following the same old `classname` logic as before. If that's not found, it sets the `icon_name` kwarg which triggers the SVG icon rendering in the template.
37dd567
to
8f6230d
Compare
Fixes #6379
Support is already present in the MenuItem and SubmenuMenuItem classes that ModelAdminMenuItem and GroupMenuItem subclass (and their respective templates), but those two subclasses needed to be updated to pass the new
icon_name
kwarg.This commit retains support for the popular wagtail-fontawesome package by checking for
menu_icon
properties beginning withfa-
, and following the same oldclassname
logic as before. If that's not found, it sets theicon_name
kwarg which triggers the SVG icon rendering in the template. Curious if this rubs anyone the wrong way.make lint
from the Wagtail root)For front-end changes: Did you test on all of Wagtail’s supported browsers? Please list the exact versions you tested.For new features: Has the documentation been updated accordingly?