refactor modal and confirm alert

This commit is contained in:
Konstantin Schaper
2020-09-23 14:34:21 +02:00
parent fc534605f0
commit 3e5349d5d1
3 changed files with 93 additions and 67 deletions

View File

@@ -25,7 +25,7 @@
import { storiesOf } from "@storybook/react";
import { MemoryRouter } from "react-router-dom";
import * as React from "react";
import ConfirmAlert from "./ConfirmAlert";
import ConfirmAlert, { confirmAlert } from "./ConfirmAlert";
const body =
"Mind-paralyzing change needed improbability vortex machine sorts sought same theory upending job just allows\n " +
@@ -40,11 +40,21 @@ const buttons = [
onClick: () => null
},
{
label: "Submit",
onClick: () => {}
label: "Submit"
}
];
storiesOf("Modal|ConfirmAlert", module)
.addDecorator(story => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>)
.add("Default", () => <ConfirmAlert message={body} title={"Are you sure about that?"} buttons={buttons} />);
.add("Default", () => <ConfirmAlert message={body} title={"Are you sure about that?"} buttons={buttons} />)
.add("WithButton", () => {
const buttonClick = () => {
confirmAlert({ message: body, title: "Are you sure about that?", buttons });
};
return (
<>
<button onClick={buttonClick}>Open ConfirmAlert</button>
<div id="modalRoot" />
</>
);
});