Commit 754bfc8
committed
add
This allows us to re-implement functional utilities with a default value
in CSS using `@utility`.
Used the explicit `--default()` argument of `--value()` for a few reasons.
1. It's explicit about being a falllback value. If you have `@utility
foo-*`, then you want to be able to use `foo`, but `foo-bad` should
not compile.
2. When `--value(…)` is used in (complex) property values (think a bunch
of `calc(…)` expressions), then we don't need a separate property for
this.
One of the ideas was to have a literal fallback:
```css
@Utility tab-* {
tab-size: 4;
tab-size: --value(number);
}
```
For `tab`, this would compile to:
```css
.tab {
tab-size: 4;
}
```
For `tab-123`, this would compile to:
```css
.tab {
tab-size: 4;
tab-size: 123;
}
```
Getting rid of the `tab-size: 4` would be an option, but it's a common
pattern in real CSS for fallback values (think hex background color,
over a more modern `oklch` color).
For `tab-foo`, this would compile to:
```css
.tab {
tab-size: 4;
}
```
Which means that we have an infinite amount classes that would result in
the same class, which is bad. We could special case this one because the
internal `value` would still be `null`, but it might be too confusing.
This syntax without the `--default` also means repetition of certain
properties.
Add `--modifier(…)` to the mix, and there is even more repetition going
on.
Another option to consider is that the default fallback is just another
option in the `--value(…, 4)`, but if a default fallback is a keyword,
then there is a chance that this might conflict with actual keywords we
interpret.--default(…) to --value(…) support1 parent 4b5d6a5 commit 754bfc8
2 files changed
Lines changed: 113 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29540 | 29540 | | |
29541 | 29541 | | |
29542 | 29542 | | |
| 29543 | + | |
| 29544 | + | |
| 29545 | + | |
| 29546 | + | |
| 29547 | + | |
| 29548 | + | |
| 29549 | + | |
| 29550 | + | |
| 29551 | + | |
| 29552 | + | |
| 29553 | + | |
| 29554 | + | |
| 29555 | + | |
| 29556 | + | |
| 29557 | + | |
| 29558 | + | |
| 29559 | + | |
| 29560 | + | |
| 29561 | + | |
| 29562 | + | |
| 29563 | + | |
| 29564 | + | |
| 29565 | + | |
| 29566 | + | |
| 29567 | + | |
| 29568 | + | |
| 29569 | + | |
| 29570 | + | |
| 29571 | + | |
| 29572 | + | |
| 29573 | + | |
| 29574 | + | |
| 29575 | + | |
| 29576 | + | |
| 29577 | + | |
| 29578 | + | |
| 29579 | + | |
| 29580 | + | |
| 29581 | + | |
| 29582 | + | |
| 29583 | + | |
| 29584 | + | |
| 29585 | + | |
| 29586 | + | |
| 29587 | + | |
| 29588 | + | |
| 29589 | + | |
| 29590 | + | |
| 29591 | + | |
| 29592 | + | |
| 29593 | + | |
| 29594 | + | |
| 29595 | + | |
| 29596 | + | |
| 29597 | + | |
| 29598 | + | |
| 29599 | + | |
| 29600 | + | |
| 29601 | + | |
| 29602 | + | |
| 29603 | + | |
| 29604 | + | |
| 29605 | + | |
| 29606 | + | |
| 29607 | + | |
| 29608 | + | |
| 29609 | + | |
| 29610 | + | |
| 29611 | + | |
| 29612 | + | |
| 29613 | + | |
| 29614 | + | |
| 29615 | + | |
| 29616 | + | |
| 29617 | + | |
| 29618 | + | |
| 29619 | + | |
| 29620 | + | |
| 29621 | + | |
| 29622 | + | |
| 29623 | + | |
| 29624 | + | |
| 29625 | + | |
| 29626 | + | |
| 29627 | + | |
| 29628 | + | |
| 29629 | + | |
| 29630 | + | |
| 29631 | + | |
| 29632 | + | |
| 29633 | + | |
| 29634 | + | |
29543 | 29635 | | |
29544 | 29636 | | |
29545 | 29637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5956 | 5956 | | |
5957 | 5957 | | |
5958 | 5958 | | |
| 5959 | + | |
| 5960 | + | |
5959 | 5961 | | |
5960 | 5962 | | |
5961 | 5963 | | |
| |||
6069 | 6071 | | |
6070 | 6072 | | |
6071 | 6073 | | |
6072 | | - | |
| 6074 | + | |
6073 | 6075 | | |
6074 | 6076 | | |
6075 | 6077 | | |
| |||
6135 | 6137 | | |
6136 | 6138 | | |
6137 | 6139 | | |
6138 | | - | |
6139 | | - | |
6140 | | - | |
| 6140 | + | |
| 6141 | + | |
6141 | 6142 | | |
6142 | 6143 | | |
6143 | 6144 | | |
| |||
6185 | 6186 | | |
6186 | 6187 | | |
6187 | 6188 | | |
6188 | | - | |
| 6189 | + | |
| 6190 | + | |
| 6191 | + | |
6189 | 6192 | | |
6190 | 6193 | | |
6191 | 6194 | | |
| |||
6233 | 6236 | | |
6234 | 6237 | | |
6235 | 6238 | | |
6236 | | - | |
6237 | | - | |
| 6239 | + | |
| 6240 | + | |
| 6241 | + | |
6238 | 6242 | | |
6239 | 6243 | | |
6240 | 6244 | | |
| |||
6451 | 6455 | | |
6452 | 6456 | | |
6453 | 6457 | | |
| 6458 | + | |
| 6459 | + | |
| 6460 | + | |
| 6461 | + | |
| 6462 | + | |
| 6463 | + | |
| 6464 | + | |
| 6465 | + | |
| 6466 | + | |
| 6467 | + | |
6454 | 6468 | | |
6455 | 6469 | | |
6456 | 6470 | | |
| |||
0 commit comments