@boostdev/design-system-components 2.3.0 → 2.4.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.
@@ -60,11 +60,11 @@ describe('bds-grid', () => {
60
60
  cleanup(el);
61
61
  });
62
62
 
63
- it('reflects masonry-preferred-column-span as a number property', async () => {
63
+ it('reflects masonry-preferred-column-span as a string property', async () => {
64
64
  const el = await fixture(
65
- '<bds-grid is-masonry masonry-preferred-column-span="2"></bds-grid>',
65
+ '<bds-grid is-masonry masonry-preferred-column-span="half"></bds-grid>',
66
66
  ) as BdsGrid;
67
- expect(el.masonryPreferredColumnSpan).toBe(2);
67
+ expect(el.masonryPreferredColumnSpan).toBe('half');
68
68
  cleanup(el);
69
69
  });
70
70
  });
@@ -1,5 +1,6 @@
1
1
  import { LitElement, css, html } from 'lit';
2
2
  import { applyMasonryLayout, clearMasonryLayout, supportsNativeMasonry } from '../../components/layout/Grid/masonry';
3
+ import type { GridItemSpanValue } from '../../components/layout/Grid/GridItem';
3
4
 
4
5
  export type GridVariant = 'main' | 'page' | 'funnel' | 'custom';
5
6
 
@@ -16,9 +17,12 @@ export type GridVariant = 'main' | 'page' | 'funnel' | 'custom';
16
17
  * auto-span-media — boolean; child `<bds-grid-item>`s without a `column-span`
17
18
  * attribute resolve their span from the intrinsic aspect
18
19
  * ratio of their first `<img>`/`<video>` child.
19
- * masonry-preferred-column-span — number; masonry only. Child items without a
20
- * `column-span` attribute try to span this many columns; an
21
- * item at row-end is demoted to the remaining column count.
20
+ * masonry-preferred-column-span — named span or number; masonry only. Child
21
+ * items without a `column-span` attribute try to span this
22
+ * value (e.g. `"half"`, `"one-third"`). Named values adapt
23
+ * across breakpoints via the foundation's responsive column
24
+ * tokens. An item at row-end is demoted to the remaining
25
+ * column count. Numeric values are literal and don't adapt.
22
26
  *
23
27
  * Slots:
24
28
  * (default) — grid content; typically `<bds-grid-item>` children
@@ -80,7 +84,7 @@ export class BdsGrid extends LitElement {
80
84
  isMasonry: { type: Boolean, attribute: 'is-masonry', reflect: true },
81
85
  autoSpanMedia: { type: Boolean, attribute: 'auto-span-media', reflect: true },
82
86
  masonryPreferredColumnSpan: {
83
- type: Number,
87
+ type: String,
84
88
  attribute: 'masonry-preferred-column-span',
85
89
  reflect: true,
86
90
  },
@@ -91,7 +95,7 @@ export class BdsGrid extends LitElement {
91
95
  declare isCentered: boolean;
92
96
  declare isMasonry: boolean;
93
97
  declare autoSpanMedia: boolean;
94
- declare masonryPreferredColumnSpan: number | undefined;
98
+ declare masonryPreferredColumnSpan: string | undefined;
95
99
 
96
100
  private _ro?: ResizeObserver;
97
101
  private _mo?: MutationObserver;
@@ -156,12 +160,21 @@ export class BdsGrid extends LitElement {
156
160
  const container = this._gridEl();
157
161
  if (container) {
158
162
  applyMasonryLayout(container, this._items(), {
159
- preferredColumnSpan: this.masonryPreferredColumnSpan,
163
+ preferredColumnSpan: this._resolvePreferredColumnSpan(),
160
164
  });
161
165
  }
162
166
  });
163
167
  }
164
168
 
169
+ private _resolvePreferredColumnSpan(): Exclude<GridItemSpanValue, 'auto'> | undefined {
170
+ const raw = this.masonryPreferredColumnSpan;
171
+ if (raw === undefined || raw === null || raw === '') return undefined;
172
+ // Numeric attribute → literal column count; otherwise treat as a named span.
173
+ const n = Number(raw);
174
+ if (Number.isFinite(n) && String(n) === raw) return n;
175
+ return raw as Exclude<GridItemSpanValue, 'auto'>;
176
+ }
177
+
165
178
  private _teardownMasonry() {
166
179
  cancelAnimationFrame(this._frame);
167
180
  this._ro?.disconnect();