Skip to content

Clean up icons - #1099

Merged
hkdobrev merged 3 commits into
refined-github:masterfrom
niklashigi:clean-up-icons
Feb 20, 2018
Merged

hkdobrev merged 3 commits into
refined-github:masterfrom
niklashigi:clean-up-icons

Conversation

@niklashigi

Copy link
Copy Markdown
Contributor

While working on a new feature that required me to add a new icon I noticed that the source/libs/icons.js file was pretty messy and decided to clean it up.

To do that, I ...

  • removed the version attribute from all <svg> tags (user agents ignore it)
  • removed one occurrence of the xmlns attribute (user agents ignore it as well)
  • removed the viewBox attribute from <svg> tags when it was 0 0 [width] [height] (= redundant)
  • removed aria-label tag from all <svg> tags (icons can be used in multiple contexts)
  • added the aria-hidden attribute to all <svg> tags
  • removed the role attribute from all <svg> tags (useless with aria-hidden)
  • ordered the attributes (for consistency)

These changes make the file more readable and reduce the amount of code RGH inserts into the DOM.

@sindresorhus

sindresorhus commented Feb 19, 2018 •

Copy link
Copy Markdown
Member

Nice work!

Did you try running the icons through https://jakearchibald.github.io/svgomg/ or SVGo to see if we could minify them?

@fregante

Copy link
Copy Markdown
Member

I think they're already minified by GitHub

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

viewBox is necessary when we resize the SVGs via CSS. Rare but it happens. darkCompare for example has non-matching viewBox/width+height because it's used to align it better

@fregante fregante added the meta Related to Refined GitHub itself label Feb 19, 2018
@jgierer12

Copy link
Copy Markdown
Contributor

Not sure if we considered this before, but why are we not using the official octicons package for the icons?

@niklashigi

Copy link
Copy Markdown
Contributor Author

@sindresorhus It suggested making the <path> tags self-closing, so I did that.

@bfred-it I only removed viewBox from <svg> tags where viewBox and width and height were matching. Is viewBox still necessary in these cases?

@fregante

fregante commented Feb 19, 2018 •

Copy link
Copy Markdown
Member

Is viewBox still necessary in these cases?

Can you check all the icons across the extension to see if they've changed? 😄

I remember that it was needed at some point for the merge commits, but now that has changed #1052

However this might be a moot point if we follow @jgierer12's good suggestion, we can probably just require the SVG files directly if webpack is configured.

@niklashigi

niklashigi commented Feb 20, 2018 •

Copy link
Copy Markdown
Contributor Author

@bfred-it

Can you check all the icons across the extension to see if they've changed? 😄

Did it. I didn't notice any visual changes.

Screenshots of the "new" icons

During my "reasearch" (sarching for the icon names in the project) I also found that the mute icon is not used anywhere, so I removed it.

However this might be a moot point if we follow @jgierer12's good suggestion [...].

I would for now merge this (as it's definitely an improvement) and open a new issue (probably a good first issue?) to address the suggestion.

@hkdobrev hkdobrev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good work!

I think I'm at fault for directly including the source of the icons as early as #12. 😊

@hkdobrev
hkdobrev merged commit baacc31 into refined-github:master Feb 20, 2018
@fregante

Copy link
Copy Markdown
Member

When in doubt, blame @hkdobrev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

5 participants