-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Compare current selector to other common selectors #1174
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
Comments
why not write it as
.. e.g. what advantage do you get with your code? If we were going to implement this I would want to combine it with the request to have mixin guards on non mixins and then a request to be able to use |
Yes I agree with combining it with mixin guards on non-mixins. Someone would probably want this when a group of selectors share a ton of similarities but not many differences. For instance (with mixin guards on non-mixins):
In my opinion, this is much more containerized and readable than writing the shared less and then each additional header selector separately. We just switched over all of our CSS to LESS at the startup I work at (around 7000 - 8000 lines of CSS), and it was a fairly common scenario to see where this feature would be a win. When I'm looking at LESS that extends from a certain class, it eventually turns into somewhat of a class definition, which is awesome because it's super readable. However, it's easy, as the code base grows and whatever else, for this to happen:
I suppose it's also the job of the programmer to not fragment their LESS all over the place, but it would also be nice to just know "ok, all/most of the suff pertaining to headers will be compartmentalized into this one block". |
I think the situation you've presented is really just a matter of style and organization on the part of the stylesheet designer. It doesn't reduce the amount of code you need to write and it deviates so far from CSS syntax that it gets confusing to read as you scan down the sheet. LESS, and even vanilla CSS, give you plenty of ways to organize and comment your styles. I don't see this as bringing any value. Also, with the |
Agreed with @Soviut & @agatronic. It's an interesting idea, but the use cases are / will be covered with existing and future syntax, and this syntax feels a bit clunky. |
keep it in the 2 existing issues, have referenced this one |
More of a feature request, but I would like to do the following (and I'm assuming others would probably want to do this at some point as well):
So the feature request would be to be able to see if the current selector is another common selector. I'm not sure how the '&' operator works internally. If the functionality does not exist in a month or so, I'll probably return to less and look at its internals to see if I can implement something that allows for this within it (if you give me a green light and think that'd be something people would want). I could attach the commit here. I'm assuming there's some way to get the current selector state as you're building the CSS rules, so the comparison would just make a new selector path if this comparison ever showed up. It would also check if the current selector is a top-level selector and it could just make two "heads" to the selector state. So, in this case:
In other cases where it's not a top-level selector:
The text was updated successfully, but these errors were encountered: