@linzjs/windows 1.0.0 → 1.1.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/.storybook/main.ts +26 -6
- package/README.md +129 -6
- package/package.json +34 -12
- package/src/modal/Modal.tsx +9 -5
- package/src/modal/ModalContextProvider.tsx +35 -36
- package/src/modal/PreModal.tsx +45 -0
- package/src/panel/OpenPanelButton.tsx +18 -0
- package/src/panel/OpenPanelIcon.scss +73 -0
- package/src/panel/OpenPanelIcon.tsx +50 -0
- package/src/panel/Panel.scss +34 -0
- package/src/panel/Panel.tsx +150 -0
- package/src/panel/PanelContext.ts +17 -0
- package/src/panel/PanelInstanceContext.ts +41 -0
- package/src/panel/PanelInstanceContextProvider.tsx +47 -0
- package/src/panel/PanelsContext.tsx +36 -0
- package/src/panel/PanelsContextProvider.tsx +140 -0
- package/src/panel/PopoutWindow.tsx +183 -0
- package/src/panel/generateId.ts +23 -0
- package/src/panel/handleStyleSheetsChanges.ts +71 -0
- package/src/stories/Introduction.mdx +18 -0
- package/src/stories/Introduction.stories.tsx +8 -0
- package/src/stories/modal/Modal.mdx +9 -3
- package/src/stories/modal/Modal.stories.tsx +1 -1
- package/src/stories/modal/PreModal.mdx +26 -0
- package/src/stories/modal/PreModal.stories.tsx +27 -0
- package/src/stories/modal/PreModal.tsx +79 -0
- package/src/stories/modal/TestModal.scss +21 -0
- package/src/stories/panel/PanelButtons/ShowPanel.mdx +21 -0
- package/src/stories/panel/PanelButtons/ShowPanel.stories.tsx +27 -0
- package/src/stories/panel/PanelButtons/ShowPanel.tsx +86 -0
- package/src/stories/panel/ShowPanel/ShowPanel.mdx +20 -0
- package/src/stories/panel/ShowPanel/ShowPanel.stories.tsx +27 -0
- package/src/stories/panel/ShowPanel/ShowPanel.tsx +70 -0
- package/src/stories/panel/ShowPanelResizingAgGrid/ShowPanelResizingAgGrid.mdx +21 -0
- package/src/stories/panel/ShowPanelResizingAgGrid/ShowPanelResizingAgGrid.stories.tsx +27 -0
- package/src/stories/panel/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +164 -0
- package/src/stories/support.js +16 -0
- package/src/util/useInterval.ts +11 -19
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { throttle } from "lodash-es";
|
|
2
|
+
|
|
3
|
+
// Copy the app's styles into the new window
|
|
4
|
+
export const copyStyleSheets = (newHeadMountElement: HTMLDivElement) => {
|
|
5
|
+
const stylesheets = Array.from(document.styleSheets);
|
|
6
|
+
|
|
7
|
+
stylesheets.forEach((stylesheet) => {
|
|
8
|
+
if (stylesheet.href) {
|
|
9
|
+
const newStyleElement = document.createElement("link");
|
|
10
|
+
newStyleElement.rel = "stylesheet";
|
|
11
|
+
newStyleElement.href = stylesheet.href;
|
|
12
|
+
newHeadMountElement.appendChild(newStyleElement);
|
|
13
|
+
} else {
|
|
14
|
+
const css = stylesheet as CSSStyleSheet;
|
|
15
|
+
if (css && css.cssRules && css.cssRules.length > 0) {
|
|
16
|
+
const newStyleElement = document.createElement("style");
|
|
17
|
+
Array.from(css.cssRules).forEach((rule) => {
|
|
18
|
+
newStyleElement.appendChild(document.createTextNode(rule.cssText));
|
|
19
|
+
});
|
|
20
|
+
newHeadMountElement.appendChild(newStyleElement);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Add listener for dynamic style changes
|
|
27
|
+
* This works by listening to any changes to the head element
|
|
28
|
+
* If there are any changes it replaces all the styles in the floating window
|
|
29
|
+
* at most every 100ms
|
|
30
|
+
* @param newHeadMountElement
|
|
31
|
+
*/
|
|
32
|
+
export const observeStyleSheetChanges = (newHeadMountElement: HTMLDivElement) => {
|
|
33
|
+
const targetNode = document.querySelector("head");
|
|
34
|
+
|
|
35
|
+
if (!targetNode) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
// Options for the observer (which mutations to observe)
|
|
39
|
+
const config = { /*attributes: true,*/ childList: true /*, subtree: true */ };
|
|
40
|
+
|
|
41
|
+
//throttle the copying of the all the styles at most 100ms
|
|
42
|
+
const throttleCopyStyleSheets = throttle(() => {
|
|
43
|
+
copyStyleSheets(newHeadMountElement);
|
|
44
|
+
}, 100);
|
|
45
|
+
|
|
46
|
+
// Callback function to execute when mutations are observed
|
|
47
|
+
const callback: MutationCallback = function (mutationList) {
|
|
48
|
+
for (const mutation of mutationList) {
|
|
49
|
+
if (mutation.type === "childList") {
|
|
50
|
+
// console.log("A child node has been added or removed.", mutation);
|
|
51
|
+
//naive way up updating style sheets
|
|
52
|
+
//the observer tells us what has been added and removed, but syncing the changes with the
|
|
53
|
+
//floating window is complicated, so the easiest way is to just wait for modifications for finish
|
|
54
|
+
//updating, then replace them all
|
|
55
|
+
//we could probably just copy all style on every modification, by that might have a performance hit
|
|
56
|
+
throttleCopyStyleSheets();
|
|
57
|
+
} /*else if (mutation.type === "attributes") {
|
|
58
|
+
//Do we need to handle attribute modifications?
|
|
59
|
+
// console.log("The " + mutation.attributeName + " attribute was modified.");
|
|
60
|
+
}*/
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Create an observer instance linked to the callback function
|
|
65
|
+
const observer = new MutationObserver(callback);
|
|
66
|
+
|
|
67
|
+
// Start observing the target node for configured mutations
|
|
68
|
+
observer.observe(targetNode, config);
|
|
69
|
+
|
|
70
|
+
return observer;
|
|
71
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @linzjs/windows
|
|
2
|
+
|
|
3
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
4
|
+
|
|
5
|
+
> Reusable promise based windowing component for LINZ / Toitū te whenua.
|
|
6
|
+
|
|
7
|
+
Rect state based modals/windows are painful because they require:
|
|
8
|
+
- shared states for open/closed.
|
|
9
|
+
- callbacks/states for return values.
|
|
10
|
+
- inline modal/window includes, which prevent you from closing the invoking component before the modal/window has
|
|
11
|
+
completed.
|
|
12
|
+
|
|
13
|
+
This module gives you promise based modals/windows which don't require all the state
|
|
14
|
+
based boiler-plate / inline-components.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
- Async HTML dialog based Modals.
|
|
18
|
+
- Draggable and resizeable, pop-in/out Windows.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import {getBlocks, blockToString} from "../support.js";
|
|
1
2
|
import {Meta, Source, Story} from "@storybook/blocks";
|
|
2
3
|
import * as ModalStories from "./Modal.stories"
|
|
3
4
|
|
|
4
5
|
import myModule from './TestModal?raw';
|
|
5
6
|
|
|
6
|
-
<Meta
|
|
7
|
+
<Meta name="Show" of={ModalStories}/>
|
|
7
8
|
# Show Modal
|
|
8
9
|
## Example
|
|
9
10
|
Click to show the modal:
|
|
@@ -11,10 +12,15 @@ Click to show the modal:
|
|
|
11
12
|
|
|
12
13
|
## Code
|
|
13
14
|
<br/>
|
|
14
|
-
{myModule
|
|
15
|
+
{getBlocks(myModule).map((block) => (
|
|
15
16
|
<>
|
|
16
17
|
<h3>{block.split("\n")[0]}</h3>
|
|
17
|
-
<Source code={block
|
|
18
|
+
<Source code={blockToString(block)} language="typescript" />
|
|
18
19
|
</>
|
|
19
20
|
))}
|
|
20
21
|
|
|
22
|
+
### Example: Mocking Modal response
|
|
23
|
+
|
|
24
|
+
<Source code={"{ /* Responds with the value 1 */ }\n<ModalContext.Provider value={showModal: async() => 1}>\n" +
|
|
25
|
+
"... Component under test ...\n" +
|
|
26
|
+
"</ModalContext.Provider>\n"} language="typescript"/>
|
|
@@ -3,7 +3,7 @@ import { TestModalUsage } from "./TestModal";
|
|
|
3
3
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof TestModalUsage> = {
|
|
6
|
-
title: "Modal",
|
|
6
|
+
title: "Components/Modal",
|
|
7
7
|
component: TestModalUsage,
|
|
8
8
|
argTypes: {
|
|
9
9
|
backgroundColor: { control: "color" },
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {getBlocks, blockToString} from "../support";
|
|
2
|
+
import {Meta, Source, Story} from "@storybook/blocks";
|
|
3
|
+
import * as PreModalStories from "./PreModal.stories"
|
|
4
|
+
|
|
5
|
+
import myModule from './PreModal?raw';
|
|
6
|
+
|
|
7
|
+
<Meta name="Show Preset Modal" of={PreModalStories}/>
|
|
8
|
+
# Show Preset Modal
|
|
9
|
+
## Example
|
|
10
|
+
Click to show the modal:
|
|
11
|
+
<Story of={PreModalStories.ShowPreModal}/>
|
|
12
|
+
|
|
13
|
+
## Code
|
|
14
|
+
<br/>
|
|
15
|
+
{getBlocks(myModule).map((block) => (
|
|
16
|
+
<>
|
|
17
|
+
<h3>{block.split("\n")[0]}</h3>
|
|
18
|
+
<Source code={blockToString(block)} language="typescript" />
|
|
19
|
+
</>
|
|
20
|
+
))}
|
|
21
|
+
|
|
22
|
+
### Example: Mocking Modal response
|
|
23
|
+
|
|
24
|
+
<Source code={"{ /* Responds with the value 1 */ }\n<ModalContext.Provider value={showModal: async() => 1}>\n" +
|
|
25
|
+
"... Component under test ...\n" +
|
|
26
|
+
"</ModalContext.Provider>\n"} language="typescript"/>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ModalContextProvider } from "../../modal/ModalContextProvider";
|
|
2
|
+
import { PreModalUsage } from "./PreModal";
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof PreModalUsage> = {
|
|
6
|
+
title: "Components/Modal",
|
|
7
|
+
component: PreModalUsage,
|
|
8
|
+
argTypes: {
|
|
9
|
+
backgroundColor: { control: "color" },
|
|
10
|
+
},
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story: any) => (
|
|
13
|
+
<div>
|
|
14
|
+
<ModalContextProvider>
|
|
15
|
+
<Story />
|
|
16
|
+
</ModalContextProvider>
|
|
17
|
+
</div>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
export const ShowPreModal: Story = {
|
|
26
|
+
args: {},
|
|
27
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import "./TestModal.scss";
|
|
2
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
3
|
+
|
|
4
|
+
import { ModalContextProvider } from "../../modal/ModalContextProvider";
|
|
5
|
+
import { PreModal } from "../../modal/PreModal";
|
|
6
|
+
import { useShowModal } from "../../modal/useShowModal";
|
|
7
|
+
|
|
8
|
+
// #Example: Modal Context Provider
|
|
9
|
+
// Don't forget to add a ModalContextProvider at the root of your project
|
|
10
|
+
export const App = () => (
|
|
11
|
+
<ModalContextProvider>
|
|
12
|
+
<div>...the rest of your app...</div>
|
|
13
|
+
</ModalContextProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// #Example: PreModal Invocation
|
|
17
|
+
export const PreModalUsage = () => {
|
|
18
|
+
// showModal to show modal, modalOwnerRef is only required if you have popout windows
|
|
19
|
+
const { showModal, modalOwnerRef } = useShowModal();
|
|
20
|
+
|
|
21
|
+
const showWarningModal = async () => {
|
|
22
|
+
const result = await showModal(PreModal, {
|
|
23
|
+
level: "warning",
|
|
24
|
+
children: (
|
|
25
|
+
<>
|
|
26
|
+
<h2>You are about to make changes</h2>
|
|
27
|
+
<p>Are you sure that you want to make these changes?</p>
|
|
28
|
+
</>
|
|
29
|
+
),
|
|
30
|
+
});
|
|
31
|
+
alert(`Modal result is: ${result}`);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const showInfoModal = async () => {
|
|
35
|
+
await showModal(PreModal, {
|
|
36
|
+
level: "info",
|
|
37
|
+
children: (
|
|
38
|
+
<>
|
|
39
|
+
<h2>You are a fantastic person</h2>
|
|
40
|
+
<p>Keep it up!</p>
|
|
41
|
+
</>
|
|
42
|
+
),
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const showErrorModal = async () => {
|
|
47
|
+
await showModal(PreModal, {
|
|
48
|
+
level: "error",
|
|
49
|
+
children: (
|
|
50
|
+
<>
|
|
51
|
+
<h2>Something is not right</h2>
|
|
52
|
+
<p>Maybe stop doing that</p>
|
|
53
|
+
</>
|
|
54
|
+
),
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const showSuccessModal = async () => {
|
|
59
|
+
await showModal(PreModal, {
|
|
60
|
+
level: "success",
|
|
61
|
+
children: (
|
|
62
|
+
<>
|
|
63
|
+
<h2>You are a success</h2>
|
|
64
|
+
<p>Keep succeeding!</p>
|
|
65
|
+
</>
|
|
66
|
+
),
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Remember to add the modalOwnerRef!
|
|
71
|
+
return (
|
|
72
|
+
<div ref={modalOwnerRef}>
|
|
73
|
+
<button onClick={showWarningModal}>Show Warning Bi-Modal</button>{" "}
|
|
74
|
+
<button onClick={showInfoModal}>Show Info Bi-Modal</button>{" "}
|
|
75
|
+
<button onClick={showErrorModal}>Show Error Bi-Modal</button>{" "}
|
|
76
|
+
<button onClick={showSuccessModal}>Show Success Bi-Modal</button>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
@use "node_modules/@linzjs/lui/dist/scss/Core" as lui;
|
|
2
|
+
@use "node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars.scss" as colours;
|
|
3
|
+
|
|
1
4
|
dialog > div {
|
|
2
5
|
padding: 20px;
|
|
3
6
|
display: flex;
|
|
@@ -12,4 +15,22 @@ dialog > div {
|
|
|
12
15
|
button {
|
|
13
16
|
flex: 1;
|
|
14
17
|
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.lui-modal {
|
|
21
|
+
margin: 0 !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
button:focus {
|
|
25
|
+
outline: 2px solid colours.$brand-primary;
|
|
26
|
+
// make sure the button sits above the others so the outline is not cut off on focus
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
dialog::backdrop {
|
|
31
|
+
background: rgba(0,0,0,0.6);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
dialog {
|
|
35
|
+
border: none;
|
|
15
36
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {getBlocks, blockToString} from "../../support.js";
|
|
2
|
+
import {Meta, Source, Story} from "@storybook/blocks";
|
|
3
|
+
import * as ShowPanelStories from "./ShowPanel.stories"
|
|
4
|
+
|
|
5
|
+
import myModule from './ShowPanel.tsx?raw';
|
|
6
|
+
|
|
7
|
+
<Meta name="Buttons" of={ShowPanelStories}/>
|
|
8
|
+
# Show Panel
|
|
9
|
+
## Example
|
|
10
|
+
Click to show the panel:
|
|
11
|
+
<Story of={ShowPanelStories.ShowPanel}/>
|
|
12
|
+
|
|
13
|
+
## Code
|
|
14
|
+
<br/>
|
|
15
|
+
{getBlocks(myModule).map(block => (
|
|
16
|
+
<>
|
|
17
|
+
<h3>{block.split("\n")[0]}</h3>
|
|
18
|
+
<Source code={blockToString(block)} language='typescript'/>
|
|
19
|
+
</>
|
|
20
|
+
))}
|
|
21
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PanelsContextProvider } from "../../../panel/PanelsContextProvider";
|
|
2
|
+
import { TestShowPanelButtons } from "./ShowPanel";
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof TestShowPanelButtons> = {
|
|
6
|
+
title: "Components/PanelButtons",
|
|
7
|
+
component: TestShowPanelButtons,
|
|
8
|
+
argTypes: {
|
|
9
|
+
backgroundColor: { control: "color" },
|
|
10
|
+
},
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story: any) => (
|
|
13
|
+
<div>
|
|
14
|
+
<PanelsContextProvider baseZIndex={500}>
|
|
15
|
+
<Story />
|
|
16
|
+
</PanelsContextProvider>
|
|
17
|
+
</div>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
export const ShowPanel: Story = {
|
|
26
|
+
args: {},
|
|
27
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
2
|
+
|
|
3
|
+
import { OpenPanelButton } from "../../../panel/OpenPanelButton";
|
|
4
|
+
import {
|
|
5
|
+
ButtonIconHorizontalGroup,
|
|
6
|
+
ButtonIconSeparator,
|
|
7
|
+
ButtonIconVerticalGroup,
|
|
8
|
+
OpenPanelIcon,
|
|
9
|
+
} from "../../../panel/OpenPanelIcon";
|
|
10
|
+
import { Panel, PanelContent, PanelHeader } from "../../../panel/Panel";
|
|
11
|
+
|
|
12
|
+
/* exclude */
|
|
13
|
+
export interface ShowPanelProps {
|
|
14
|
+
data: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ShowPanel = ({ data }: ShowPanelProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<Panel title={`Panel demo ${data}`} size={{ width: 640, height: 400 }}>
|
|
20
|
+
<PanelHeader />
|
|
21
|
+
<PanelContent>
|
|
22
|
+
<PanelContents />
|
|
23
|
+
</PanelContent>
|
|
24
|
+
</Panel>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const PanelContents = () => {
|
|
29
|
+
return (
|
|
30
|
+
<table>
|
|
31
|
+
<thead>
|
|
32
|
+
<tr>
|
|
33
|
+
<th>Owner</th>
|
|
34
|
+
<th>Title</th>
|
|
35
|
+
<th>Address</th>
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
<tbody>
|
|
39
|
+
<tr>
|
|
40
|
+
<td>Roy</td>
|
|
41
|
+
<td>OT10A/1011</td>
|
|
42
|
+
<td>5 Grange St, Auckland</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td>Ryan</td>
|
|
46
|
+
<td>OT10A/154</td>
|
|
47
|
+
<td>145 Garry St, Wellington</td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td>Suzy</td>
|
|
51
|
+
<td>OT10A/155</td>
|
|
52
|
+
<td>15 Aix St, Auckland</td>
|
|
53
|
+
</tr>
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
/* exclude */
|
|
59
|
+
|
|
60
|
+
// #Example: Show Panel Buttons
|
|
61
|
+
export const TestShowPanelButtons = () => (
|
|
62
|
+
<>
|
|
63
|
+
<div>
|
|
64
|
+
<OpenPanelButton buttonText={"Panel name 1"} component={() => <ShowPanel data={1} />} />{" "}
|
|
65
|
+
<OpenPanelButton buttonText={"Panel name 2"} component={() => <ShowPanel data={2} />} />
|
|
66
|
+
</div>
|
|
67
|
+
<br />
|
|
68
|
+
<ButtonIconHorizontalGroup>
|
|
69
|
+
<OpenPanelIcon iconTitle={"Marks"} icon={"ic_marks"} component={() => <ShowPanel data={1} />} />
|
|
70
|
+
<ButtonIconSeparator />
|
|
71
|
+
<OpenPanelIcon iconTitle={"Vectors"} icon={"ic_line_irregular"} component={() => <ShowPanel data={2} />} />
|
|
72
|
+
</ButtonIconHorizontalGroup>
|
|
73
|
+
<br />
|
|
74
|
+
<br />
|
|
75
|
+
<ButtonIconVerticalGroup>
|
|
76
|
+
<OpenPanelIcon iconTitle={"Marks"} icon={"ic_marks"} component={() => <ShowPanel data={1} />} />
|
|
77
|
+
<ButtonIconSeparator />
|
|
78
|
+
<OpenPanelIcon iconTitle={"Vectors"} icon={"ic_timeline"} component={() => <ShowPanel data={2} />} />
|
|
79
|
+
<OpenPanelIcon
|
|
80
|
+
iconTitle={"Irregular lines"}
|
|
81
|
+
icon={"ic_line_irregular"}
|
|
82
|
+
component={() => <ShowPanel data={3} />}
|
|
83
|
+
/>
|
|
84
|
+
</ButtonIconVerticalGroup>
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {getBlocks, blockToString} from "../../support.js";
|
|
2
|
+
import {Meta, Source, Story} from "@storybook/blocks";
|
|
3
|
+
import * as ShowPanelStories from "./ShowPanel.stories.tsx"
|
|
4
|
+
|
|
5
|
+
import myModule from './ShowPanel.tsx?raw';
|
|
6
|
+
|
|
7
|
+
<Meta name="Show" of={ShowPanelStories}/>
|
|
8
|
+
# Show Panel
|
|
9
|
+
## Example
|
|
10
|
+
Click to show the panel:
|
|
11
|
+
<Story of={ShowPanelStories.ShowPanel}/>
|
|
12
|
+
|
|
13
|
+
## Code
|
|
14
|
+
<br/>
|
|
15
|
+
{getBlocks(myModule).map(block => (
|
|
16
|
+
<>
|
|
17
|
+
<h3>{block.split("\n")[0]}</h3>
|
|
18
|
+
<Source code={blockToString(block)} language='typescript'/>
|
|
19
|
+
</>
|
|
20
|
+
))}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PanelsContextProvider } from "../../../panel/PanelsContextProvider";
|
|
2
|
+
import { TestShowPanel } from "./ShowPanel";
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof TestShowPanel> = {
|
|
6
|
+
title: "Components/Panel",
|
|
7
|
+
component: TestShowPanel,
|
|
8
|
+
argTypes: {
|
|
9
|
+
backgroundColor: { control: "color" },
|
|
10
|
+
},
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story: any) => (
|
|
13
|
+
<div>
|
|
14
|
+
<PanelsContextProvider baseZIndex={500}>
|
|
15
|
+
<Story />
|
|
16
|
+
</PanelsContextProvider>
|
|
17
|
+
</div>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
export const ShowPanel: Story = {
|
|
26
|
+
args: {},
|
|
27
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
2
|
+
|
|
3
|
+
import { OpenPanelButton } from "../../../panel/OpenPanelButton";
|
|
4
|
+
import { Panel, PanelContent, PanelHeader } from "../../../panel/Panel";
|
|
5
|
+
import { PanelsContextProvider } from "../../../panel/PanelsContextProvider";
|
|
6
|
+
|
|
7
|
+
// #Example: Panel Context Provider
|
|
8
|
+
// Don't forget to add a PanelContextProvider at the root of your project
|
|
9
|
+
export const App = () => (
|
|
10
|
+
<PanelsContextProvider baseZIndex={500}>
|
|
11
|
+
<div>...the rest of your app...</div>
|
|
12
|
+
</PanelsContextProvider>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// #Example: Panel Component
|
|
16
|
+
export interface ShowPanelComponentProps {
|
|
17
|
+
data: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ShowPanelComponent = ({ data }: ShowPanelComponentProps) => (
|
|
21
|
+
<Panel title={`Panel demo ${data}`} size={{ width: 640, height: 400 }}>
|
|
22
|
+
<PanelHeader />
|
|
23
|
+
<PanelContent>
|
|
24
|
+
<PanelContents />
|
|
25
|
+
</PanelContent>
|
|
26
|
+
</Panel>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
/* exclude */
|
|
30
|
+
export const PanelContents = () => {
|
|
31
|
+
return (
|
|
32
|
+
<table>
|
|
33
|
+
<thead>
|
|
34
|
+
<tr>
|
|
35
|
+
<th>Owner</th>
|
|
36
|
+
<th>Title</th>
|
|
37
|
+
<th>Address</th>
|
|
38
|
+
</tr>
|
|
39
|
+
</thead>
|
|
40
|
+
<tbody>
|
|
41
|
+
<tr>
|
|
42
|
+
<td>Roy</td>
|
|
43
|
+
<td>OT10A/1011</td>
|
|
44
|
+
<td>5 Grange St, Auckland</td>
|
|
45
|
+
</tr>
|
|
46
|
+
<tr>
|
|
47
|
+
<td>Ryan</td>
|
|
48
|
+
<td>OT10A/154</td>
|
|
49
|
+
<td>145 Garry St, Wellington</td>
|
|
50
|
+
</tr>
|
|
51
|
+
<tr>
|
|
52
|
+
<td>Suzy</td>
|
|
53
|
+
<td>OT10A/155</td>
|
|
54
|
+
<td>15 Aix St, Auckland</td>
|
|
55
|
+
</tr>
|
|
56
|
+
</tbody>
|
|
57
|
+
</table>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
/* exclude */
|
|
61
|
+
|
|
62
|
+
// #Example: Panel Invocation
|
|
63
|
+
export const TestShowPanel = () => {
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<OpenPanelButton buttonText={"TestPanel 1"} component={() => <ShowPanelComponent data={1} />} />{" "}
|
|
67
|
+
<OpenPanelButton buttonText={"TestPanel 2"} component={() => <ShowPanelComponent data={2} />} />
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {getBlocks, blockToString} from "../../support.js";
|
|
2
|
+
import {Meta, Source, Story} from "@storybook/blocks";
|
|
3
|
+
import * as PanelStories from "./ShowPanelResizingAgGrid.stories.tsx"
|
|
4
|
+
|
|
5
|
+
import myModule from './ShowPanelResizingStepAgGrid.tsx?raw';
|
|
6
|
+
|
|
7
|
+
<Meta name="Show Resizing step-ag-grid" of={PanelStories}/>
|
|
8
|
+
# Show Panel
|
|
9
|
+
## Example
|
|
10
|
+
Click to show the panel:
|
|
11
|
+
<Story of={PanelStories.PanelResizing}/>
|
|
12
|
+
|
|
13
|
+
## Code
|
|
14
|
+
<br/>
|
|
15
|
+
{getBlocks(myModule).map(block => (
|
|
16
|
+
<>
|
|
17
|
+
<h3>{block.split("\n")[0]}</h3>
|
|
18
|
+
<Source code={blockToString(block)} language='typescript'/>
|
|
19
|
+
</>
|
|
20
|
+
))}
|
|
21
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PanelsContextProvider } from "../../../panel/PanelsContextProvider";
|
|
2
|
+
import { TestShowPanelResizingAgGrid } from "./ShowPanelResizingStepAgGrid";
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof TestShowPanelResizingAgGrid> = {
|
|
6
|
+
title: "Components/Panel",
|
|
7
|
+
component: TestShowPanelResizingAgGrid,
|
|
8
|
+
argTypes: {
|
|
9
|
+
backgroundColor: { control: "color" },
|
|
10
|
+
},
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story: any) => (
|
|
13
|
+
<div>
|
|
14
|
+
<PanelsContextProvider baseZIndex={500}>
|
|
15
|
+
<Story />
|
|
16
|
+
</PanelsContextProvider>
|
|
17
|
+
</div>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
export const PanelResizing: Story = {
|
|
26
|
+
args: {},
|
|
27
|
+
};
|