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

fix(svg-icons): icon size consistency #8380

Merged
merged 7 commits into from
Aug 17, 2023
Merged

Conversation

amtins
Copy link
Contributor

@amtins amtins commented Jul 28, 2023

Description

This PR fixes the size of svg icons using the font size of the various components as a reference size, to bring consistency between font icons and svg icons.

Specific Changes proposed

  • icons.svg the icons have been regenerated from the svg files in videojs/font
  • .vjs-svg-icon uses the same reference value from the font size of font icons to define the default height and width of svg icons
  • big-play-button uses the same size as the big-play-button font size and centers the svg icon
  • volume-control uses the same size as the volume-level font size and
    centers the svg icon for both horizontal and vertical display
  • volume-control mouse-display overlaps the volume-level svg icon
  • play-progress uses the same size as the play-progress font size and removes the hover effect
  • subtitles-button uses the same size as the subtitles button font size

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chrome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
  • Reviewed by Two Core Contributors

The icons have been regenerated from the svg files in `videojs/font` to ensure consistency in size.

- update icons.svg file
Uses the same reference value from the font size of `font icons` to define the default height and width of `svg icons`
Uses the same size as the big-play-button font size and centers the svg icon
Uses the same size as the `volume-level` font size and
centers the svg icon for both horizontal and vertical display
Uses the same size as the `play-progress` font size and removes the hover effect
Uses the same size as the `subtitles button` font size
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #8380 (ce8f064) into main (3e9ef0a) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #8380      +/-   ##
==========================================
+ Coverage   82.68%   82.69%   +0.01%     
==========================================
  Files         113      113              
  Lines        7578     7578              
  Branches     1821     1821              
==========================================
+ Hits         6266     6267       +1     
+ Misses       1312     1311       -1     
Files Changed Coverage Δ
src/images/icons.svg 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@wseymour15 wseymour15 left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks for taking the time for making these a bit more consistent. I played around with these changes a bit, and they look solid to me!

+1 once the minor question is answered.

@@ -1,142 +1,143 @@
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<symbol viewBox="0 0 16 16" id="vjs-icon-play">
<path d="M2 1v14l12-7z"></path>
<symbol viewBox="0 0 48 48" id="vjs-icon-play">
Copy link
Contributor

Choose a reason for hiding this comment

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

These are much more consistent now! Just out of curiosity, how were these regenerated?

Copy link
Contributor Author

@amtins amtins Aug 1, 2023

Choose a reason for hiding this comment

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

@wseymour15 thank you for taking the time to review and comment 👍🏽

To answer your question:

It was quite a process to say the least. 🫠

My original idea was to automate everything by starting from the videojs/font project, extracting the icons directly from there and passing them to svg-screact-cli. Unfortunately, the installation of videojs/font failed, so I had to abandon the idea to avoid wasting too much time.

So I created a separate project, added the [email protected] and svg-spreact-cli dependencies. I then retrieved each material-design-icons icon used in https://videojs.github.io/font/ one by one and put them in a directory named svg. However, videojs/font has a few custom icons which I also retrieved and put in the svg directory. I renamed each svg file to match the icon name.

The svg directory looks like:
Screenshot from 2023-08-01 12-26-52

Once this preparatory work was done, I ran the command: npx svg-spreact ./svg > icons.svg -p 'vjs-icon-'

It generates a single svg file that looks like:

Screenshot from 2023-08-01 12-28-04

Finally, I removed the use xlink:href tags, reordered the generated symbols to make the git diff a little more digestible, removed the xmlns properties, checked that everything was coherent and consistent and congratulated myself on a job well done. 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Great work! When I was doing the initial development for this, I saw tools like svg-spreact-cli, but did not think it was worth the time to build out the separate SVG files. Nice to know you found a way to cut back on some of that effort!

It is also useful to know this process moving forward. If we need to ever add a new icon, we could throw it into that script, and copy the related contents into the icons.svg file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wseymour15 I've created a small project to test the automation of svg generation with svg-sprite and it works quite well and is quite simple. The demo page.

@mister-ben mister-ben merged commit d040881 into videojs:main Aug 17, 2023
9 checks passed
@amtins amtins deleted the fix/svg-icons branch November 5, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants