Replies: 1 comment
-
That’s an interesting idea 💡 I reckon that you could create a codegen plugin for this in your project and modify the generated token.d.ts code. Here are some plugin code you could get ideas from: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
In my project, I want engineers to use the
token(tokenNamespace.value)
format (e.g.token(blue.50)
) for all Panda token references, so that token usage looks like CSS variable usage (var(--namespace-value)
) rather than built-in value usage (e.g.blue
ormediumseagreen
) to make it very explicit to future readers of the code when we're using Panda tokens.Unfortunately, enabling
strictTokens
means that Panda generates TypeScript types that require using only the the baretokenNamespace.value
format (e.g.blue.50
), not thetoken(...)
format.Could we change the way that Panda generates TypeScript types to either support both formats or have a config option that specifies which format we want to support (akin to how the
syntax
config option allows us to constrain how we can write styles)? My preference would be the latter, since then it would allow me to specifically disallow the "bare" non-token(...)
format.Problem Statement/Justification
When managing a codebase that has lots of contributing engineers and which we expect to be long-lived, constraining people to use only valid values of the format
token(...)
helps ensure consistency and therefore maintainability across the codebase. It would therefore be helpful to be able to usestrictTokens
and thetoken(...)
format together.Proposed Solution or API
Supporting just the
token(...)
format requires changing this line of code in thegenerator
package to the following:Obviously landing that simple swap would break anyone who does not want to use the
token(...)
format. I assume this would be undesirable, so I would propose that either we allow both the current andtoken(...)
-wrapped versions, or we support a config option that lets us pick between them. My preference would be the latter so that I can limit the number of patterns in my team's codebase.Alternatives
The obvious alternative is to either not use
strictTokens
or to stop using thetoken(...)
format, but I think both of these choices would make my codebase less maintainable over time.Additional Information
Implementing the "either" version should be easy, and I'd be happy to take a stab at implementing the config option version as well, if you'd be open to this change!
Beta Was this translation helpful? Give feedback.
All reactions