Closed mellyeliu closed 1 month ago
I wrote a stylex patch in RSD to prefix class names with the prop name: https://github.com/facebook/react-strict-dom/blob/main/patches/%40stylexjs%2Bbabel-plugin%2B0.7.5.patch#L52
I would be wary of trying to generate tailwind-like classes, even if it's only in dev, because people will simply try to write selectors against them. We already had an issue internally where a patch was landed to target a StyleX dev classname.
It was communicated to the CSS BE team that we'd switch to dev data-*
props (https://github.com/facebook/stylex/issues/723), which would make that a lot less likely for an engineer to try to target with a CSS selector. The GH issue frames it as providing info for a dev tools integration, but it's first an improvement over the current debugging info we generate.
The initial goal is only to make the classes a bit more readable in development. We can start with prefixing class names with the prop name. and leave the hashes for the value part.
See also #184
Describe the feature request
Right now, we hash the <list of “conditions”>++ to generate classNames for everything!
Instead: For common, key-value pairs, such as margin:0, generate small readable classNames, such as: m-0
We'll want to add this in as a config option to
StyleXOptions
Some examples: