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

Icon font to SVG migration part 1 #6107 #10277

Merged
merged 15 commits into from Mar 29, 2023

Conversation

thibaudcolas
Copy link
Member

@thibaudcolas thibaudcolas commented Mar 28, 2023

Assorted icon font -> SVG conversions as part of #6107. This is missing a few areas of the CMS still, which will come in a "part 2" (#10278). In particular workflows, ModelAdmin, and listings will be done in a separate PR.

This might be easier to review commit-by-commit – I’ll add comments directly in the PR for specific changes. At a high level:

  • Icons have been switched to inline SVGs where possible, and SVG mask-image where inline SVGs would be impractical.
  • Some icons will render with different alignment after this change. I’ve decided to not adjust styles here, as we are revising the visuals of almost all icons in Wagtail icon set should be extended and improved #2349, which will involve further alignment changes anyway.
  • There should be no backwards compatibility issues with those changes.

  • Do the tests still pass?[^1]
  • Does the code comply with the style guide?
  • [ ] 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 environments?[^2]
    • Please list the exact browser and operating system versions you tested: latest Chrome Safari Firefox on macOS 13.2
    • Please list which assistive technologies [^3] you tested: None
  • [ ] For new features: Has the documentation been updated accordingly?

@squash-labs
Copy link

squash-labs bot commented Mar 28, 2023

Manage this branch in Squash

Test this branch here: https://thibaudcolas6107-icon-font-par-654r4.squash.io

&:before {
display: none; // TODO: remove when iconfont styles are removed
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All dropdown chevron icons are already converted so this doesn’t need to wait.

width: 1em;
height: 1em;
display: inline-block;
background-color: currentColor;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in the icons looking more or less the same as before. I chose to keep those three "-after" icons done via CSS for two reasons:

  • So this keeps working for people implementing listings by copy-pasting Wagtail’s own listings.
  • So we introduce appropriate listing components in Universal listings roadmap#33

color: $color-grey-2;
border: 1px solid currentColor;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn’t used, and wasn’t documented in our list of available icons.

&:before {
font-size: 1.5em;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icon size defined via a reusable icon-specific class.

vertical-align: -10%;
content: map.get($icons, 'warning');
mask-image: url('#{$images-root}icons/warning.svg');
background-color: currentColor;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as -after icons – a lot of people have "error-message" directly referenced in their templates, and we don’t have a reusable component for this, so keeping the icon in CSS for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove that line above while we're in this code.

// UI-Redesign: to be added via js and styled here

And maybe the Todo note?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don’t understand what it’s about so sounds sensible to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's about how error message elements for StreamField are constructed? If I remember correctly, they're dynamically created on the client-side via JS as opposed to server-rendered.

@@ -113,7 +113,7 @@ describe('telepath: wagtail.blocks.ListBlock', () => {
icon: 'placeholder',
classname: null,
helpText: 'use <strong>a few</strong> of these',
helpIcon: '<div class="icon-help">?</div>',
helpIcon: '<svg></svg>',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of tests, helpIcon renders an SVG icon since quite a few releases ago. I chose to use an empty <svg> element as the exact markup is irrelevant here.

@@ -308,11 +308,8 @@ if (!wagtail.ui) {
const DROPDOWN_SELECTOR = '[data-dropdown]';
const LISTING_TITLE_SELECTOR = '[data-listing-page-title]';
const LISTING_ACTIVE_CLASS = 'listing__item--active';
const ICON_DOWN = 'icon-arrow-down';
const ICON_UP = 'icon-arrow-up';
const IS_OPEN = 'is-open';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was all dead code. Dropdown up/down chevrons had already been rewritten to use the is-open class only to determine which icon to show.

@@ -4,7 +4,7 @@
{% block titletag %}{% blocktrans trimmed with title=subtitle %}Page history for {{ subtitle }}{% endblocktrans %}{% endblock %}

{% block actions %}
<a href="{% url 'wagtailadmin_pages:edit' page.id %}" class="button bicolor icon icon-edit">{% trans "Edit this page" %}</a>
<a href="{% url 'wagtailadmin_pages:edit' page.id %}" class="button bicolor button--icon">{% icon name="edit" wrapped=1 %}{% trans "Edit this page" %}</a>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note on wrapped=1 – not the nicest API but essentially this is needed for button--icon buttons. The buttons look bigger like this than with the icon font, which we’ve accepted in other parts of the UI.

height: 100%;
vertical-align: middle;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those have been replaced with the same -after ordering icons as other listings.

@@ -44,8 +44,9 @@
{% endblock fields %}

<li>
<a href="#tab-roles" data-tab-trigger class="button lowpriority icon icon-arrow-right-after">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn’t find a reference to lowpriority anywhere else.

Copy link
Member

@lb- lb- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a smoke test of all icon scenarios changed - did not see any issues. One minor comment.

Happy to approve but I see there are some CI items to fix still.

vertical-align: -10%;
content: map.get($icons, 'warning');
mask-image: url('#{$images-root}icons/warning.svg');
background-color: currentColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove that line above while we're in this code.

// UI-Redesign: to be added via js and styled here

And maybe the Todo note?

@thibaudcolas
Copy link
Member Author

Thank you @lb-! The CI failures are just because I’ve cancelled the GitHub Actions builds, it’s all green in CircleCI (which is all that’s relevant for this kind of change)

@thibaudcolas thibaudcolas merged commit b504403 into wagtail:main Mar 29, 2023
4 of 7 checks passed
@thibaudcolas thibaudcolas deleted the 6107-icon-font-part-1 branch March 29, 2023 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants