linkedin / linkedin/css-blocks
Shared State
- Dominant language
- TypeScript
- Stars
- 6.3k
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
I've been wondering if we should have a syntax for creating a state that is shared across all classes.
An example use case for this would be a the `gutter` and `last` states for a float-based grid block.
Using Sass, you can create mixins to simplify this process, but I'd like the block syntax to be usable without a preprocessor.
```css
/* example.block.css */
.foo {
margin: 10px;
}
.bar {
margin: 18px;
}
*[state|last] {
margin-right: 0;
}
```
Would then compile to:
```css
.example__foo { margin: 10px; }
.example__bar { margin: 18px; }
.example__foo--last,
.example__bar--last { margin-right: 0; }
```
Maybe it's not common enough to warrant addressing with specialized syntax, but I thought I'd write it down for discussion at some point.
Contributor guide
Research direction
The issue provides example.block.css as the entry point; start by comparing its block and state syntax with the requested compiled CSS output. Done would require a decided syntax and an implementation that compiles shared states across classes, but the issue does not name tests or implementation files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, sass
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100