@linzjs/windows 1.1.1 → 1.1.2
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/package.json +1 -1
- package/src/modal/{PreModal.tsx → PrefabModal.tsx} +22 -2
- package/src/panel/OpenPanelIcon.tsx +7 -3
- package/src/stories/modal/{PreModal.mdx → PrefabModal.mdx} +4 -4
- package/src/stories/modal/{PreModal.stories.tsx → PrefabModal.stories.tsx} +4 -4
- package/src/stories/modal/PrefabModal.tsx +48 -0
- package/src/stories/panel/PanelButtons/ShowPanel.tsx +4 -5
- package/src/stories/modal/PreModal.tsx +0 -79
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Modal } from "./Modal";
|
|
2
2
|
import { ModalCallback } from "./ModalContext";
|
|
3
|
+
import { useShowModal } from "./useShowModal";
|
|
3
4
|
import { ReactElement } from "react";
|
|
4
5
|
|
|
5
6
|
import { LuiAlertModalButtons, LuiButton, LuiIcon } from "@linzjs/lui";
|
|
@@ -7,7 +8,7 @@ import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
|
|
|
7
8
|
|
|
8
9
|
export type WarningLevel = "success" | "info" | "warning" | "error";
|
|
9
10
|
|
|
10
|
-
export interface
|
|
11
|
+
export interface PrefabModalProps extends ModalCallback<boolean> {
|
|
11
12
|
level?: WarningLevel;
|
|
12
13
|
children: ReactElement;
|
|
13
14
|
}
|
|
@@ -24,7 +25,7 @@ export const getIconForLevel = (level: "success" | "info" | "warning" | "error")
|
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
export const
|
|
28
|
+
export const PrefabModal = ({ level = "warning", children, resolve }: PrefabModalProps) => {
|
|
28
29
|
const icon = getIconForLevel(level);
|
|
29
30
|
return (
|
|
30
31
|
<Modal>
|
|
@@ -43,3 +44,22 @@ export const PreModal = ({ level = "warning", children, resolve }: PreModalProps
|
|
|
43
44
|
</Modal>
|
|
44
45
|
);
|
|
45
46
|
};
|
|
47
|
+
|
|
48
|
+
export const usePrefabModal = () => {
|
|
49
|
+
const { showModal, modalOwnerRef } = useShowModal();
|
|
50
|
+
return {
|
|
51
|
+
modalOwnerRef,
|
|
52
|
+
showPrefabModal: (level: WarningLevel, title: ReactElement | string, content: ReactElement | string) => {
|
|
53
|
+
const children = (
|
|
54
|
+
<>
|
|
55
|
+
{typeof title === "string" ? <h2>{title}</h2> : title}
|
|
56
|
+
{typeof content === "string" ? <p>{content}</p> : content}
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
return showModal(PrefabModal, {
|
|
60
|
+
level,
|
|
61
|
+
children,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -9,11 +9,15 @@ import { LuiIcon } from "@linzjs/lui";
|
|
|
9
9
|
import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
|
|
10
10
|
|
|
11
11
|
export const ButtonIconHorizontalGroup = ({ children }: { children: ReactNode }) => (
|
|
12
|
-
<div
|
|
12
|
+
<div>
|
|
13
|
+
<div className={"OpenPanelIcon-horizontalGroup"}>{children}</div>
|
|
14
|
+
</div>
|
|
13
15
|
);
|
|
14
16
|
|
|
15
17
|
export const ButtonIconVerticalGroup = ({ children }: { children: ReactNode }) => (
|
|
16
|
-
<div
|
|
18
|
+
<div>
|
|
19
|
+
<div className={"OpenPanelIcon-verticalGroup"}>{children}</div>
|
|
20
|
+
</div>
|
|
17
21
|
);
|
|
18
22
|
|
|
19
23
|
export const ButtonIconSeparator = () => <div className="OpenPanelIcon-separator"> </div>;
|
|
@@ -37,7 +41,7 @@ export const OpenPanelIcon = ({ iconTitle, uniqueId, icon, component, className,
|
|
|
37
41
|
className={clsx(
|
|
38
42
|
className,
|
|
39
43
|
"lui-button lui-button-secondary lui-button-toolbar panel-button",
|
|
40
|
-
openPanels.has(
|
|
44
|
+
openPanels.has(id.current) && "OpenPanelIcon-selected",
|
|
41
45
|
disabled && "OpenPanelIcon-disabled",
|
|
42
46
|
)}
|
|
43
47
|
title={iconTitle}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {getBlocks, blockToString} from "../support";
|
|
2
2
|
import {Meta, Source, Story} from "@storybook/blocks";
|
|
3
|
-
import * as
|
|
3
|
+
import * as PrefabModalStories from "./PrefabModal.stories"
|
|
4
4
|
|
|
5
|
-
import myModule from './
|
|
5
|
+
import myModule from './PrefabModal?raw';
|
|
6
6
|
|
|
7
|
-
<Meta name="Show
|
|
7
|
+
<Meta name="Show Prefab" of={PrefabModalStories}/>
|
|
8
8
|
# Show Preset Modal
|
|
9
9
|
## Example
|
|
10
10
|
Click to show the modal:
|
|
11
|
-
<Story of={
|
|
11
|
+
<Story of={PrefabModalStories.ShowPrefabModal}/>
|
|
12
12
|
|
|
13
13
|
## Code
|
|
14
14
|
<br/>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ModalContextProvider } from "../../modal/ModalContextProvider";
|
|
2
|
-
import {
|
|
2
|
+
import { PrefabModalUsage } from "./PrefabModal";
|
|
3
3
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
4
|
|
|
5
|
-
const meta: Meta<typeof
|
|
5
|
+
const meta: Meta<typeof PrefabModalUsage> = {
|
|
6
6
|
title: "Components/Modal",
|
|
7
|
-
component:
|
|
7
|
+
component: PrefabModalUsage,
|
|
8
8
|
argTypes: {
|
|
9
9
|
backgroundColor: { control: "color" },
|
|
10
10
|
},
|
|
@@ -22,6 +22,6 @@ const meta: Meta<typeof PreModalUsage> = {
|
|
|
22
22
|
export default meta;
|
|
23
23
|
type Story = StoryObj<typeof meta>;
|
|
24
24
|
|
|
25
|
-
export const
|
|
25
|
+
export const ShowPrefabModal: Story = {
|
|
26
26
|
args: {},
|
|
27
27
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import "./TestModal.scss";
|
|
2
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
3
|
+
|
|
4
|
+
import { ModalContextProvider } from "../../modal/ModalContextProvider";
|
|
5
|
+
import { usePrefabModal } from "../../modal/PrefabModal";
|
|
6
|
+
|
|
7
|
+
// #Example: Modal Context Provider
|
|
8
|
+
// Don't forget to add a ModalContextProvider at the root of your project
|
|
9
|
+
export const App = () => (
|
|
10
|
+
<ModalContextProvider>
|
|
11
|
+
<div>...the rest of your app...</div>
|
|
12
|
+
</ModalContextProvider>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// #Example: PrefabModal Invocation
|
|
16
|
+
export const PrefabModalUsage = () => {
|
|
17
|
+
// showModal to show modal, modalOwnerRef is only required if you have popout windows
|
|
18
|
+
const { modalOwnerRef, showPrefabModal } = usePrefabModal();
|
|
19
|
+
|
|
20
|
+
// Remember to add the modalOwnerRef!
|
|
21
|
+
return (
|
|
22
|
+
<div ref={modalOwnerRef} style={{ display: "flex", gap: 10 }}>
|
|
23
|
+
<button
|
|
24
|
+
onClick={async () =>
|
|
25
|
+
alert(
|
|
26
|
+
"Warning result: " +
|
|
27
|
+
(await showPrefabModal(
|
|
28
|
+
"warning",
|
|
29
|
+
"You are about to make changes",
|
|
30
|
+
"Are you sure that you want to make these changes?",
|
|
31
|
+
)),
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
Warning Prefab-Modal
|
|
36
|
+
</button>
|
|
37
|
+
<button onClick={() => showPrefabModal("info", "You are a fantastic person", "Keep it up!")}>
|
|
38
|
+
Info Prefab-Modal
|
|
39
|
+
</button>
|
|
40
|
+
<button onClick={() => showPrefabModal("error", "Something is not right", "Maybe stop doing that")}>
|
|
41
|
+
Error Prefab-Modal
|
|
42
|
+
</button>
|
|
43
|
+
<button onClick={() => showPrefabModal("success", "You are a success", "Keep succeeding!")}>
|
|
44
|
+
Success Prefab-Modal
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -59,19 +59,18 @@ export const PanelContents = () => {
|
|
|
59
59
|
|
|
60
60
|
// #Example: Show Panel Buttons
|
|
61
61
|
export const TestShowPanelButtons = () => (
|
|
62
|
-
|
|
62
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
|
|
63
63
|
<div>
|
|
64
64
|
<OpenPanelButton buttonText={"Panel name 1"} component={() => <ShowPanel data={1} />} />{" "}
|
|
65
65
|
<OpenPanelButton buttonText={"Panel name 2"} component={() => <ShowPanel data={2} />} />
|
|
66
66
|
</div>
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
<ButtonIconHorizontalGroup>
|
|
69
69
|
<OpenPanelIcon iconTitle={"Marks"} icon={"ic_marks"} component={() => <ShowPanel data={1} />} />
|
|
70
70
|
<ButtonIconSeparator />
|
|
71
71
|
<OpenPanelIcon iconTitle={"Vectors"} icon={"ic_line_irregular"} component={() => <ShowPanel data={2} />} />
|
|
72
72
|
</ButtonIconHorizontalGroup>
|
|
73
|
-
|
|
74
|
-
<br />
|
|
73
|
+
|
|
75
74
|
<ButtonIconVerticalGroup>
|
|
76
75
|
<OpenPanelIcon iconTitle={"Marks"} icon={"ic_marks"} component={() => <ShowPanel data={1} />} />
|
|
77
76
|
<ButtonIconSeparator />
|
|
@@ -82,5 +81,5 @@ export const TestShowPanelButtons = () => (
|
|
|
82
81
|
component={() => <ShowPanel data={3} />}
|
|
83
82
|
/>
|
|
84
83
|
</ButtonIconVerticalGroup>
|
|
85
|
-
|
|
84
|
+
</div>
|
|
86
85
|
);
|
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
};
|