-
Notifications
You must be signed in to change notification settings - Fork 258
Document limitations of tokens passed to stitches #493
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
Comments
I encountered the same problem and I was thinking that a workaround this limitation of css variables can be to replace invalid characters with a mapping to a valid string when generating the css variable name. For example: So the generated variable names of your example will be: |
I totally understand the desire for this. If you want a short answer it’s this: This request will break some strong expectations in CSS. Whenever possible, we try to avoid breaking the syntactics or implicit semantics in CSS. Now, if you are interested in a deeper explanation: Our Here’s how an "ident" token really works: These syntactic rules allow CSS to safely add new features and improve the CSS authoring experience without breaking backward compatibility. For instance, the slash ( For our The looser rules are copied from the CSS "hash" token, only ours substitute Following these rules means we keep Stitches predictable. However, it also means we accept certain restrictions. Neither the "ident" or "hash" tokens support a period ( So we live with the restrictions. Tho, I promise you, we are constantly searching for more clever ways to work with those restrictions, or ways to work around them. 😄 |
Thanks for the detailed explanation @jonathantneal. I too can live with these restrictions, and hesitated to even open this issue since I realised it seemed like an upstream issue (CSS itself being upstream 😄). That said, do you think it would be worth adding a short note to these docs to flag that certain characters are not supported (at least |
I think that’s an excellent idea, and worth adding to the documentation. What do you think about leaving this open until we add it to the docs, @peduarte ? |
@jonathantneal noted! 💯 |
Bug report
Not exactly a bug with stitches, but more of a limitation of css variables.
Describe the bug
Certain token keys create invalid css variables tokens. For example:
For cases which break, the CSS variables created look something like:
var(--colors-test)/test
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
Support any string as a token key, or warn when an invalid one is used.
Screenshots
n/a. See Sandbox
System information
Additional context
This certainly might be won't fix issue. In my case I hoped to use this structure:
test/test
because our design tokens are also used in other places (Figma), and we hoped to keep them identical in code and design.The text was updated successfully, but these errors were encountered: