Skip to content

Commit 214ce32

Browse files
authored
[CSSGapDecorations] Polish the explainer (#1257)
1 parent 8c97182 commit 214ce32

7 files changed

Lines changed: 75 additions & 63 deletions

CSSGapDecorations/explainer.md

Lines changed: 75 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ content location of future work and discussions.
3939
- [User research](#user-research)
4040
- [Properties](#properties)
4141
- [Width, style, and color](#width-style-and-color)
42+
- [Interaction with intersection types](#interaction-with-intersection-types)
4243
- [Extending or shortening gap decoration segments](#extending-or-shortening-gap-decoration-segments)
43-
- [Interaction with spanning items](#interaction-with-spanning-items)
4444
- [Paint order](#paint-order)
4545
- [Decorations next to empty areas](#decorations-next-to-empty-areas)
4646
- [Key scenarios](#key-scenarios)
@@ -59,7 +59,7 @@ content location of future work and discussions.
5959
- [Scenario: Different lines for different gaps, applied to a sub-area of a grid](#scenario-different-lines-for-different-gaps-applied-to-a-sub-area-of-a-grid)
6060
- [Scenario: Periodic Table omitting decorations from certain areas](#scenario-periodic-table-omitting-decorations-from-certain-areas)
6161
- [Dropped ideas](#dropped-ideas)
62-
- [Logical properties for flex and masonry containers](#logical-properties-for-flex-and-masonry-containers)
62+
- [Logical properties](#logical-properties)
6363
- [Considered alternatives](#considered-alternatives)
6464
- [Alternative 1: 2021 draft specification](#alternative-1-2021-draft-specification)
6565
- [Alternative 2: Using pseudo-elements](#alternative-2-using-pseudo-elements)
@@ -89,7 +89,7 @@ non-ergonomic workarounds such as these examples:
8989

9090
* Extend CSS [column rule
9191
properties](https://drafts.csswg.org/css-multicol-1/#column-gaps-and-rules) to
92-
apply to other container layouts such as grid, flex, and masonry.
92+
apply to other container layouts such as grid, flex, and grid-lanes.
9393
* Introduce row-direction gap decorations on CSS container layouts.
9494
* Allow gap decorations to vary over a given container to handle cases such as
9595
alternating row separators.
@@ -106,17 +106,24 @@ non-ergonomic workarounds such as these examples:
106106

107107
## User research
108108

109-
Use cases in this explainer were collected from the discussion in issue
109+
Use cases in this explainer were collected from the discussion in CSSWG issue
110110
[2748](https://github.com/w3c/csswg-drafts/issues/2748). Additional inspiration
111-
was drawn from discussions in issues
111+
was drawn from discussions in CSSWG issues
112112
[5080](https://github.com/w3c/csswg-drafts/issues/5080),
113113
[6748](https://github.com/w3c/csswg-drafts/issues/6748), and
114114
[9482](https://github.com/w3c/csswg-drafts/issues/9482).
115115

116+
Comments received on the feature in MSEdgeExplainers issues
117+
[996](https://github.com/MicrosoftEdge/MSEdgeExplainers/issues/996),
118+
[1099](https://github.com/MicrosoftEdge/MSEdgeExplainers/issues/1099),
119+
[1100](https://github.com/MicrosoftEdge/MSEdgeExplainers/issues/1100), and
120+
[1111](https://github.com/MicrosoftEdge/MSEdgeExplainers/issues/1111)
121+
have also been incorporated into the design.
122+
116123
## Properties
117124

118125
Unless otherwise noted, corresponding `row-` and `column-` properties should be
119-
assumed to have identical syntax. All such pairs of properties also have `gap-`
126+
assumed to have identical syntax. All such pairs of properties also have
120127
shorthands that apply the same values in both directions.
121128

122129
For property grammar details, please see the
@@ -132,26 +139,28 @@ the list is cycled through from the beginning as needed.
132139
Authors may also use familiar syntax from CSS Grid such as `repeat()`
133140
and `auto` to create patterns of line definitions. Note that while `repeat()` and `auto`
134141
are inspired by CSS Grid, they may also be used to create patterns of decorations
135-
in flex, multi-column, and masonry containers.
142+
in flex, multi-column, and grid-lanes containers.
136143

137144
Shorthands are also available to combine the width, style, and color properties.
138145

139146
```css
140147
.alternate-red-blue {
141148
display: grid;
142-
grid-template: repeat(auto-fill, 30px) / repeat(3, 100px);
143-
grid-gap: 10px;
149+
grid-template-columns: repeat(3, 100px);
150+
grid-auto-rows: 30px;
151+
gap: 10px;
144152
row-rule: 1px solid;
145-
row-rule-color: red blue;
153+
row-rule-color: red, blue;
146154
}
147155
```
148156
<image src="images/example-red-blue.png">
149157

150158
```css
151159
.alternate-heavy-light {
152160
display: grid;
153-
grid-template: repeat(auto-fill, 30px) / repeat(3, 100px);
154-
grid-gap: 10px;
161+
grid-template-columns: repeat(3, 100px);
162+
grid-auto-rows: 30px;
163+
gap: 10px;
155164
row-rule: 2px solid black, 1px solid lightgray;
156165
}
157166
```
@@ -163,14 +172,15 @@ container. Conceptually, gap decorations are considered after layout has
163172
completed, and in particular after we already know the full extent of the
164173
[implicit grid](https://drafts.csswg.org/css-grid-2/#implicit-grid) in grid
165174
layout, or the number of lines in flex layout, or the number of columns in
166-
multi-column layout, or the number of tracks in masonry layout. Thus, the
175+
multi-column layout, or the number of tracks in grid-lanes layout. Thus, the
167176
`repeat()` grammar, while modeled after the `grid-template` properties, is
168177
simpler for gap decorations as there are fewer unknowns to consider.
169178

170179
```css
171180
.varying-widths {
172181
dispay: grid;
173-
grid-template: repeat(auto-fill, 30px) / repeat(3, 100px);
182+
grid-template-columns: repeat(3, 100px);
183+
grid-auto-rows: 30px;
174184
row-gap: 9px;
175185
row-rule: 5px solid black, repeat(auto, 1px solid black), 3px solid black;
176186
}
@@ -183,14 +193,40 @@ simpler for gap decorations as there are fewer unknowns to consider.
183193

184194
<image src="images/example-width-style-color.png">
185195

196+
### Interaction with intersection types
197+
198+
Authors may change the set of intersections where gap decorations break,
199+
from the default behavior to either "all intersections" or "no intersections."
200+
Where gap decorations overlap items in the container, the decoration is painted
201+
behind the item.
202+
203+
```css
204+
.normal {
205+
rule-break: normal;
206+
}
207+
```
208+
<image src="images/example-break-normal.png">
209+
210+
```css
211+
.all-intersections {
212+
rule-break: intersection;
213+
}
214+
```
215+
<image src="images/example-break-intersection.png">
216+
217+
```css
218+
.no-intersections {
219+
rule-break: none;
220+
}
221+
```
222+
<image src="images/example-break-none.png">
223+
186224
### Extending or shortening gap decoration segments
187225

188226
By default, gap decorations are painted as continuous segments that extend as
189-
far as possible along the centerline of a given gap. The decoration is painted
190-
from one gap T intersection to another, with both endpoints at the centers of
191-
the T crossings and the decoration proceeding along the stems of both Ts. In
192-
grid layout, row decorations are painted on top of column decorations by
193-
default; changing this behavior is covered in a later section of this document.
227+
far as possible along the centerline of a given visible gap.
228+
The decoration is painted from visible intersection to another,
229+
with each endpoint at the innermost edge of the intersection.
194230

195231
```css
196232
.grid-with-spans {
@@ -223,21 +259,24 @@ into the intersection and positive values receding from it.
223259

224260
```css
225261
.inset-0px {
262+
column-rule-break: intersection;
226263
column-rule-inset: 0px;
227264
}
228265
```
229266
<image src="images/example-column-inset-0px.png">
230267

231268
```css
232269
.inset-5px {
233-
column-rule-inset: -5px;
270+
column-rule-break: intersection;
271+
column-rule-inset: 5px;
234272
}
235273
```
236274
<image src="images/example-column-inset-5px.png">
237275

238276
```css
239277
.inset-negative-5px {
240-
column-rule-inset: 5px;
278+
column-rule-break: intersection;
279+
column-rule-inset: -5px;
241280
}
242281
```
243282
<image src="images/example-column-inset-minus-5px.png">
@@ -248,8 +287,9 @@ and "interior" endpoints (any endpoint that is not an "edge").
248287

249288
```css
250289
.edge-interior-insets {
290+
column-rule-break: intersection;
251291
column-rule-edge-inset: 0px;
252-
column-rule-interior-inset: 5px;
292+
column-rule-interior-inset: -5px;
253293
}
254294
```
255295

@@ -260,48 +300,21 @@ making a distinction between "start" and "end" endpoints, in addition to the "ed
260300

261301
```css
262302
.start-end-edge-interior-insets {
263-
column-rule-start-edge-inset: 0px;
264-
column-rule-end-edge-inset: 8px;
265-
column-rule-start-interior-inset: 0px;
266-
column-rule-end-interior-inset: 8px;
267-
}
268-
```
269-
270-
<image src="images/example-column-start-end-edge-interior-insets.png">
271-
272-
### Interaction with spanning items
273-
274-
Authors may also change the set of intersections where gap decorations break,
275-
from the default "T intersections" behavior to either "all intersections" or "no intersections."
276-
In the latter case, gap decorations paint "behind" items in the container.
277-
278-
```css
279-
.t-intersections {
280-
gap-rule-break: spanning-item;
281-
gap-rule-inset: 0px;
282-
}
283-
```
284-
<image src="images/example-break-spanning-item.png">
303+
column-rule-break: intersection;
285304

286-
```css
287-
.all-intersections {
288-
gap-rule-break: intersection;
289-
gap-rule-inset: 0px;
305+
column-rule-edge-inset-start: 8px;
306+
column-rule-interior-inset-start: 8px;
307+
/* or shorthand: */
308+
column-rule-inset-start: 8px;
290309
}
291310
```
292-
<image src="images/example-break-intersection.png">
293311

294-
```css
295-
.no-intersections {
296-
gap-rule-break: none;
297-
}
298-
```
299-
<image src="images/example-break-none.png">
312+
<image src="images/example-column-start-end-edge-interior-insets.png">
300313

301314
### Paint order
302315

303-
When row and column gap decorations overlap, authors can control their painting
304-
order.
316+
When row and column gap decorations overlap, authors can control their painting order.
317+
By default, row-direction decorations are painted on top of column-direction decorations.
305318

306319
```css
307320
rule-overlap: [ row-over-column | column-over-row ]
@@ -662,13 +675,12 @@ https://github.com/w3c/csswg-drafts/issues/12024#issuecomment-3086244002
662675

663676
## Dropped ideas
664677

665-
### Logical properties for flex and masonry containers
678+
### Logical properties
666679

667680
*This idea was dropped based on feedback raised in the [initial proposal discussion](https://github.com/w3c/csswg-drafts/issues/10393).*
668681

669-
These are designed to enable scenarios where authors wish to switch
670-
`flex-direction` or `masonry-direction` based on space constraints or other
671-
factors.
682+
These are designed to enable scenarios where authors wish to switch, for example,
683+
`flex-direction` based on space constraints or other factors.
672684

673685
| Property | row or row-reverse direction | column or column-reverse direction |
674686
|------------------|------------------------------|------------------------------------|
@@ -683,8 +695,8 @@ factors.
683695

684696
And so on for other properties.
685697

686-
For flex and masonry containers, the logical properties map based on
687-
`flex-direction` or `masonry-direction` following the convention above.
698+
For flex containers, the logical properties map based on
699+
`flex-direction` following the convention above.
688700

689701
For grid containers, `main` maps to `row`, and `cross` maps to `column`.
690702

File renamed without changes.
4.36 KB
Loading
4.52 KB
Loading
7.01 KB
Loading
7.67 KB
Loading
-12.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)