[css-syntax] keeping the indent level under control in modern CSS with `@layer`, `@scope`, nesting, ...
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
Research direction
No source files, tests, or entry points are mentioned. Start by reviewing the CSSWG discussion and the examples of nested @layer, @scope, nesting, and related at-rules. Done would require a concrete, agreed syntax proposal that improves readability and a clear path for specification work.
Written by the indexing model from the issue text.
Description
Example :
@layer components {
@scope (.my-component) to (.child-component-slot > *) {
.my-component {
color: cyan;
padding: 0.5rem;
&:hover {
color: blue;
}
@media (min-width: 768px) {
padding: 1rem;
}
}
}
}
This is starting to look a bit like the callback hell from JS :
getBeef("foo", (rawBeef) => {
sliceBeef(rawBeef, (slicedBeef) => {
cookBeef(slicedBeef, (cookedBeef) => {
serveBeef(cookedBeef, (servedBeef) => {
console.log(servedBeef);
});
});
});
});
Some of this can be externalized by adding bits of it to @import :
@import "my-component.css" layer(components);
But this isn't always possible or good practice for maintainable code.
Often the reason for wrapping code in an at-rule is tightly coupled with the code that is wrapped.
Using nesting is a choice and authors can choose not to nest.
@when does not help here because it wasn't designed for @layer, @scope, @container, ...
Personally I don't think @when should be shipped at all because it doesn't solve the issue fully. Maybe I am wrong here and @when could be used for all at rules?
The underlying issue is that at-rules can only be "combined" or "stacked" by nesting them. With the introduction of new at-rules and nested CSS source code will only become more heavily nested and less readable.
I don't have a concreet proposal for a syntax that could help here.
I do however think it is something that should be explored.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 24
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from w3c/csswg-drafts
-
Agenda+ css-sizing-4 css-values-5
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
w3c/csswg-drafts#14502 · 1 reaction ·
-
css-values-5 editorial Needs Edits
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
w3c/csswg-drafts#14498 · 2 comments ·
-
css-overflow-4 topic: line-clamp
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
w3c/csswg-drafts#14485 · 1 comment ·
-
Administrative Tracker css-values-4
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
w3c/csswg-drafts#14482 · 4 comments · 1 reaction ·
-
css-values-5 Needs Edits
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
w3c/csswg-drafts#14466 ·
All issues in w3c/csswg-drafts
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
tvOS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bvaughn/react-resizable-panels#751 · 1 comment ·
-
www.wiwo.de OpenN: AdGuard Browser Extension P3: Medium T: Annoyance
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
AdguardTeam/AdguardFilters#242026 ·
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 92/100