-
Notifications
You must be signed in to change notification settings - Fork 30
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
Tokens Studio support 🎉 #30
Conversation
🦋 Changeset detectedLatest commit: ed7c6bc The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const tokenSet = path[0]; | ||
if (typeof v.value === 'string') { | ||
if (v.value.trim().startsWith('{') && !v.value.trim().startsWith(`{${tokenSet}`)) { | ||
v.value = v.value.trim().replace('{', `{${tokenSet}.`); |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding
for (const [property, propertyValue] of Object.entries(v.value)) { | ||
if (typeof propertyValue !== 'string') continue; | ||
if (propertyValue.trim().startsWith('{') && !propertyValue.trim().startsWith(`{${tokenSet}`)) { | ||
v.value[property] = v.value[property].trim().replace('{', `{${tokenSet}.`); |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding
Deploying with Cloudflare Pages
|
13904df
to
d2a4e68
Compare
Changes
Adds Tokens Studio support! 🥳
This is a better solution than a 50%-completed Figma sync functionality that I haven’t finished after over a year of procrastinating. Hopefully this is a win–win scenario:
Mini-FAQ
Is this project partnering with Tokens Studio?
No; this project is completely unaffiliated with Tokens Studio.
Isn’t Tokens Studio paid?
The 100% free version of the plugin offers everything Cobalt supports and then some. This is the only reason this solution is being proposed.
The paid “Pro” version offers some extra features not everyone needs (which are beyond the current scope of the W3C Design Tokens spec anyway). If, in the future, a necessary feature to make Figma syncing work is gated behind a paywall, this project may explore other options. But for now this is a great solution.
I was using
co sync
! Can you keep it around for longer?If you were using this, I’d actually love for you to comment & explain how you managed manually typing hundreds of tokens in a
tokens.config.js
file in a sane way. Not to shame, of course—I’d actually love to hear your workflow to provide better workarounds. But also to inform the next steps of Figma syncing.Why not release a Tokens Studio transformer instead?
Tokens Studio has a Style Dictionary transformer they officially support. I initially looked into doing something similar, but realized that’s a one-off and not pluggable.
Tokens Studio is meant to be a “no-code” solution, and at the moment that’s completely different than Cobalt’s approach of a pluggable, adaptable, configurable dev tool for the W3C Design Tokens format. The simplest solution for Tokens Studio support seemed to be adding support on Cobalt’s end to just parse the format automatically, which turned out to be trivial (it’s basically just converting
type
to$type
and a tiny bit of math for basic support).If, in the future, Tokens Studio releases more transformers, including one for the W3C Design Tokens format, I’d be happy to collaborate / align better on what they’re doing.