@wordpress/grid 0.5.0 → 0.6.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/CHANGELOG.md +8 -0
- package/build/dashboard-grid/index.cjs +3 -3
- package/build/dashboard-grid/index.cjs.map +2 -2
- package/build/dashboard-lanes/index.cjs +3 -3
- package/build/dashboard-lanes/index.cjs.map +2 -2
- package/build-module/dashboard-grid/index.mjs +3 -3
- package/build-module/dashboard-grid/index.mjs.map +2 -2
- package/build-module/dashboard-lanes/index.mjs +3 -3
- package/build-module/dashboard-lanes/index.mjs.map +2 -2
- package/package.json +10 -9
- package/src/dashboard-grid/grid.module.css +6 -6
- package/src/dashboard-grid/index.tsx +1 -1
- package/src/dashboard-grid/stories/index.story.tsx +15 -0
- package/src/dashboard-lanes/index.tsx +1 -1
- package/src/dashboard-lanes/lanes.module.css +6 -6
- package/src/dashboard-lanes/stories/index.story.tsx +25 -0
- package/src/dashboard-lanes/test/use-lane-placement.test.tsx +10 -3
- package/build-types/dashboard-grid/stories/index.story.d.ts +0 -92
- package/build-types/dashboard-grid/stories/index.story.d.ts.map +0 -1
- package/build-types/dashboard-lanes/stories/index.story.d.ts +0 -58
- package/build-types/dashboard-lanes/stories/index.story.d.ts.map +0 -1
|
@@ -44,7 +44,7 @@ import styles from './lanes.module.css';
|
|
|
44
44
|
|
|
45
45
|
const dashboardDragDropAnimation = createDashboardDragDropAnimation(
|
|
46
46
|
styles[ 'drag-preview-frame' ],
|
|
47
|
-
styles
|
|
47
|
+
styles[ 'is-exiting' ]
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
// Fallback gap in pixels for math that runs before the computed gap
|
|
@@ -100,14 +100,14 @@
|
|
|
100
100
|
* is replaced.
|
|
101
101
|
*/
|
|
102
102
|
@media not (prefers-reduced-motion: reduce) {
|
|
103
|
-
.drag-preview-frame.
|
|
103
|
+
.drag-preview-frame.is-exiting {
|
|
104
104
|
animation:
|
|
105
105
|
wp-grid-drag-preview-shadow-exit
|
|
106
106
|
var(--wpds-motion-duration-md) var(--wpds-motion-easing-balanced)
|
|
107
107
|
forwards;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
.drag-preview-frame.
|
|
110
|
+
.drag-preview-frame.is-exiting .drag-preview-frame__lift {
|
|
111
111
|
animation:
|
|
112
112
|
wp-grid-drag-preview-scale-exit
|
|
113
113
|
var(--wpds-motion-duration-md) var(--wpds-motion-easing-balanced)
|
|
@@ -135,11 +135,11 @@
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
.drag-preview-frame.
|
|
138
|
+
.drag-preview-frame.is-exiting {
|
|
139
139
|
box-shadow: var(--_wp-grid-elevation-xs);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
.drag-preview-frame.
|
|
142
|
+
.drag-preview-frame.is-exiting .drag-preview-frame__lift {
|
|
143
143
|
transform: scale(1);
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -152,12 +152,12 @@
|
|
|
152
152
|
transform: none;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
.drag-preview-frame.
|
|
155
|
+
.drag-preview-frame.is-exiting {
|
|
156
156
|
box-shadow: var(--_wp-grid-elevation-xs);
|
|
157
157
|
transition: none;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
.drag-preview-frame.
|
|
160
|
+
.drag-preview-frame.is-exiting .drag-preview-frame__lift {
|
|
161
161
|
transition: none;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -187,6 +187,11 @@ export const Default: Story = {
|
|
|
187
187
|
* frame to see the lane count adapt.
|
|
188
188
|
*/
|
|
189
189
|
export const Responsive: Story = {
|
|
190
|
+
parameters: {
|
|
191
|
+
// FIXME: Resize handles are nameless aria commands; edit mode nests interactive controls (aria-command-name, nested-interactive).
|
|
192
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
193
|
+
a11y: { test: 'todo' },
|
|
194
|
+
},
|
|
190
195
|
args: {
|
|
191
196
|
minColumnWidth: 200,
|
|
192
197
|
layout: [
|
|
@@ -216,6 +221,11 @@ export const Responsive: Story = {
|
|
|
216
221
|
* tiles below `minColumnWidth`.
|
|
217
222
|
*/
|
|
218
223
|
export const Layered: Story = {
|
|
224
|
+
parameters: {
|
|
225
|
+
// FIXME: Resize handles are nameless aria commands; edit mode nests interactive controls (aria-command-name, nested-interactive).
|
|
226
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
227
|
+
a11y: { test: 'todo' },
|
|
228
|
+
},
|
|
219
229
|
args: {
|
|
220
230
|
columns: 4,
|
|
221
231
|
minColumnWidth: 200,
|
|
@@ -244,6 +254,11 @@ export const Layered: Story = {
|
|
|
244
254
|
* lanes.
|
|
245
255
|
*/
|
|
246
256
|
export const Spanning: Story = {
|
|
257
|
+
parameters: {
|
|
258
|
+
// FIXME: Resize handles are nameless aria commands; edit mode nests interactive controls (aria-command-name, nested-interactive).
|
|
259
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
260
|
+
a11y: { test: 'todo' },
|
|
261
|
+
},
|
|
247
262
|
args: {
|
|
248
263
|
columns: 4,
|
|
249
264
|
layout: [
|
|
@@ -287,6 +302,11 @@ export const Spanning: Story = {
|
|
|
287
302
|
* story below for a full override example.
|
|
288
303
|
*/
|
|
289
304
|
export const EditMode: Story = {
|
|
305
|
+
parameters: {
|
|
306
|
+
// FIXME: Resize handles are nameless aria commands; edit mode nests interactive controls (aria-command-name, nested-interactive).
|
|
307
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
308
|
+
a11y: { test: 'todo' },
|
|
309
|
+
},
|
|
290
310
|
args: {
|
|
291
311
|
columns: 4,
|
|
292
312
|
editMode: true,
|
|
@@ -433,6 +453,11 @@ function NumberedLanesOverlay( { columns, isActive }: GridOverlayRenderProps ) {
|
|
|
433
453
|
* entirely while keeping `editMode` interactions on.
|
|
434
454
|
*/
|
|
435
455
|
export const CustomGridOverlayStory: Story = {
|
|
456
|
+
parameters: {
|
|
457
|
+
// FIXME: Resize handles are nameless aria commands; edit mode nests interactive controls (aria-command-name, nested-interactive).
|
|
458
|
+
// See: https://github.com/WordPress/gutenberg/issues/81596
|
|
459
|
+
a11y: { test: 'todo' },
|
|
460
|
+
},
|
|
436
461
|
name: 'Custom Grid Overlay',
|
|
437
462
|
args: {
|
|
438
463
|
columns: 4,
|
|
@@ -77,9 +77,16 @@ function setNativeSupport( supported: boolean ) {
|
|
|
77
77
|
if ( property === 'display' && value === 'grid-lanes' ) {
|
|
78
78
|
return supported;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
if ( ! originalSupports ) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/*
|
|
84
|
+
* `call` on the overloaded `CSS.supports` resolves to the
|
|
85
|
+
* single-argument signature, so pass equivalent condition text.
|
|
86
|
+
*/
|
|
87
|
+
return value === undefined
|
|
88
|
+
? originalSupports.call( CSS, property )
|
|
89
|
+
: originalSupports.call( CSS, `(${ property }: ${ value })` );
|
|
83
90
|
};
|
|
84
91
|
}
|
|
85
92
|
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { DashboardGrid } from '..';
|
|
3
|
-
declare const meta: Meta<typeof DashboardGrid>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof DashboardGrid>;
|
|
6
|
-
/**
|
|
7
|
-
* Static grid with a fixed number of columns. Each item declares its
|
|
8
|
-
* column span via `width`. Items flow left-to-right and wrap to new
|
|
9
|
-
* rows as the total exceeds `columns`.
|
|
10
|
-
*/
|
|
11
|
-
export declare const Default: Story;
|
|
12
|
-
/**
|
|
13
|
-
* Responsive grid: the column count is derived from the container
|
|
14
|
-
* width using `minColumnWidth` as the lower bound per column. A
|
|
15
|
-
* `ResizeObserver` recomputes the count on container resize.
|
|
16
|
-
*/
|
|
17
|
-
export declare const Responsive: Story;
|
|
18
|
-
/**
|
|
19
|
-
* Layered configuration: `columns` caps the count and
|
|
20
|
-
* `minColumnWidth` enforces a per-tile width floor. The grid renders
|
|
21
|
-
* up to `columns` columns on wide containers and reduces the count
|
|
22
|
-
* on narrow ones whenever fitting all of them would push tiles
|
|
23
|
-
* below `minColumnWidth`. Resize the preview to see the cap apply
|
|
24
|
-
* on wide widths and the floor reduce the count on narrow widths.
|
|
25
|
-
*/
|
|
26
|
-
export declare const Layered: Story;
|
|
27
|
-
/**
|
|
28
|
-
* A `width: 'fill'` item expands to cover the remaining columns in
|
|
29
|
-
* its row. Mix it with fixed-width items on either side to build
|
|
30
|
-
* sidebar-like layouts that adapt to the column count.
|
|
31
|
-
*/
|
|
32
|
-
export declare const FillWidth: Story;
|
|
33
|
-
/**
|
|
34
|
-
* A `width: 'full'` item spans every column (`grid-column: 1 / -1`),
|
|
35
|
-
* forcing a row break around it. Useful for dividers, hero banners,
|
|
36
|
-
* or embedded content that should always take the full width.
|
|
37
|
-
*/
|
|
38
|
-
export declare const FullWidth: Story;
|
|
39
|
-
/**
|
|
40
|
-
* Numeric `rowHeight` lets items span multiple rows via `height`.
|
|
41
|
-
* Combined with `width`, this produces tile-based dashboards where
|
|
42
|
-
* each cell can be tuned independently.
|
|
43
|
-
*/
|
|
44
|
-
export declare const RowHeight: Story;
|
|
45
|
-
/**
|
|
46
|
-
* Edit mode with drag, resize, and all width modes. While `editMode`
|
|
47
|
-
* is on, `<DashboardGrid />` paints its default overlay behind the
|
|
48
|
-
* tiles to visualize the underlying template: rounded row-marker
|
|
49
|
-
* tiles in each column when `rowHeight` is numeric. The overlay
|
|
50
|
-
* disappears when `editMode` flips back to `false`.
|
|
51
|
-
*
|
|
52
|
-
* Theme the default look in place via `--wp-grid-overlay-tile-bg`,
|
|
53
|
-
* or replace the visual wholesale by passing `renderGridOverlay`.
|
|
54
|
-
* See the `Custom Grid Overlay` story for a full override example.
|
|
55
|
-
*
|
|
56
|
-
* A state panel shows the raw layout JSON. Drag items to reorder;
|
|
57
|
-
* resize from the bottom-right handle. Keyboard sensor is enabled:
|
|
58
|
-
* use Tab to focus an item, Space to grab, arrow keys to move, Space
|
|
59
|
-
* to drop.
|
|
60
|
-
*/
|
|
61
|
-
export declare const EditMode: Story;
|
|
62
|
-
/**
|
|
63
|
-
* Exercises the three customization vectors on a single grid:
|
|
64
|
-
*
|
|
65
|
-
* 1. `renderResizeHandle` swaps the default corner triangle for a
|
|
66
|
-
* custom diagonal-arrow icon.
|
|
67
|
-
* 2. `renderDragPreview` wraps the dragged clone (here only for the
|
|
68
|
-
* height chain; lift and shadow stay on the grid frame).
|
|
69
|
-
* 3. CSS custom properties on an ancestor retheme the lift scale,
|
|
70
|
-
* placeholder opacity, placeholder outline color, and placeholder
|
|
71
|
-
* border-radius without touching the package.
|
|
72
|
-
*
|
|
73
|
-
* Toggle `editMode`, then drag and resize a tile to see all three
|
|
74
|
-
* respond.
|
|
75
|
-
*/
|
|
76
|
-
export declare const Customization: Story;
|
|
77
|
-
/**
|
|
78
|
-
* Replaces the package's default edit-mode overlay with a custom
|
|
79
|
-
* visual through the `renderGridOverlay` prop. The grid mounts the
|
|
80
|
-
* supplied component as a sibling behind the tiles whenever
|
|
81
|
-
* `editMode` is on, passing the resolved `{ columns, rowHeight }`
|
|
82
|
-
* so the override can reproduce the column and row tracks
|
|
83
|
-
* pixel-accurately without re-deriving them.
|
|
84
|
-
*
|
|
85
|
-
* Here the override (see `NumberedOverlay` above) swaps the warning
|
|
86
|
-
* tone for info, drops the row dividers, and labels each column
|
|
87
|
-
* track with its index. Pass `renderGridOverlay={ () => null }` to
|
|
88
|
-
* suppress the overlay entirely while keeping `editMode` interactions
|
|
89
|
-
* on.
|
|
90
|
-
*/
|
|
91
|
-
export declare const CustomGridOverlayStory: Story;
|
|
92
|
-
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/dashboard-grid/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK5D,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAQnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,aAAa,CAuCrC,CAAC;eACa,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,aAAa,CAAE,CAAC;AAgM9C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KA4BrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,KAiCxB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAAE,KAkCrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KAwBvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KA4BvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KA6BvB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,EAAE,KA8JtB,CAAC;AAoEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,EAAE,KA6D3B,CAAC;AAoEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAmDpC,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { DashboardLanes } from '..';
|
|
3
|
-
declare const meta: Meta<typeof DashboardLanes>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof DashboardLanes>;
|
|
6
|
-
/**
|
|
7
|
-
* Mixed-height tiles in a fixed lane count. Items pack from
|
|
8
|
-
* left-to-right by source order, falling into whichever lane has
|
|
9
|
-
* the lowest baseline at the moment of placement.
|
|
10
|
-
*/
|
|
11
|
-
export declare const Default: Story;
|
|
12
|
-
/**
|
|
13
|
-
* Responsive lane count: derived from container width using
|
|
14
|
-
* `minColumnWidth` as the per-lane lower bound. Resize the preview
|
|
15
|
-
* frame to see the lane count adapt.
|
|
16
|
-
*/
|
|
17
|
-
export declare const Responsive: Story;
|
|
18
|
-
/**
|
|
19
|
-
* Layered configuration: `columns` caps the lane count and
|
|
20
|
-
* `minColumnWidth` enforces a per-tile width floor. The surface
|
|
21
|
-
* renders up to `columns` lanes on wide containers and reduces the
|
|
22
|
-
* count on narrow ones whenever fitting all of them would push
|
|
23
|
-
* tiles below `minColumnWidth`.
|
|
24
|
-
*/
|
|
25
|
-
export declare const Layered: Story;
|
|
26
|
-
/**
|
|
27
|
-
* Items with `width: 2` span two lanes. The skyline picks a span
|
|
28
|
-
* position that minimizes the resulting baseline across spanned
|
|
29
|
-
* lanes.
|
|
30
|
-
*/
|
|
31
|
-
export declare const Spanning: Story;
|
|
32
|
-
/**
|
|
33
|
-
* Edit mode: drag to reorder, resize from the bottom-right corner
|
|
34
|
-
* (horizontal only — heights are content-driven). Drop commits the
|
|
35
|
-
* new layout via `onChangeLayout`.
|
|
36
|
-
*
|
|
37
|
-
* While `editMode` is on, `<DashboardLanes />` paints its default
|
|
38
|
-
* overlay behind the tiles to mark the lane tracks. Lanes paint
|
|
39
|
-
* columns only — there are no row markers because heights are
|
|
40
|
-
* content-driven.
|
|
41
|
-
*
|
|
42
|
-
* Theme the default look in place via `--wp-grid-overlay-tile-bg`,
|
|
43
|
-
* or replace the visual wholesale
|
|
44
|
-
* by passing `renderGridOverlay`. See the `Custom Grid Overlay`
|
|
45
|
-
* story below for a full override example.
|
|
46
|
-
*/
|
|
47
|
-
export declare const EditMode: Story;
|
|
48
|
-
/**
|
|
49
|
-
* Replaces the surface's default edit-mode overlay with a custom
|
|
50
|
-
* visual through the `renderGridOverlay` prop. The same contract as
|
|
51
|
-
* `<DashboardGrid />`'s override path, with `rowHeight` omitted from
|
|
52
|
-
* the render props because lanes are content-driven vertically.
|
|
53
|
-
*
|
|
54
|
-
* Pass `renderGridOverlay={ () => null }` to suppress the overlay
|
|
55
|
-
* entirely while keeping `editMode` interactions on.
|
|
56
|
-
*/
|
|
57
|
-
export declare const CustomGridOverlayStory: Story;
|
|
58
|
-
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/dashboard-lanes/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAIpC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,cAAc,CA6CtC,CAAC;eACa,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,cAAc,CAAE,CAAC;AAkF/C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KAwCrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,KAoBxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,EAAE,KAqBrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,KA0BtB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,EAAE,KAuEtB,CAAC;AAkEF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAwEpC,CAAC"}
|