@surflane/css 0.23.1 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,8 @@
18
18
  .surf-container[data-width='wide'] {
19
19
  max-width: var(--surf-layout-wide);
20
20
  }
21
+ /* Without a gap of their own, blocks sit a gutter apart: 24px, 16px on a phone and
22
+ 12px in compact density. */
21
23
  .surf-stack,
22
24
  .surf-inline,
23
25
  .surf-grid {
@@ -97,7 +99,10 @@
97
99
  .surf-surface {
98
100
  box-sizing: border-box;
99
101
  min-width: 0;
100
- padding: var(--surf-surface-padding, var(--surf-space-6));
102
+ padding: var(
103
+ --surf-surface-padding,
104
+ var(--surf-ui-density-padding, var(--surf-space-6))
105
+ );
101
106
  border-radius: var(--surf-radius-lg);
102
107
  background: var(--surf-surface);
103
108
  color: var(--surf-ink);
@@ -3,9 +3,11 @@
3
3
  surflane.sizes;
4
4
 
5
5
  @layer surflane.base {
6
+ /* Compact density keeps 8px between the breadcrumb, the copy and the actions,
7
+ and 4px between actions; the heading and its description keep theirs. */
6
8
  .surf-page-header {
7
9
  display: grid;
8
- gap: var(--surf-page-header-breadcrumb-gap);
10
+ gap: var(--surf-ui-density-inset, var(--surf-page-header-breadcrumb-gap));
9
11
  min-width: 0;
10
12
  margin: 0;
11
13
  }
@@ -14,7 +16,7 @@
14
16
  flex-wrap: wrap;
15
17
  align-items: flex-start;
16
18
  justify-content: space-between;
17
- gap: var(--surf-space-4);
19
+ gap: var(--surf-ui-density-inset, var(--surf-space-4));
18
20
  min-width: 0;
19
21
  }
20
22
  .surf-page-header-copy {
@@ -34,6 +36,6 @@
34
36
  max-inline-size: 100%;
35
37
  display: flex;
36
38
  flex-wrap: wrap;
37
- gap: var(--surf-space-2);
39
+ gap: var(--surf-ui-density-item, var(--surf-space-2));
38
40
  }
39
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surflane/css",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "description": "Surflane's CSS-only layer: control, layout composition, document typography and presentation classes that work without React, on top of @surflane/design-tokens.",
5
5
  "keywords": [
6
6
  "design-system",
@@ -37,7 +37,7 @@
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "peerDependencies": {
40
- "@surflane/design-tokens": "^0.23.1"
40
+ "@surflane/design-tokens": "^0.24.0"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -6,7 +6,8 @@
6
6
  /* A notice for the whole product: a full-width plane in its tone, square, with the
7
7
  icon, the title and description in one line where they fit, then the actions
8
8
  and the dismiss button at the end. Parts keep their own spacing, so a missing
9
- part leaves no gap. */
9
+ part leaves no gap. Compact density pads it 4px above and below, sets the
10
+ actions 8px after the text and 4px apart. */
10
11
  .surf-banner {
11
12
  box-sizing: border-box;
12
13
  display: grid;
@@ -14,7 +15,7 @@
14
15
  grid-template-areas: 'icon content actions dismiss';
15
16
  align-items: center;
16
17
  min-inline-size: 0;
17
- padding-block: var(--surf-space-2);
18
+ padding-block: var(--surf-ui-density-row-padding, var(--surf-space-2));
18
19
  padding-inline: var(--surf-banner-inset, var(--surf-space-4));
19
20
  background: var(--surf-status-info-bg);
20
21
  color: var(--surf-status-info-fg);
@@ -50,8 +51,8 @@
50
51
  grid-area: actions;
51
52
  display: flex;
52
53
  flex-wrap: wrap;
53
- gap: var(--surf-space-2);
54
- margin-inline-start: var(--surf-space-4);
54
+ gap: var(--surf-ui-density-item, var(--surf-space-2));
55
+ margin-inline-start: var(--surf-ui-density-inset, var(--surf-space-4));
55
56
  }
56
57
  .surf-banner > .surf-banner-dismiss {
57
58
  grid-area: dismiss;
@@ -3,15 +3,19 @@
3
3
  surflane.sizes;
4
4
 
5
5
  @layer surflane.components {
6
- /* Cards use one surface; children provide hierarchy without extra frames. */
6
+ /* Cards use one surface; children provide hierarchy without extra frames. Compact
7
+ density pads a card 12px and keeps 8px between its parts. */
7
8
  .surf-card {
8
9
  /* Stretched to a taller neighbor in a row, a card keeps its parts at the top
9
10
  and its footer at the bottom, so the footers of a row line up. */
10
11
  display: flex;
11
12
  flex-direction: column;
12
- gap: var(--surf-space-4);
13
+ gap: var(--surf-ui-density-inset, var(--surf-space-4));
13
14
  min-width: 0;
14
- padding: var(--surf-surface-padding, var(--surf-space-6));
15
+ padding: var(
16
+ --surf-surface-padding,
17
+ var(--surf-ui-density-padding, var(--surf-space-6))
18
+ );
15
19
  border-radius: var(--surf-radius-lg);
16
20
  background: var(--surf-surface);
17
21
  color: var(--surf-ink-body);
@@ -36,14 +40,22 @@
36
40
  gap: var(--surf-space-2);
37
41
  min-width: 0;
38
42
  }
43
+ /* Compact density titles a card with the label role: in a grid of them, a title
44
+ names what the card holds. */
39
45
  .surf-card-title {
40
46
  margin: 0;
41
47
  color: var(--surf-ink);
42
48
  font-weight: var(--surf-weight-medium);
43
- font-size: var(--surf-type-section-size);
44
- line-height: var(--surf-type-section-leading);
49
+ font-size: var(--surf-ui-density-title-size, var(--surf-type-section-size));
50
+ line-height: var(
51
+ --surf-ui-density-title-leading,
52
+ var(--surf-type-section-leading)
53
+ );
45
54
  font-family: var(--surf-font-body);
46
- letter-spacing: var(--surf-type-section-tracking);
55
+ letter-spacing: var(
56
+ --surf-ui-density-title-tracking,
57
+ var(--surf-type-section-tracking)
58
+ );
47
59
  overflow-wrap: anywhere;
48
60
  }
49
61
  /* A card that opens something: its title's action stretches over it. The card is
@@ -123,7 +135,7 @@
123
135
  flex-wrap: wrap;
124
136
  align-items: center;
125
137
  justify-content: space-between;
126
- gap: var(--surf-space-3);
138
+ gap: var(--surf-ui-density-inset, var(--surf-space-3));
127
139
  }
128
140
  /* A bar, such as a Meter, takes a line of its own in the footer. */
129
141
  .surf-card-footer > .surf-gauge {
@@ -14,8 +14,8 @@
14
14
  flex-wrap: wrap;
15
15
  align-items: center;
16
16
  justify-content: space-between;
17
- gap: var(--surf-space-3);
18
- margin-bottom: var(--surf-space-3);
17
+ gap: var(--surf-ui-density-inset, var(--surf-space-3));
18
+ margin-bottom: var(--surf-ui-density-inset, var(--surf-space-3));
19
19
  }
20
20
  .surf-code-label {
21
21
  display: inline-flex;
@@ -37,9 +37,10 @@
37
37
  background: var(--surf-code-bg);
38
38
  border-radius: var(--surf-radius-md);
39
39
  }
40
+ /* Compact density pads the code 12px. */
40
41
  .surf-code-text {
41
42
  margin: 0;
42
- padding: var(--surf-space-4);
43
+ padding: var(--surf-ui-density-padding, var(--surf-space-4));
43
44
  font-weight: var(--surf-weight-regular);
44
45
  font-size: var(--surf-type-code-size);
45
46
  line-height: var(--surf-type-code-leading);
@@ -7,15 +7,26 @@
7
7
  line centered, so a badge or a copy action fits without growing it: the term in
8
8
  muted ink in a column of its own width, the value beside it in ink. Where a row
9
9
  is too narrow for both, the value moves under its term. No lines between rows:
10
- the term column and the rhythm carry the structure. */
10
+ the term column and the rhythm carry the structure. Compact density takes the
11
+ 32px row, 4px above and below a stacked pair, 8px between a term and its value
12
+ and 12px between columns. */
11
13
  .surf-description-list {
12
14
  --surf-description-list-term-width: 10rem;
13
15
  --surf-description-list-value-min-width: 10rem;
14
16
  --surf-description-list-column-min-width: 22rem;
15
- --surf-description-list-row: var(--surf-size-row-default);
17
+ --surf-description-list-row: var(
18
+ --surf-ui-density-row,
19
+ var(--surf-size-row-default)
20
+ );
16
21
  --surf-description-list-leading: var(--surf-size-leading-default);
17
- --surf-description-list-gap: var(--surf-space-8);
18
- --surf-description-list-stack-padding: var(--surf-space-2);
22
+ --surf-description-list-gap: var(
23
+ --surf-ui-density-gap,
24
+ var(--surf-space-8)
25
+ );
26
+ --surf-description-list-stack-padding: var(
27
+ --surf-ui-density-row-padding,
28
+ var(--surf-space-2)
29
+ );
19
30
  display: grid;
20
31
  grid-template-columns: minmax(0, 1fr);
21
32
  align-items: start;
@@ -46,7 +57,7 @@
46
57
  flex-wrap: wrap;
47
58
  align-content: center;
48
59
  align-items: baseline;
49
- column-gap: var(--surf-space-4);
60
+ column-gap: var(--surf-ui-density-inset, var(--surf-space-4));
50
61
  min-inline-size: 0;
51
62
  min-block-size: var(--surf-description-list-row);
52
63
  }
@@ -109,14 +120,4 @@
109
120
  .surf-description-list-value > .surf-copy-button {
110
121
  flex: none;
111
122
  }
112
- /* Compact: a small row, for dense panels. A list in a compact density scope is
113
- compact unless it says density='default'. */
114
- .surf-description-list:is(
115
- [data-density='compact'],
116
- :where([data-ui-density='compact'] :not([data-density]))
117
- ) {
118
- --surf-description-list-row: var(--surf-size-row-small);
119
- --surf-description-list-gap: var(--surf-space-6);
120
- --surf-description-list-stack-padding: var(--surf-space-1);
121
- }
122
123
  }
@@ -3,14 +3,16 @@
3
3
  surflane.sizes;
4
4
 
5
5
  @layer surflane.components {
6
+ /* Compact density pads an empty state 12px, sets its actions 8px under the text
7
+ and 4px apart. */
6
8
  .surf-empty-actions {
7
9
  display: flex;
8
10
  flex-wrap: wrap;
9
- gap: var(--surf-space-2);
10
- margin-top: var(--surf-space-4);
11
+ gap: var(--surf-ui-density-item, var(--surf-space-2));
12
+ margin-top: var(--surf-ui-density-inset, var(--surf-space-4));
11
13
  }
12
14
  .surf-empty {
13
- padding: var(--surf-space-6);
15
+ padding: var(--surf-ui-density-padding, var(--surf-space-6));
14
16
  text-align: center;
15
17
  color: var(--surf-ink-body);
16
18
  overflow-wrap: anywhere;
@@ -45,7 +47,7 @@
45
47
  }
46
48
  @media (max-width: 560px) {
47
49
  .surf-empty {
48
- padding: var(--surf-space-4);
50
+ padding: var(--surf-ui-density-padding, var(--surf-space-4));
49
51
  }
50
52
  }
51
53
  }
@@ -3,11 +3,12 @@
3
3
  surflane.sizes;
4
4
 
5
5
  @layer surflane.components {
6
+ /* Compact density pads a message 12px and sets its actions 4px apart. */
6
7
  .surf-message {
7
8
  display: flex;
8
9
  align-items: flex-start;
9
10
  gap: var(--surf-space-3);
10
- padding: var(--surf-space-4);
11
+ padding: var(--surf-ui-density-padding, var(--surf-space-4));
11
12
  border-radius: var(--surf-radius-md);
12
13
  background: var(--surf-status-neutral-bg);
13
14
  color: var(--surf-status-neutral-fg);
@@ -58,7 +59,7 @@
58
59
  .surf-message-actions {
59
60
  display: flex;
60
61
  flex-wrap: wrap;
61
- gap: var(--surf-space-2);
62
+ gap: var(--surf-ui-density-item, var(--surf-space-2));
62
63
  margin-top: var(--surf-space-4);
63
64
  }
64
65
  @media (forced-colors: active) {
@@ -3,9 +3,11 @@
3
3
  surflane.sizes;
4
4
 
5
5
  @layer surflane.components {
6
+ /* Compact density sets items 4px apart and pads each 4px above and below and
7
+ 12px at its sides, like a compact table's rows. */
6
8
  .surf-list {
7
9
  display: grid;
8
- gap: var(--surf-space-2);
10
+ gap: var(--surf-ui-density-item, var(--surf-space-2));
9
11
  padding: 0;
10
12
  margin: 0;
11
13
  list-style: none;
@@ -14,8 +16,9 @@
14
16
  .surf-list-item {
15
17
  display: flex;
16
18
  align-items: center;
17
- gap: var(--surf-space-4);
18
- padding: var(--surf-space-3) var(--surf-space-4);
19
+ gap: var(--surf-ui-density-inset, var(--surf-space-4));
20
+ padding: var(--surf-ui-density-row-padding, var(--surf-space-3))
21
+ var(--surf-ui-density-padding, var(--surf-space-4));
19
22
  border-radius: var(--surf-radius-md);
20
23
  min-width: 0;
21
24
  }
@@ -52,7 +55,7 @@
52
55
  display: flex;
53
56
  align-items: center;
54
57
  flex-wrap: wrap;
55
- gap: var(--surf-space-2);
58
+ gap: var(--surf-ui-density-item, var(--surf-space-2));
56
59
  flex: none;
57
60
  }
58
61
  @media (max-width: 560px) {
@@ -3,11 +3,15 @@
3
3
  surflane.sizes;
4
4
 
5
5
  @layer surflane.components {
6
- /* Native data structures preserve table/list semantics and generous hover insets. */
6
+ /* Native data structures preserve table/list semantics and generous hover insets.
7
+ * Rows sit half an item apart: 4px, or 2px in compact density, which also pads a
8
+ * cell 4px above and below and 12px at its sides, for scanning many records. */
7
9
  .surf-table {
8
10
  width: 100%;
9
11
  border-collapse: separate;
10
- --surf-table-row-space: var(--surf-space-1);
12
+ --surf-table-row-space: calc(
13
+ var(--surf-ui-density-item, var(--surf-space-2)) / 2
14
+ );
11
15
  border-spacing: 0 var(--surf-table-row-space);
12
16
  font: inherit;
13
17
  color: var(--surf-ink-body);
@@ -44,10 +48,12 @@
44
48
  text-align: start;
45
49
  font-weight: var(--surf-weight-regular);
46
50
  color: var(--surf-ink);
47
- padding: 0 var(--surf-space-4) var(--surf-space-3);
51
+ padding: 0 var(--surf-ui-density-padding, var(--surf-space-4))
52
+ var(--surf-ui-density-inset, var(--surf-space-3));
48
53
  }
49
54
  .surf-table-cell {
50
- padding: var(--surf-space-3) var(--surf-space-4);
55
+ padding: var(--surf-ui-density-row-padding, var(--surf-space-3))
56
+ var(--surf-ui-density-padding, var(--surf-space-4));
51
57
  text-align: start;
52
58
  vertical-align: middle;
53
59
  border: 0;
@@ -149,16 +155,6 @@
149
155
  .surf-table-sort[data-sort] .surf-table-sort-icon {
150
156
  color: var(--surf-ink);
151
157
  }
152
- /* Compact density: 4px row padding and 2px between rows, for scanning many
153
- * records with a pointer. It overrides the component size's cell padding. */
154
- /* A table in a compact density scope is compact unless it says density='default'. */
155
- .surf-table:is(
156
- [data-density='compact'],
157
- :where([data-ui-density='compact'] :not([data-density]))
158
- ) {
159
- --surf-table-row-space: 2px;
160
- border-spacing: 0 var(--surf-table-row-space);
161
- }
162
158
  /* Lined, grid and striped rows meet edge to edge, square, so lines and stripes
163
159
  * run unbroken. Lines stay inside the table: none above the header, below the
164
160
  * last row or at its sides. */
@@ -214,20 +210,22 @@
214
210
  /* A bleeding container hangs by the cell inset, which density and size set; it
215
211
  outranks the scroll root's own width cap. */
216
212
  .surf-scroll-root.surf-table-bleed {
217
- --surf-table-bleed: var(--surf-space-4);
213
+ --surf-table-bleed: var(--surf-ui-density-padding, var(--surf-space-4));
218
214
  max-inline-size: none;
219
215
  margin-inline: calc(-1 * var(--surf-table-bleed));
220
216
  }
221
217
  :where([data-ui-size], [data-ui-size] *).surf-scroll-root.surf-table-bleed {
222
- --surf-table-bleed: var(--surf-ui-table-padding-x);
218
+ --surf-table-bleed: var(
219
+ --surf-ui-density-padding,
220
+ var(--surf-ui-table-padding-x)
221
+ );
222
+ }
223
+ /* A table that sets its own density sets its container's bleed. */
224
+ .surf-scroll-root.surf-table-bleed:has(.surf-table[data-density='compact']) {
225
+ --surf-table-bleed: var(--surf-density-padding-compact);
223
226
  }
224
- .surf-scroll-root.surf-table-bleed:has(
225
- .surf-table:is(
226
- [data-density='compact'],
227
- :where([data-ui-density='compact'] :not([data-density]))
228
- )
229
- ) {
230
- --surf-table-bleed: var(--surf-space-3);
227
+ .surf-scroll-root.surf-table-bleed:has(.surf-table[data-density='default']) {
228
+ --surf-table-bleed: var(--surf-ui-table-padding-x, var(--surf-space-4));
231
229
  }
232
230
  /* A sticky header needs a Container with a bounded block size that scrolls
233
231
  * vertically. --surf-table-surface matches the surface behind the table; --table-surface
@@ -372,19 +370,22 @@
372
370
  .surf-table-header > .surf-button:where(:not([data-size^='icon'])) {
373
371
  padding-inline: var(--surf-space-3);
374
372
  }
375
- .surf-table:is(
376
- [data-density='compact'],
377
- :where([data-ui-density='compact'] :not([data-density]))
378
- )
379
- .surf-table-cell {
380
- padding: var(--surf-space-1) var(--surf-space-3);
381
- }
382
- .surf-table:is(
383
- [data-density='compact'],
384
- :where([data-ui-density='compact'] :not([data-density]))
385
- )
386
- .surf-table-sort {
387
- height: auto;
388
- min-height: 28px;
373
+ /* A sort control is part of its header row, so in compact density it takes the
374
+ row's space, not a control's size: its line and the row padding, no less than
375
+ the 24px target. Out of compact the compact height is invalid and the control
376
+ keeps the Button's height. */
377
+ .surf-table-header > .surf-table-sort {
378
+ --surf-table-sort-compact-height: max(
379
+ var(--surf-control-target-size-min),
380
+ calc(1lh + 2 * var(--surf-ui-density-row-padding))
381
+ );
382
+ block-size: var(
383
+ --surf-table-sort-compact-height,
384
+ var(--surf-control-height)
385
+ );
386
+ min-block-size: var(
387
+ --surf-table-sort-compact-height,
388
+ var(--surf-control-height)
389
+ );
389
390
  }
390
391
  }
@@ -19,12 +19,14 @@
19
19
  font-family: var(--surf-font-body);
20
20
  letter-spacing: var(--surf-type-body-tracking);
21
21
  }
22
+ /* Compact density pads an event 4px above and below. */
22
23
  .surf-timeline-item {
23
24
  display: grid;
24
25
  grid-template-columns: auto minmax(0, 1fr);
25
26
  column-gap: var(--surf-space-3);
26
27
  min-inline-size: 0;
27
- padding: var(--surf-space-2) var(--surf-space-3);
28
+ padding: var(--surf-ui-density-row-padding, var(--surf-space-2))
29
+ var(--surf-space-3);
28
30
  border-radius: var(--surf-radius-md);
29
31
  }
30
32
  /* The current step is recessed one step from its plane, and what it holds sits on