-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: svg sprite generation #1
base: main
Are you sure you want to change the base?
Conversation
Adds SVG sprite generation to customize video.js icons - The `bin` folder contains the `cli.js` file for command-line usage. - The `icons` folder contains all the SVG icons used to generate the sprite. - The `src` folder contains the `svg-sprite` and `SVGO` configuration files, as well as the script for generating the sprite. - The `template` folder includes the HTML file used for the preview page, along with a configuration file that can be generated via the CLI. - The `vjs-svg-sprite` folder contains the preview page and the default sprite. - The `index.js` file is only used for development and generating the default sprite. - The `svg-icons.json` file defines the default configuration.
Great stuff, a couple of quick thoughts
|
@mister-ben I've added the .nvmrc file.
Yes, because I've applied two optimizations, the first directly to the icons and the second directly to the generated sprite, which should further reduce the size of the final sprite. Individual icon optimization svg-sprite-generator/src/vjs-sprite.js Line 41 in f9b1014
Sprite optimization svg-sprite-generator/src/vjs-sprite.js Line 53 in f9b1014
Yes, I can also change the destination filename to |
Regenerate `vjs-svg-sprite/index.html` to remove reference to wrong repo.
From now on, the value of `output-dir` is `dist` instead of `vjs-svg-sprite`. Access to the SVG file will be via the path `@videojs/svg-sprite-generator/dist/vjs-sprite-icons.svg` instead of `@videojs/svg-sprite-generator/vjs-svg-sprite/vjs-sprite-icons.svg`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, nice work! I left a few comments and questions.
Regarding the usage of this repo, is the distributed svg file meant to replace the file here? https://github.com/videojs/video.js/pull/8260/files#diff-56a92727a19631fea08e4d8424bbf11cbf939176723287f3e2947eded506fc83
LICENSE
Outdated
@@ -0,0 +1,21 @@ | |||
MIT License | |||
|
|||
Copyright (c) 2024 amtins<amtins.dev@gmail.com>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to update this file to align with https://github.com/videojs/video.js/blob/main/LICENSE
@@ -0,0 +1,2 @@ | |||
node_modules | |||
vjs-sprite-tmp_* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to include dist
in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, yes, in order to replace the player.js import with the file generated by this project. A bit like videojs-icons.css
params: { | ||
attributes: [ | ||
{ | ||
style: 'display: none' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sure there is good reason, but why do we want to set this style on clean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason is that svg-sprite adds style="position:absolute"
. So the cleanup is to replace position:absolute
with display:none
. Currently, display:none
is applied via JavaScript and is not present in the icons.svg
file. This would allow to remove line 545.
template/svg.config.file.js
Outdated
"root-dir": "", | ||
"output-dir": "", | ||
"icons": { | ||
"audio-description": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems bit repetitive as a similar structure exists in scg-icons.json. Would it be possible to just move those values here and remove the other file?
It may not be possible as I am unfamiliar with svg-sprite
, but figured I would mention it and try to get a better understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lack of a README
adds some confusion. To give a bit of context, there are two aspects to this project:
- Standardize and simplify the generation of the SVG sprite used by video.js. This would allow us to remove the
icons.svg
file and replace the import with the file generated by this project. I was inspired by the same philosophy as the font project, which is why this project also provides the final file. So thesvg-icons.json
file is used to generate the sprite for this project. - Allow developers to easily replace the default icons used by video.js. All of this can be done using the command-line tool. Therefore,
svg.config.file.js
will serve as a configuration file template for developers to customize the icons.
"vjs-svg-sprite": "./bin/cli.js" | ||
}, | ||
"scripts": { | ||
"build": "node index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to think if there are any other scripts we may want to include here.. Would we want to include lint
, or maybe clean
to remove the dist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the linter
as well as husky
.
Thank you for taking the time to review this PR and for the comments. ❤️
I am open to any other suggestions or ideas you may have.
Run linter on pre-commit hook
The svg-sprite.config.js file is ignored because import.meta.url is not compatible with the version of javascript used by vjsstandard.
Regenerate sprite file and html page.
Description
Adds SVG sprite generation to customize video.js icons.
Specific Changes proposed
bin
folder contains thecli.js
file for command-line usage.icons
folder contains all the SVG icons used to generate the sprite.src
folder contains thesvg-sprite
andSVGO
configuration files, as well as the script for generating the sprite.template
folder includes the HTML file used for the preview page, along with a configuration file that can be generated via the CLI.vjs-svg-sprite
folder contains the preview page and the default sprite.index.js
file is only used for development and generating the default sprite.svg-icons.json
file defines the default configuration.