import _ from 'lodash';
import React, { useState } from 'react';
import createClass from 'create-react-class';
import { Meta, Story } from '@storybook/react';
import { Dialog, IDialogProps } from './Dialog';
import Button from '../Button/Button';
import SearchableMultiSelect from '../SearchableMultiSelect/SearchableMultiSelect';
import SingleSelect from '../SingleSelect/SingleSelect';
import CheckboxLabeled from '../CheckboxLabeled/CheckboxLabeled';
import SearchField from '../SearchField/SearchField';
export default {
title: 'Layout/Dialog',
component: Dialog,
parameters: {
docs: {
description: {
component: Dialog.peek.description,
},
},
layout: 'centered',
},
args: Dialog.defaultProps,
decorators: [
(Story) => (
),
],
} as Meta;
export const Basic: Story = (args) => {
const [isShown, setIsShown] = useState(false);
const handleShow = (isShown: boolean) => {
setIsShown(isShown);
};
return (
);
};
Basic.decorators = [(Story) => {Story()}
];
export const Small = () => {
const Component = createClass({
getInitialState() {
return {
isShown: false,
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
render() {
return (
);
},
});
return ;
};
/* Medium */
export const Medium = () => {
const Component = createClass({
getInitialState() {
return {
isShown: false,
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
render() {
return (
);
},
});
return ;
};
/* Large With Rich Header */
export const LargeWithRichHeader = () => {
const Component = createClass({
getInitialState() {
return {
isShown: false,
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
render() {
return (
);
},
});
return ;
};
/* Complex */
export const Complex = () => {
const style = {
marginBottom: '3px',
};
const { Option } = SearchableMultiSelect;
const { Placeholder, Option: SingleOption } = SingleSelect;
const Component = createClass({
getInitialState() {
return {
isShown: false,
flavors: ['chocolate'],
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
handleSelectedChocolate(isSelected: any) {
this.setState({
flavors: isSelected
? _.concat(this.state.flavors, 'chocolate')
: _.without(this.state.flavors, 'chocolate'),
});
},
handleSelectedStrawberry(isSelected: any) {
this.setState({
flavors: isSelected
? _.concat(this.state.flavors, 'strawberry')
: _.without(this.state.flavors, 'strawberry'),
});
},
render() {
return (
);
},
});
return ;
};
/* No Modal */
export const NoModal = () => {
const Component = createClass({
getInitialState() {
return {
isShown: false,
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
render() {
return (
);
},
});
return ;
};
/* No Footer */
export const NoFooter = () => {
const Component = createClass({
getInitialState() {
return {
isShown: false,
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
render() {
return (
);
},
});
return ;
};
/* No Gutters */
export const NoGutters = () => {
const Component = createClass({
getInitialState() {
return {
isShown: false,
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
render() {
return (
);
},
});
return ;
};
/* No Close Button */
export const NoCloseButton = () => {
const Component = createClass({
getInitialState() {
return {
isShown: false,
};
},
handleShow(isShown: any) {
this.setState({ isShown });
},
render() {
return (
);
},
});
return ;
};