Skip to content

Commit 4909a8c

Browse files
authored
Showcase refurb (#1571)
* migrate showcase from vuu-layout to grid-layout * rewrite grid spliytter resiz I * IFrame should respond to location changes * adopt features of flexbox splitter in grid splitter * fix bug, splitter fails with iframe * fix margin issues with griditems adjoining splitters * fix issue in showcase tree building * add file watcher to showcase
1 parent 91f5a93 commit 4909a8c

31 files changed

+4565
-1404
lines changed

vuu-ui/package-lock.json

Lines changed: 47 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vuu-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"deploy:websocket-test": "node ./tools/deploy-websocket-test.mjs",
3838
"view-bundle": "node ./scripts/visualize-bundle.mjs",
3939
"type-defs": "node ./scripts/build-all-type-defs.mjs",
40-
"showcase": "cd showcase && tsx ../tools/vuu-showcase/scripts/showcase-vite-api.ts",
40+
"showcase": "cd showcase && tsx ../tools/vuu-showcase/scripts/showcase-dev.ts",
4141
"showcase:prod": "npm run build:worker && cd showcase && tsx ../tools/vuu-showcase/scripts/showcase-build.ts",
4242
"test:cypress": "npm run build:worker && cypress run --component --browser chrome --headless",
4343
"test:cypress:local": "cypress open --component --browser chrome",

vuu-ui/packages/grid-layout/src/GridLayout.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
&.vuuResizing {
2121
transition: .3s;
2222
}
23+
24+
&.vuuFullPage {
25+
height: 100vh;
26+
width: 100vw;
27+
}
28+
2329
}
2430

2531
.vuuGridLayoutItem {
@@ -34,6 +40,13 @@
3440
grid-column: 0/0 !important;
3541
grid-row: 0/0;
3642
}
43+
44+
&.has-h-splitter:not(.vuu-stacked) {
45+
margin-top: 7px;
46+
}
47+
&.has-v-splitter {
48+
margin-left: 7px;
49+
}
3750
}
3851

3952
.vuuGridLayoutItem-active {
@@ -82,7 +95,12 @@
8295
}
8396

8497
.vuu-stacked {
85-
margin-top: var(--vuu-layout-tabs-height)
98+
&.has-h-splitter {
99+
margin-top: calc(var(--vuu-layout-tabs-height) + 7px);
100+
}
101+
&:not(.has-h-splitter){
102+
margin-top: var(--vuu-layout-tabs-height);
103+
}
86104
}
87105

88106
.vuuGridLayoutItemHeader-close {

vuu-ui/packages/grid-layout/src/GridLayout.tsx

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,22 @@ import { useWindow } from "@salt-ds/window";
55
import cx from "clsx";
66
import { CSSProperties, HTMLAttributes, ReactElement } from "react";
77
import { DragDropProviderNext } from "./drag-drop-next/DragDropProviderNext";
8-
import type { ResizeOrientation } from "./grid-dom-utils";
98
import { getGridArea } from "./grid-layout-utils";
109
import { GridLayoutContext } from "./GridLayoutContext";
1110
import { GridLayoutItemProps } from "./GridLayoutItem";
1211
import { GridLayoutStackedItem } from "./GridLayoutStackedtem";
13-
import {
14-
AriaOrientation,
15-
GridColumnsAndRows,
16-
GridLayoutChangeHandler,
17-
} from "./GridModel";
12+
import { GridColumnsAndRows, GridLayoutChangeHandler } from "./GridModel";
1813
import { GridPlaceholder } from "./GridPlaceholder";
1914
import { useGridLayout } from "./useGridLayout";
2015
import { useGridSplitterResizing } from "./useGridSplitterResizing";
16+
import { GridSplitter } from "./GridSplitter";
2117

2218
import gridLayoutCss from "./GridLayout.css";
2319

2420
const classBase = "vuuGridLayout";
2521

2622
export type GridResizeable = "h" | "v" | "hv";
2723

28-
export interface GridSplitterProps extends HTMLAttributes<HTMLDivElement> {
29-
"aria-controls": string;
30-
ariaOrientation: AriaOrientation;
31-
orientation: ResizeOrientation;
32-
}
33-
34-
const NO_DRAG_SOURCES = {} as const;
35-
36-
export const GridSplitter = ({
37-
"aria-controls": ariaControls,
38-
ariaOrientation,
39-
orientation,
40-
...htmlAttributes
41-
}: GridSplitterProps) => {
42-
const id = `${ariaControls}-splitter-${orientation[0]}`;
43-
return (
44-
<div
45-
{...htmlAttributes}
46-
aria-controls={ariaControls}
47-
aria-orientation={ariaOrientation}
48-
className="vuuGridSplitter"
49-
id={id}
50-
role="separator"
51-
/>
52-
);
53-
};
54-
5524
export interface GridLayoutProps
5625
extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
5726
children?:
@@ -62,6 +31,8 @@ export interface GridLayoutProps
6231
onChange?: GridLayoutChangeHandler;
6332
}
6433

