@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.
- package/dist/client.cjs +95 -58
- package/dist/client.css +537 -537
- package/dist/client.d.cts +30 -26
- package/dist/client.d.ts +30 -26
- package/dist/client.js +95 -58
- package/dist/index.cjs +95 -58
- package/dist/index.css +537 -537
- package/dist/index.d.cts +30 -26
- package/dist/index.d.ts +30 -26
- package/dist/index.js +95 -58
- package/dist/web-components/index.d.ts +9 -5
- package/dist/web-components/index.js +53 -9
- package/package.json +1 -1
- package/src/components/layout/Grid/Grid.mdx +4 -2
- package/src/components/layout/Grid/Grid.spec.tsx +62 -6
- package/src/components/layout/Grid/Grid.stories.tsx +16 -9
- package/src/components/layout/Grid/Grid.tsx +11 -6
- package/src/components/layout/Grid/masonry.ts +88 -18
- package/src/web-components/layout/BdsGrid.mdx +5 -3
- package/src/web-components/layout/BdsGrid.stories.tsx +16 -10
- package/src/web-components/layout/bds-grid.spec.ts +3 -3
- package/src/web-components/layout/bds-grid.ts +19 -6
|
@@ -60,11 +60,11 @@ describe('bds-grid', () => {
|
|
|
60
60
|
cleanup(el);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
it('reflects masonry-preferred-column-span as a
|
|
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="
|
|
65
|
+
'<bds-grid is-masonry masonry-preferred-column-span="half"></bds-grid>',
|
|
66
66
|
) as BdsGrid;
|
|
67
|
-
expect(el.masonryPreferredColumnSpan).toBe(
|
|
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
|
|
20
|
-
* `column-span` attribute try to span this
|
|
21
|
-
*
|
|
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:
|
|
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:
|
|
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.
|
|
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();
|