Skip to content
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

Merged
merged 3 commits into from Sep 25, 2020

Conversation

Scotchester
Copy link
Contributor

@Scotchester Scotchester commented Sep 24, 2020

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 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. Curious if this rubs anyone the wrong way.


  • Do the tests still pass? (https://docs.wagtail.io/en/latest/contributing/developing.html#testing)
  • Does the code comply with the style guide? (Run make lint from the Wagtail root)
  • For Python changes: Have you added tests to cover the new/fixed behaviour?
  • 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?

@squash-labs
Copy link

squash-labs bot commented Sep 24, 2020

Manage this branch in Squash

Test this branch here: https://modeladmin-menu-item-svg-icons-ypjnd.squash.io

@Scotchester
Copy link
Contributor Author

Here's a screenshot of the bakerydemo running with these changes, updating the menu_icon to thumbtack for BreadModelAdminGroup and updating the menu_icon to resubmit for PeopleModelAdmin:

bakerydemo menu with SVG icons

Copy link
Member

@thibaudcolas thibaudcolas left a 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'
Copy link
Member

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).

Scotchester and others added 3 commits September 25, 2020 15:51
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.
@thibaudcolas thibaudcolas merged commit 70bb9d9 into master Sep 25, 2020
@thibaudcolas thibaudcolas deleted the modeladmin-menu-item-svg-icons branch September 25, 2020 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some icons from the styleguide not working in ModelAdmin
2 participants