@timmo001/groundwork-ui 0.8.0 → 0.9.1

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.
@@ -3250,12 +3250,18 @@
3250
3250
  "kind": "field",
3251
3251
  "name": "#lead",
3252
3252
  "privacy": "private",
3253
+ "type": {
3254
+ "text": "HTMLSpanElement"
3255
+ },
3253
3256
  "readonly": true
3254
3257
  },
3255
3258
  {
3256
3259
  "kind": "field",
3257
3260
  "name": "#text",
3258
3261
  "privacy": "private",
3262
+ "type": {
3263
+ "text": "HTMLSpanElement"
3264
+ },
3259
3265
  "readonly": true
3260
3266
  },
3261
3267
  {
@@ -21389,13 +21395,17 @@
21389
21395
  },
21390
21396
  {
21391
21397
  "kind": "class",
21392
- "description": "Fills as many columns as fit, each at least `--gw-grid-min` wide.",
21398
+ "description": "Fills as many columns as fit, each at least `--gw-grid-min` wide, and at\nmost `max` of them when it's set.",
21393
21399
  "name": "GwGrid",
21394
21400
  "cssProperties": [
21395
21401
  {
21396
21402
  "description": "The narrowest a column gets. Defaults to `18rem`.",
21397
21403
  "name": "--gw-grid-min"
21398
21404
  },
21405
+ {
21406
+ "description": "The most columns it shows, as a number. Unset by default, so as many fit as the width allows.",
21407
+ "name": "--gw-grid-max"
21408
+ },
21399
21409
  {
21400
21410
  "description": "The gap. Defaults to `--gw-space-3`.",
21401
21411
  "name": "--gw-gap"
@@ -21415,7 +21425,7 @@
21415
21425
  "text": "readonly CSSStyleSheet[]"
21416
21426
  },
21417
21427
  "static": true,
21418
- "default": "[ base, gaps, css` :host { display: grid; grid-template-columns: repeat( auto-fill, minmax(min(100%, var(--gw-grid-min, 18rem)), 1fr) ); gap: var(--gw-gap, var(--gw-space-3)); } `, ]",
21428
+ "default": "[ base, gaps, css` :host { /* A column's width at the cap. Invalid while --gw-grid-max is unset, so the var() below falls back to 0px and the cap does nothing */ --_gw-grid-cap: calc( (100% - (var(--gw-grid-max) - 1) * var(--gw-gap, var(--gw-space-3))) / var(--gw-grid-max) ); display: grid; grid-template-columns: repeat( auto-fill, minmax( min(100%, max(var(--gw-grid-min, 18rem), var(--_gw-grid-cap, 0px))), 1fr ) ); gap: var(--gw-gap, var(--gw-space-3)); } :host([max=\"2\"]) { --gw-grid-max: 2; } :host([max=\"3\"]) { --gw-grid-max: 3; } :host([max=\"4\"]) { --gw-grid-max: 4; } :host([max=\"5\"]) { --gw-grid-max: 5; } :host([max=\"6\"]) { --gw-grid-max: 6; } `, ]",
21419
21429
  "inheritedFrom": {
21420
21430
  "name": "GwElement",
21421
21431
  "module": "src/element.ts"
@@ -21753,6 +21763,13 @@
21753
21763
  },
21754
21764
  "description": "A smaller or larger gap.",
21755
21765
  "name": "gap"
21766
+ },
21767
+ {
21768
+ "type": {
21769
+ "text": "\"2\"|\"3\"|\"4\"|\"5\"|\"6\""
21770
+ },
21771
+ "description": "The most columns it shows. Sets `--gw-grid-max`.",
21772
+ "name": "max"
21756
21773
  }
21757
21774
  ],
21758
21775
  "superclass": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmo001/groundwork-ui",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Groundwork's framework-free web components, styled by the --gw-* tokens",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/gw-button.ts CHANGED
@@ -366,7 +366,9 @@ export class GwButton extends GwElement {
366
366
 
367
367
  readonly #swatch = h("span", { class: "swatch", "aria-hidden": "true" });
368
368
 
369
- readonly #lead = h(
369
+ // Typed, since inferring through h() and the tag map that holds this
370
+ // element is circular for consumers that type-check the source
371
+ readonly #lead: HTMLSpanElement = h(
370
372
  "span",
371
373
  { class: "lead" },
372
374
  this.#icon,
@@ -375,7 +377,7 @@ export class GwButton extends GwElement {
375
377
  h("span", { class: "ring" }),
376
378
  );
377
379
 
378
- readonly #text = h("span", { class: "text" }, h("slot"));
380
+ readonly #text: HTMLSpanElement = h("span", { class: "text" }, h("slot"));
379
381
 
380
382
  readonly #over = h("span", { class: "ring over" });
381
383
 
package/src/layout.ts CHANGED
@@ -138,16 +138,19 @@ export class GwRow extends GwSlotted {
138
138
  }
139
139
 
140
140
  /**
141
- * Fills as many columns as fit, each at least `--gw-grid-min` wide.
141
+ * Fills as many columns as fit, each at least `--gw-grid-min` wide, and at
142
+ * most `max` of them when it's set.
142
143
  *
143
144
  * @element gw-grid
144
145
  * @summary Children in responsive columns.
145
146
  *
146
147
  * @attr {"s"|"l"} gap - A smaller or larger gap.
148
+ * @attr {"2"|"3"|"4"|"5"|"6"} max - The most columns it shows. Sets `--gw-grid-max`.
147
149
  *
148
150
  * @slot - The children.
149
151
  *
150
152
  * @cssprop --gw-grid-min - The narrowest a column gets. Defaults to `18rem`.
153
+ * @cssprop --gw-grid-max - The most columns it shows, as a number. Unset by default, so as many fit as the width allows.
151
154
  * @cssprop --gw-gap - The gap. Defaults to `--gw-space-3`.
152
155
  */
153
156
  export class GwGrid extends GwSlotted {
@@ -156,13 +159,42 @@ export class GwGrid extends GwSlotted {
156
159
  gaps,
157
160
  css`
158
161
  :host {
162
+ /* A column's width at the cap. Invalid while --gw-grid-max is unset,
163
+ so the var() below falls back to 0px and the cap does nothing */
164
+ --_gw-grid-cap: calc(
165
+ (100% - (var(--gw-grid-max) - 1) * var(--gw-gap, var(--gw-space-3))) /
166
+ var(--gw-grid-max)
167
+ );
159
168
  display: grid;
160
169
  grid-template-columns: repeat(
161
170
  auto-fill,
162
- minmax(min(100%, var(--gw-grid-min, 18rem)), 1fr)
171
+ minmax(
172
+ min(100%, max(var(--gw-grid-min, 18rem), var(--_gw-grid-cap, 0px))),
173
+ 1fr
174
+ )
163
175
  );
164
176
  gap: var(--gw-gap, var(--gw-space-3));
165
177
  }
178
+
179
+ :host([max="2"]) {
180
+ --gw-grid-max: 2;
181
+ }
182
+
183
+ :host([max="3"]) {
184
+ --gw-grid-max: 3;
185
+ }
186
+
187
+ :host([max="4"]) {
188
+ --gw-grid-max: 4;
189
+ }
190
+
191
+ :host([max="5"]) {
192
+ --gw-grid-max: 5;
193
+ }
194
+
195
+ :host([max="6"]) {
196
+ --gw-grid-max: 6;
197
+ }
166
198
  `,
167
199
  ];
168
200
  }