-
Notifications
You must be signed in to change notification settings - Fork 3.4k
guards on css styles #748
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
👍 |
Could you explain? Isn't this possible? Or you want @width derived from the element(don't see how this is possible). Could you include a compilable example? |
Sorry, I understand now. +1 from me. |
Since classes get interpreted as mixins anyway, this seems like an obvious win. +1 |
Note that I've proposed extending this syntax to property / value and inline mixin declarations in #1293. |
I'm not sure about the additions.. I think we should have 2 bugs and do |
Makes sense. |
Lots of fun on this one
Have made good progress on implementing, need another couple of hours. |
@lukeapage can you explain #4 in greater detail (regarding the selector vs ruleset guard distinction)? |
my unit tests have (something like) this in at the moment...
extend is per selector because we decided it was unintuitive that it covered all of the selectors.. I think when should be the same. p.s. probably need a better test since
|
Ah, thanks for the example. If I understand correctly, then I'm in agreement with everything you've outlined. |
@lukeapage thanks for the update, though I'm still not clear on the distinction. What would be the output if the guard were on the ruleset instead? And is
|
guard on ruleset =
and no output.... @extemporalgenome thats point 2.. it should have no effect |
Ah. I had completely misunderstood, believing that ruleset vs selector was an issue in determining what the output would be when a guard applies, not a matter of what the guard applies to. I agree entirely that it should be per-selector. One could always simulate per-ruleset by doing:
Note that this also implies that the following:
could be equivalently specified as:
|
yep, true.. I think its looking neat |
Yeah, this feature is a slam-duck. Thanks, Luke. ^_^ EDIT: Er... that's slam DUNK. lol |
@matthew-dean, why would you do such a thing?! poor duck lol |
@extemporalgenome very nice examples! |
Nice! +1 |
I'd love something like this:
Instead of
|
@initart please open a new issue |
Hrmm
Vs
The trouble is I don't know if, a comma is part of the when or the next selector. Options:
I will try option 1 as it can always be expanded to option 2 or 3. |
I haven't looked into it much, but I get the sense that parsing and lexing are a combined step. That probably isn't the case with all LESS implementations (or at least all potential implementations), and when they are separate processing steps, the distinction you mention is completely unambiguous with a single-token lookahead: if it's a parentheses, then continue parsing the 'when' clause, otherwise parse a selector. I'd suggest that in all cases we avoid changing syntax to account for implementation details (because, as mentioned, these kinds of issues may be trivially solvable with a different parse model). |
@extemporalgenome this has nothing to do with implementation.. It isn't that simple..
also I'm concerned that if the guard syntax is ever extended, we are in a hole. also, it isn't just whether the parser can parse it.. I did say in option 2 that I can quite easily backtrack, I have a concern that a syntax that is ambiguous to the parser without look-ahead is also ambiguous to someone using less.. I don''t think the resultant less looks nice if people are using or conditions AND multiple selectors. |
Ah, I see what you mean. Since you demonstrated a comment in there, and CSS comments are preserved, how and where would that comment appear in the output, if at all (since afaik, guard expressions are not part of any CSS proposal or spec)? |
Either it wouldn't appear or it would appear inbetween the selector and And I'm not sure comments are supported in exactly that place in less.js at |
this is implemented. I also added test cases for this curious piece of less
which is syntactic sugar for the previous
|
I'd like to use guards on concrete CSS like this:
When @width variable is greater then 400px, the .rule would be hidden in generated CSS. Nowadays I need to do something like:
The text was updated successfully, but these errors were encountered: