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 (
For better UX, we recommend NOT handling onEscape and onBackgroundClick when isModal is true. The term "modal" implies that the user needs to interact with one of the buttons in the footer to exit the dialog.
{_.times(10).map((i) => { return
Body
; })}
); }; Basic.decorators = [(Story) =>
{Story()}
]; export const Small = () => { const Component = createClass({ getInitialState() { return { isShown: false, }; }, handleShow(isShown: any) { this.setState({ isShown }); }, render() { return (
For better UX, we recommend NOT handling onEscape and onBackgroundClick when isModal is true. The term "modal" implies that the user needs to interact with one of the buttons in the footer to exit the dialog.
{_.times(10).map((i) => { return
Body
; })}
); }, }); return ; }; /* Medium */ export const Medium = () => { const Component = createClass({ getInitialState() { return { isShown: false, }; }, handleShow(isShown: any) { this.setState({ isShown }); }, render() { return (
For better UX, we recommend NOT handling onEscape and onBackgroundClick when isModal is true. The term "modal" implies that the user needs to interact with one of the buttons in the footer to exit the dialog.
{_.times(50).map((i) => { return
Body
; })}
); }, }); return ; }; /* Large With Rich Header */ export const LargeWithRichHeader = () => { const Component = createClass({ getInitialState() { return { isShown: false, }; }, handleShow(isShown: any) { this.setState({ isShown }); }, render() { return (
Rich Header
For better UX, we recommend NOT handling onEscape and onBackgroundClick when isModal is true. The term "modal" implies that the user needs to interact with one of the buttons in the footer to exit the dialog.
{_.times(50).map((i) => { return
Body
; })}
); }, }); 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 (

Flavor

Chocolate Strawberry

Flavor Combination Research

Toppings

Ice Cream Breaks

You must select a break... 10am 11am 1pm 2pm
); }, }); return ; }; /* No Modal */ export const NoModal = () => { const Component = createClass({ getInitialState() { return { isShown: false, }; }, handleShow(isShown: any) { this.setState({ isShown }); }, render() { return (
In most cases, you'll probably just use an isModal Dialog, but this example shows that the Dialog doesn't have to be a modal. Try pressing "escape" to close this Dialog.
); }, }); return ; }; /* No Footer */ export const NoFooter = () => { const Component = createClass({ getInitialState() { return { isShown: false, }; }, handleShow(isShown: any) { this.setState({ isShown }); }, render() { return (
This `Dialog` has no footer!
); }, }); return ; }; /* No Gutters */ export const NoGutters = () => { const Component = createClass({ getInitialState() { return { isShown: false, }; }, handleShow(isShown: any) { this.setState({ isShown }); }, render() { return (
This `Dialog` has no gutters!
); }, }); return ; }; /* No Close Button */ export const NoCloseButton = () => { const Component = createClass({ getInitialState() { return { isShown: false, }; }, handleShow(isShown: any) { this.setState({ isShown }); }, render() { return (
For better UX, we recommend NOT handling onEscape and onBackgroundClick when isModal is true. The term "modal" implies that the user needs to interact with one of the buttons in the footer to exit the dialog.
{_.times(50).map((i) => { return
Body
; })}
); }, }); return ; };