DocSpace-buildtools/packages/components/modal-dialog/modal-dialog.stories.js

82 lines
2.0 KiB
JavaScript
Raw Normal View History

import React, { useState } from "react";
import ModalDialog from "./index.js";
import Button from "../button";
2022-04-08 23:41:44 +00:00
import PropTypes from "prop-types";
2019-06-27 12:47:32 +00:00
export default {
title: "Components/ModalDialog",
component: ModalDialog,
parameters: {
docs: {
description: {
component: "ModalDialog is used for displaying modal dialogs",
},
},
},
argTypes: {
2022-04-08 22:42:38 +00:00
onOk: { action: "onOk" },
},
};
2022-04-08 22:42:38 +00:00
const Template = ({ onOk, ...args }) => {
2022-03-16 14:41:25 +00:00
const [isVisible, setIsVisible] = useState(false);
2022-04-08 22:42:38 +00:00
const openModal = () => setIsVisible(true);
const closeModal = () => setIsVisible(false);
return (
2022-03-16 14:41:25 +00:00
<>
2022-04-08 22:42:38 +00:00
<Button label="Show" primary={true} size="medium" onClick={openModal} />
<ModalDialog {...args} visible={isVisible} onClose={closeModal}>
2022-04-08 23:41:44 +00:00
<ModalDialog.Header>Change password</ModalDialog.Header>
<ModalDialog.Body>
<span>
Send the password change instruction to the{" "}
<a href="mailto:asc@story.book">asc@story.book</a> email address
</span>
</ModalDialog.Body>
<ModalDialog.Footer>
<Button
key="SendBtn"
label="Send"
primary={true}
scale
2022-04-18 13:41:17 +00:00
size="normal"
2022-04-08 22:42:38 +00:00
onClick={() => {
onOk();
closeModal();
}}
/>
<Button
2022-03-15 15:08:32 +00:00
key="CloseBtn"
label="Cancel"
scale
2022-04-18 13:41:17 +00:00
size="normal"
2022-04-08 22:42:38 +00:00
onClick={closeModal}
/>
</ModalDialog.Footer>
<ModalDialog.Container>
<div style={{ width: "100%", height: "100%", background: "red" }}>
123
</div>
</ModalDialog.Container>
</ModalDialog>
2022-03-16 14:41:25 +00:00
</>
);
};
2022-04-08 23:41:44 +00:00
Template.propTypes = {
onOk: PropTypes.func,
};
export const Default = Template.bind({});
Default.args = {
displayType: "aside",
2022-07-04 09:12:02 +00:00
displayTypeDetailed: {
desktop: "aside",
2022-07-04 09:12:02 +00:00
tablet: "aside",
smallTablet: "modal",
mobile: "aside",
2022-07-04 09:12:02 +00:00
},
};