Updating tokens
Last updated
Was this helpful?
Last updated
Was this helpful?
One of the benefits to work directly with the SDK is that you can update the tokens value on the fly to match exactly your needs. Before explaining you how to do it, it's important that you note that updating tokens won't run a remote update in your repository.
Before even updating the tokens, we need to import the updaters that will help us to perform the updates. Everything is grouped inside the updaters
object:
If you need to have your colors to be converted to a specific format, you can use the prebuilt color
updater:
You can refer to to see all the available colors.
If you need to have your token's name to be formatted in a specify way: camelCase, snakeCase, etc... You can use the changeCase
updater:
If you need to have your dimensions to be converted to a specific format, you can use the prebuilt dimension
updater:
The update
method actually takes as much parameter as you want, so you can do the following:
If you want to perform multiple updates with the same query, it can quickly become quite verbose. To avoid it, you can use the withQuery
method:
An updater is in reality a function that looks like this:
If you're wondering why there's 2 applyTo
, it's because the first one is the one that you're passing when calling the function, and the second one is passed if the updater is called with withQuery
.
Once implemented, you can use it the same way we're using the updaters above:
The above implementation works for a reusable updater, but if you exactly know what you want, you can do the following as well:
You can refer to to see all the available casing.
You can refer to to see all the available units.
So if you want to create a custom updater, feel free to copy/paste the above function and implement it the way you want. You can refer to the to understand how to perform updates on the SDTF.