-
Notifications
You must be signed in to change notification settings - Fork 31
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
CSS Custom Props Have Spaces #123
Comments
Maybe we can separate groups with :root {
--Full-Color-Palette--Magenta--Magenta-50: #fff0f6;
} |
I've been thinking about this a bit and I think the best solution is having an option in the plugin's config where the user can specify a string to replaces spaces in names. That option can have a default value (
If the approach I described above works, then it probably wouldn't be to hard to add an additional option for separating groups. Personally I feel like that should be different issue since it isn't breaking anything now, whereas the spaces in names issue is a bug . |
I agree—letting the user control the name generation is probably best (but in addition to the core issue of spaces being fixed). Will get to this soon, but I’d also accept PRs in case someone beats me to it 🙂 |
I'll see if I can spend some time working on this in the next couple days |
It's possible for token or group object keys to contain a space. To the best of my knowledge, this is not disallowed by the spec (though specific cases like the empty string and leading/trailing white space are being considered).
Those space don't currently cause any issues (that I can tell) with Cobalt parsing the tokens, and the rendered output by the JS plugin is valid, using strings as keys. But they become a problem when trying to use the CSS plugin to produce custom properties. CSS custom properties cannot have spaces in them, but Cobalt renders the spaces as is anyway creating invalid CSS.
Example
Tested with
Given the following tokens input
Running
npx co build
produces the following output:A valid `index.js` file
An invalid tokens.css file
Options
-
the same way it does in between group and token names_
to distinguish between spaces within a name and the split between different token and group namestransform
option to allow editing more than the value, or another option all together.I think option 3 is my personal preference, but I don't have a strong opinion. Just hoping this can get resolved quickly.
Thanks for your work on this tool! Looking forward to seeing the design tokens space mature.
The text was updated successfully, but these errors were encountered: