-
Notifications
You must be signed in to change notification settings - Fork 485
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
Add ability to download resulting config #383
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for svgomg ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
c128425
to
441e414
Compare
src/js/page/ui/settings.js
Outdated
const floatPrecision = Number(settings.floatPrecision); | ||
const plugins = []; | ||
|
||
for (const [name, active] of Object.entries(settings.plugins)) { |
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.
Most of this block seems to be duplicated in svgo-worker. Doesn't seem good from a maintenance perspective.
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 decided to copy the code first. I can rework it a bit and take out the repeating code.
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 think that would help, yeah. Because this kind of duplication can be bad in the future.
Maybe we should just have a function to return the config with plugins somewhere in a common place.
@jakearchibald any suggestions?
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.
Moved the code for getting plugins into a separate utility
src/js/utils/download.js
Outdated
@@ -0,0 +1,15 @@ | |||
export function downloadSvgoConfig(filename, text) { | |||
const element = document.createElement('a'); |
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'm wondering, isn't there a cleaner way without adding the extra a
tag?
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.
Rewrote the code so that the link to the configuration was always on the page and was updated when the configuration was changed
hey, there. Thanks for continuing your work on this. Can you please make sure there are no lint issues and the the export actually works? |
This doesn't seem to work, no lint errors, no console errors but the config is not downloaded, at lean of Firefox that I tried. |
What version of Firefox do you have? I have tested with the following versions on my system (MacOS Ventura)
I tested the export button on localhost and on the netlify build |
Something weird is happening... If I load the page and don't make any change, clicking on the export button does not trigger the download. If I change a setting, then it works. |
Maybe you are missing a |
But it's a link, it doesn't need click event handler. UPDATE: I think I've found a case where the problem might arise |
Yup, that was it. Now, the only issue I see is ripple not firing when clicking the button. |
This looks pretty good now! Waiting for @jakearchibald to review too. |
No progress on the review? I guess https://deploy-preview-383--svgomg.netlify.app works for now though 🙂 |
JFYI: Using the preview build, I was able to export and use the config, but the property
Mostly because Manually renaming on config file works. |
0b9e437
to
be87fcf
Compare
Thanks for the feedback. Checked, there is indeed a problem. It is true that for SVGOMG to support the new plugin name you need to update the svgo package. I updated my PR and added the necessary edits |
Hi.
I and others (according to requests #11, #50 and #184), miss the possibility to apply SVGO configuration to multiple files. As I understood it, batch processing support is not expected, that's why I suggest an intermediate solution - a possibility to download the resulting config and then apply it using the cli interface of SVGO.
Unfortunately, the latest versions of SVGO don't support sending the config as text, that's why you'll have to create the config file as JS.
Fixes #11