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

[Draft] Override default settings through url parameters #174 #209

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jeromebon
Copy link

@jeromebon jeromebon commented Feb 24, 2021

This change allow to override svgomg default settings through url parameters. #174
It's usefull when you want to share svomg to coworkers without asking them to check/uncheck some options.

Seach parameters names are the same as the input name attribute, which also are the same as svgo options name. For example to set "Prefer viewBox to width/height" by default one would use https://jakearchibald.github.io/svgomg/?removeDimensions=true

Options from the url parameters are taken into account at 2 moments:

  • On page load, we merge the options from localStorage with the ones in the url (url parameters taking precedence)
  • On reset, we override svgo's defaults with options in the url

Fixes #174

@netlify
Copy link

netlify bot commented Oct 13, 2021

✔️ Deploy Preview for svgomg ready!

🔨 Explore the source changes: 8588932

🔍 Inspect the deploy log: https://app.netlify.com/sites/svgomg/deploys/618d2a81ae336a0007f557a2

😎 Browse the preview: https://deploy-preview-209--svgomg.netlify.app

@XhmikosR
Copy link
Collaborator

XhmikosR commented Oct 18, 2021

@Mojeer0 can you rebase and make sure tests are green?

@@ -250,7 +250,12 @@ export default class MainController {
}

async _loadSettings() {
const settings = await storage.get('settings');
let settings = await storage.get('settings');
settings = Object.assign(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be a spread instead

@XhmikosR
Copy link
Collaborator

This doesn't seem to work when Service Workers are disabled.

@jeromebon jeromebon changed the title Override default settings through url parameters #174 [Draft] Override default settings through url parameters #174 Nov 11, 2021
@jeromebon jeromebon marked this pull request as draft November 11, 2021 14:39
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.

Make optimization settings overridable via the URL
2 participants