Re: [csswg-drafts] [css-nesting-1] nesting limited to conditional styling of the current element (another proposal) (#8166)

I agree.

But I think there is a nuance here.

I think that the combination of this proposal with `@scope` and `@custom-selector` does fully cover the needs, but only within a single coding style, a convention within a team of developers. 

_That is not a good thing._

----

Nesting proposal 3 doesn't have this aspect.
It does not require developers to follow a methodology.

I think ultimately nesting is mostly about reducing friction when writing CSS.

Nesting in proposal 3 is a really awesome writing tool.
It allows you to write linearly, carrying the meaning/context of `&` as you add more bits.

Having to go back and forth in a file to add more `@custom-selector` rules and apply them after noticing that selector will be repeated is not ideal and takes you out of your flow.

This is subtly different from purely reducing repetition.
Variable assignment (`@custom-selector`) allows you to reduce repetition but it doesn't reduce friction.

-------

Proposal 3 can however make the final source code really problematic for code reviews, refactoring, ... Having to figure out the meaning of `&` in non-trivial examples during code review is painful. (this is shared with preprocessor nesting, Proposal 1, 2, 4, 5)

I personally favor readability over ease of writing which is also why something like this proposal is appealing to me.

----------

Proposal 3 is easy to write but can lead to less-readable code.
_linters can help teams keep code readable for each other, which can make this a non-issue_

Proposal 4 is problematic because it is harder to write and harder to read.
_requires a very specific code format to make it somewhat readable_

Proposal 5 is problematic because it is harder to write.
_requires going back and changing previous bits of code_

This proposal is problematic because it is harder to write.
_requires going back and changing previous bits of code, same as 5_


-- 
GitHub Notification of comment by romainmenke
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8166#issuecomment-1336118294 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 3 December 2022 09:02:53 UTC