34+
const NO_DRAG_SOURCES = {} as const;
35+
6536
export const GridLayout = ({
6637
id: idProp,
6738
children: childrenProp,
@@ -108,6 +79,8 @@ export const GridLayout = ({
10879
onClick,
10980
});
11081

82+
// const splitterProps = useGridSplitter();
83+
11184
const style = {
11285
...gridModel.tracks.css,
11386
...styleProp,
@@ -162,6 +135,7 @@ export const GridLayout = ({
162135
))}
163136
{splitters.map((splitter) => (
164137
<GridSplitter
138+
// {...splitterProps}
165139
aria-controls={splitter.controls}
166140
ariaOrientation={splitter.ariaOrientation}
167141
id={splitter.id}

vuu-ui/packages/grid-layout/src/GridLayoutItem.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
useGridLayoutDragStartHandler,
2323
} from "./GridLayoutContext";
2424
import { GridModelChildItemProps } from "./GridModel";
25-
import gridSplitterCss from "./GridSplitter.css";
2625
import { useDraggable } from "./useDraggable";
2726
import { useGridChildProps } from "./useGridChildProps";
2827
import { IconButton } from "./IconButton";
@@ -90,11 +89,6 @@ export const GridLayoutItem = ({
9089
css: gridLayoutCss,
9190
window: targetWindow,
9291
});
93-
useComponentCssInjection({
94-
testId: "vuu-grid-splitter",
95-
css: gridSplitterCss,
96-
window: targetWindow,
97-
});
9892

9993
const dispatch = useGridLayoutDispatch();
10094
// TODO pass the styleProp in here to initialise the model value
@@ -103,8 +97,10 @@ export const GridLayoutItem = ({
10397
contentVisible,
10498
dropTarget,
10599
header,
100+
horizontalSplitter,
106101
stacked,
107102
title,
103+
verticalSplitter,
108104
...layoutProps
109105
} = useGridChildProps({
110106
contentVisible: contentVisibleProp,
@@ -150,6 +146,8 @@ export const GridLayoutItem = ({
150146
const className = cx(classBaseItem, {
151147
"vuu-detached": contentDetached,
152148
"vuu-stacked": stacked && !contentDetached,
149+
"has-h-splitter": horizontalSplitter,
150+
"has-v-splitter": verticalSplitter,
153151
});
154152

155153
const style = {

vuu-ui/packages/grid-layout/src/GridLayoutStackedtem.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ export const GridLayoutStackedItem = ({
5353
registerTabsForDragDrop(id);
5454
}, [id, registerTabsForDragDrop]);
5555

56-
const layoutProps = useGridChildProps({
57-
id,
58-
resizeable,
59-
style: styleProp,
60-
type: "stacked-content",
61-
});
56+
const { horizontalSplitter, verticalSplitter, ...layoutProps } =
57+
useGridChildProps({
58+
id,
59+
resizeable,
60+
style: styleProp,
61+
type: "stacked-content",
62+
});
6263

6364
const { getTabState } = useGridModel();
6465
const tabState = getTabState(id);
@@ -70,7 +71,10 @@ export const GridLayoutStackedItem = ({
7071
[tabState],
7172
);
7273

73-
const className = cx(classBaseItem, "vuuGridLayoutItem");
74+
const className = cx(classBaseItem, "vuuGridLayoutItem", {
75+
"has-h-splitter": horizontalSplitter,
76+
"has-v-splitter": verticalSplitter,
77+
});
7478

7579
const style = {
7680
...styleProp,

vuu-ui/packages/grid-layout/src/GridModel.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,13 @@ export class GridModelChildItem implements IGridModelChildItem {
248248
dropTarget?: boolean | string;
249249
header?: boolean;
250250
height?: number;
251+
horizontalSplitter = false;
251252
stackId?: string;
252253
resizeable: GridModelItemResizeable;
253254
row: GridModelPosition;
254255
title?: string;
255256
type: GridModelItemType;
257+
verticalSplitter = false;
256258
width?: number;
257259

258260
#dragging = false;
@@ -1260,13 +1262,18 @@ export class GridModel extends EventEmitter<GridModelEvents> {
12601262
row: { start: rowStart, end: rowEnd },
12611263
} = targetChild;
12621264
const stackId = uuid();
1265+
12631266
const stackChild = new GridModelChildItem({
12641267
column: { start: colStart, end: colEnd },
12651268
id: stackId,
12661269
row: { start: rowStart, end: rowEnd },
12671270
type: "stacked-content",
12681271
});
12691272

1273+
const { horizontalSplitter: h, verticalSplitter: v } = targetChild;
1274+
stackChild.horizontalSplitter = stackedChild.horizontalSplitter = h;
1275+
stackChild.verticalSplitter = stackedChild.verticalSplitter = v;
1276+
12701277
this.setTabState(stackId, [targetChild, stackedChild]);
12711278

12721279
this.addChildItem(stackChild);
@@ -1390,6 +1397,10 @@ export class GridModel extends EventEmitter<GridModelEvents> {
13901397
}
13911398

13921399
getSplitters() {
1400+
this.#childItems.forEach((childItem) => {
1401+
childItem.horizontalSplitter = false;
1402+
childItem.verticalSplitter = false;
1403+
});
13931404
return this.#childItems.flatMap(this.getSplittersForChildItem);
13941405
}
13951406

@@ -1405,7 +1416,11 @@ export class GridModel extends EventEmitter<GridModelEvents> {
14051416

14061417
if (!isFixedWidthChildItem(childItem)) {
14071418
const columnContrasAndSiblings =
1408-
this.findColContrasAndSiblings(childItem);
1419+
this.findColumnContrasAndSiblings(childItem);
1420+
1421+
console.log(`column contrasAndSiblings for #${childItem.id}`, {
1422+
columnContrasAndSiblings,
1423+
});
14091424

14101425
if (columnContrasAndSiblings) {
14111426
const resizeTrackIndex = column.start - 1;
@@ -1416,6 +1431,10 @@ export class GridModel extends EventEmitter<GridModelEvents> {
14161431
after: columnContrasAndSiblings.siblings.map((c) => c.id),
14171432
};
14181433

1434+
columnContrasAndSiblings.siblings.forEach((childItem) => {
1435+
childItem.verticalSplitter = true;
1436+
});
1437+
14191438
splitters.push({
14201439
align: "start",
14211440
ariaOrientation: "vertical",
@@ -1448,6 +1467,10 @@ export class GridModel extends EventEmitter<GridModelEvents> {
14481467
after: rowContrasAndSiblings.siblings.map((c) => c.id),
14491468
};
14501469

1470+
rowContrasAndSiblings.siblings.forEach((childItem) => {
1471+
childItem.horizontalSplitter = true;
1472+
});
1473+
14511474
splitters.push({
14521475
align: "start",
14531476
ariaOrientation: "horizontal",
@@ -1472,7 +1495,7 @@ export class GridModel extends EventEmitter<GridModelEvents> {
14721495
return splitters;
14731496
};
14741497

1475-
private findColContrasAndSiblings(childItem: GridModelChildItem) {
1498+
private findColumnContrasAndSiblings(childItem: GridModelChildItem) {
14761499
const contrasLeft = this.getContrasLeft(childItem);
14771500
if (contrasLeft.length > 0) {
14781501
const siblingsBelow = this.getSiblingsBelow(childItem);

0 commit comments

Comments
 (0)