Replies: 3 comments 4 replies
-
Here's an example of a problem that comes from mimicking DOM structure: iTwin/iTwinUI-react#30 (comment) We want to wrap a button with span but that breaks button-group styling because of iTwinUI/src/button/button-group.scss Line 8 in 53065e4 |
Beta Was this translation helpful? Give feedback.
-
While I agree that limiting nesting has some benefits, I wouldn't impose a lint about it because some component can be complex and nesting help understanding how the component is designed. I would said, be aware that nesting can be bad and try to avoid that, but imposing limit is not helpful. |
Beta Was this translation helpful? Give feedback.
-
One of the most popular component lib says to recommends to use longer names and avoid scoping: https://github.com/palantir/blueprint/wiki/Coding-guidelines#css-selectors |
Beta Was this translation helpful? Give feedback.
-
We have a stylelint rule for limiting selector nesting.
iTwinUI/.stylelintrc.json
Line 10 in df726ca
And because of the way we conventionally write css in this repo, we often find ourselves hitting that limit (in header, in sidenav, in slider, and in so many other places).
The other problem we run into is with clashing selectors (e.g. we use the same classes in completely different ways in different components and they end up conflicting).
I think we should start making our selectors flatter by making base classnames (not modifiers) longer where we need to.
Inception Rule:
Other good reads:
Beta Was this translation helpful? Give feedback.
All reactions