Move all the icons to CSS backgrounds

Created on 3 August 2023, 11 months ago
Updated 28 August 2023, 10 months ago

Problem/Motivation

Right now all the icons are embedded SVGs into the HTML. But in core we don't have a way to tie SVG to menu items, so the only way we'll have to provide icons for now will be the existing solution in the toolbar: with CSS backgrounds.

Proposed resolution

Move all SVG to CSS backgrounds with an strategy close to what the existing Toolbar uses.

๐Ÿ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ckrina
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    Moving to minor since it won't be necessary for testing purposes.

  • Assigned to claireristow
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada claireristow

    Working on this now

  • @claireristow opened merge request.
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada claireristow

    Hey @ckrina, do you mind doing a quick review of my work? I'm wondering if you're ok with the mask-image approach I took for hover color changes or if you'd prefer to have multiple color versions of the icons, or if there's another option entirely!

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    @claireristow nice work!

    About the mas itself, I personally think itโ€™s a really good modern strategy to avoid what core is currently doing by storing the same icon in several colors. This is assuming all icons will be monochromatich, which Iโ€™d say itโ€™s a safe assumption. It is also good because itโ€™ll let us play with accent colors in the future letting us customize the admin UI colors. So unless anybody else has more insights I donโ€™t oversee any problem with this,

    The only thing I'd change here is that I would use a BEM pattern to name icons, and use each icon name as a modifier. From navigation-icon-media Iโ€™d convert it to navigation-linkโ€”media.

    You can see an example in action-link.pcss.css.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US
  • ๐Ÿ‡ช๐Ÿ‡ธSpain ckrina Barcelona

    Make sure if the SVGs are inlined into the CSS, you abstract them to a CSS variable (so the long SVG doesn't get output twice). Also keep in mind you'll pretty much always want to use them in pseudo-classes because the mask covers up everything else.

    This is @mherchel feedback in Slack :)

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada claireristow

    Thanks for the feedback @ckrina and @mherchel, I'll work on those changes!

  • Issue was unassigned.
  • Status changed to Fixed 10 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada claireristow

    Merged updates to BEM-style classes and setup CSS variables for icons!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024