As the project grows, the general expectations from what we can/should build with tokens is growing and so these patterns can be optimized to our use-cases.
I think the output from the example configuration above should be this:
As we are also trying on creating an API to easily create live-editable components (compose()), it seems obvious we'll need to have a better approach to this.
There is currently 2 entry points to access your tokens in your app.
$dt() helper, and @component('component.key');
These helpers both has in their resolving, access to full tokens object, processed by Style Dictionary.
That means we should easily be able to change these built outputs into generating only that:
By having this aliased tokens map, but preserving the tokens definition "complete", we can eliminate the overhead of having a lot of variables declared, while preserving the capacity to be very specific at what we can live-edit from our editor.
Aliases resolving
We currently use native
{aliases.keys}
resolving in Style Dictionary.This resolving leads to replacing the
{alias}
by its value in the built output.Leading to this:
Generating this:
As the project grows, the general expectations from what we can/should build with tokens is growing and so these patterns can be optimized to our use-cases.
I think the output from the example configuration above should be this:
Shorthands
Currently, we are creating a CSS variable PER token (objects with
value
) in the wholetokens.config
object tree.Which means this:
Will lead to this:
As we are also trying on creating an API to easily create
live-editable components
(compose()
), it seems obvious we'll need to have a better approach to this.There is currently 2 entry points to access your tokens in your app.
$dt()
helper, and@component('component.key')
;These helpers both has in their resolving, access to full tokens object, processed by Style Dictionary.
That means we should easily be able to change these built outputs into generating only that:
By having this aliased tokens map, but preserving the tokens definition "complete", we can eliminate the overhead of having a lot of variables declared, while preserving the capacity to be very specific at what we can live-edit from our editor.