-
Notifications
You must be signed in to change notification settings - Fork 1
Use easy-to-test CSS modules #5
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
base: main
Are you sure you want to change the base?
Conversation
I think it is good idea. But I do want to hear the opinions of others: @kswenson, @ekosmin, @knowuh, @sfentress, @dstrawberrygirl, @DALove1025, @mklewandowski, and @dougmartin |
I am in favor of predictable & meaningful class names, regardless of testing actually. I was also in favor of the data attribute approach where items that are useful to tests are called out, eg: In either event, these are not mutually exclusive, and I like removing the random hash from our class names. This will all become irrelevant once I convert everyone to using styled components anyway. 😜 |
I think this is a pretty good idea - a small thing to note is that search/replacing |
This |
I agree that as an implementation of CSS modules this seems like a reasonable approach. I don't feel like as an organization we've settled on the fact that CSS modules is the preferred standard, however. My inclination would be to make it opt-in rather than on by default. |
I'm just working without CSS modules for the first time in a long time, in the DESE models repo. And I've managed to have class name conflicts within my small app twice. It's so easy. Even if you nest classes, it's enough that you use the same name somewhere in the ancestor component. And there's no easy way to prevent it (unless doing namespacing manually, but why?). Not saying CSS modules are the best approach out there, but I feel like it's just better than the no-modules approach. 😉 |
Is it time to adopt this pattern? 😉 |
@pjanik I think it makes sense but we should remove the |
@dougmartin, the reason for |
I think that our main problem about CSS modules was that it's making integration testing really annoying because of the random hash.
This configuration setups constant prefix, which is still unique enough to be sure that we'll avoid 99.99% of conflicts with outer or inner apps/components.
It also makes testing possible, CSS classes are not pretty, but won't change randomly. If we ever need to change this prefix, an update of tests will be trivial too.
Not pushing for it, this PR is opinionated and more like a proposal. But I think it gives us most of the CSS modules advantages and removes the major issue/pain. Does it seem like a reasonable compromise?