Skip to content

Conversation

emmelleppi
Copy link

@emmelleppi emmelleppi commented Nov 4, 2020

I added a couple of methods in utils.ts to set and get the initial schema values, based on the url hash

How to use it

  const { speed, factor } = useTweaks({
    speed: 1,
    factor: { value: 1, min: 10, max: 100 },
  }, { setGetFromUrl: true });

or

  const { speed } = useTweaks('Example', { speed: 1 }, { setGetFromUrl: true } )

If you set the setGetFromUrl value to true in the settings, the values are automatically set in the hash of the url when the changes occur.

When the component is mounted, the schema passed to the useTweaks hook is modified with the corresponding values found in the hash.

It is far from perfect and some TS types will certainly need to be fixed :)

@emmelleppi emmelleppi marked this pull request as draft November 5, 2020 16:05
@emmelleppi emmelleppi changed the title [WIP] Adds set and get initial tweaks data from the url hash Adds set and get initial tweaks data from the url hash Nov 5, 2020
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.

1 participant