Replies: 3 comments 2 replies
-
|
@willmcvay Being quite unfamiliar with using Elements directly, what you've proposed may be fine, so I have some clarifying questions to ask before weighing in:
FYI I think answering #98 would help provide some clarity here too 😅 |
Beta Was this translation helpful? Give feedback.
-
Probably a bit of all of these TBH @kurtdoherty . It's not something we widely use, more just a convenience to cater for the odd edge case that arises. It's not a vanilla flow we are talking about :-) |
Beta Was this translation helpful? Give feedback.
-
Sure, you can do this too - just keeps things DRY if we have commonly used modifiers as utilities |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Ok, so we all know
!importantrules should be used sparingly in CSS. There is however a use case I can see in Elements where it makes sense and I think would be generally accepted as valid i.e. utility classes. Wanted to float this with the team before thinking about implementing.Consider this example:
I think it seems reasonable that the
.el-mb-12modifier would only be applied by a developer if they wanted to override the default behaviour of.el-card- I can't see another use case. Because the rules are equally specific, the winning rule will depend on which selector is loaded last which seems like a pretty rubbish edge case.Consider if I increase the specificity on
.el-cardIn this case because the
.el-is-activeclass increases the specificity, the.el-mb-12modifier is rendered totally useless. If the developer intention was to add the modifier, their expectation surely would be that the modifier would win, right?Proposal: Add an
!importantto util classesBrutal, yes, but if the sole purpose of util classes is to override default behaviours, seems reasonable that we would guarantee that the override works in all use cases.
Our modified example:
In this case, our modified margin would always work. If the important flag is causing any inheritance issues, we can easily remove it without too much of an issue. My sense is, it's a far lesser evil that we use
!importantfor utilities only than having to worry about those utilities not working in some scenarios.Please comment, upvote or downvote as something we can look at in v5.
Beta Was this translation helpful? Give feedback.
All reactions