diff --git a/lib/components/Modal/Modal.stories.js b/lib/components/Modal/Modal.stories.js index cbd8bfba..e3dab017 100644 --- a/lib/components/Modal/Modal.stories.js +++ b/lib/components/Modal/Modal.stories.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useRef, useState } from "react"; import Button from "../Button"; import Modal from "."; import { H3, P } from "../Typography"; @@ -15,23 +15,31 @@ export default { const Basic = () => { const [visible, setVisible] = useState(false); + const button = useRef(); + const handleOnButtonClick = () => { setVisible(true); }; + const handleOnConfirm = () => { setVisible(false); }; + const onToggleModal = (visible) => () => { setVisible(visible); }; return ( <> - +

Modal Title

@@ -44,25 +52,79 @@ const Basic = () => { ); }; export const basicModal = () => ; +basicModal.parameters = { + docs: { + source: { + code: ` +const Basic = () => { + const [visible, setVisible] = useState(false); + const button = useRef(); + + const handleOnButtonClick = () => { + setVisible(true); + }; + + const handleOnConfirm = () => { + setVisible(false); + }; + + const onToggleModal = (visible) => () => { + setVisible(visible); + }; + + return ( + <> + + + +

Modal Title

+

+ Content of the modal. Modal accepts any child components or content. +

+
+
+ + ); +};` + } + } +}; const Advanced = () => { const [visible, setVisible] = useState(false); + const button = useRef(); + const handleOnButtonClick = () => { setVisible(true); }; + const handleOnConfirm = () => { setVisible(false); }; + const onToggleModal = (visible) => () => { setVisible(visible); }; + const modalHeader =

Modal Title

; + const modalFooter = ( ); + return ( <> - + { onClose={onToggleModal(false)} headerContent={modalHeader} footerContent={modalFooter} + triggerRef={button} >

@@ -111,18 +174,105 @@ const Advanced = () => { ); }; export const advancedModal = () => ; +advancedModal.parameters = { + docs: { + source: { + code: ` +const Advanced = () => { + const [visible, setVisible] = useState(false); + const button = useRef(); + + const handleOnButtonClick = () => { + setVisible(true); + }; + + const handleOnConfirm = () => { + setVisible(false); + }; + + const onToggleModal = (visible) => () => { + setVisible(visible); + }; + + const modalHeader =

Modal Title

; + + const modalFooter = ( + + ); + + return ( + <> + + + +

+ Content of the modal. Modal accepts any child components or content. + This content will be scrollable if it exeeds the height of the + modal. +

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim + ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut + aliquip ex ea commodo consequat. Duis aute irure dolor in + reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla + pariatur. Excepteur sint occaecat cupidatat non proident, sunt in + culpa qui officia deserunt mollit anim id est laborum. +

+

+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem + accusantium doloremque laudantium, totam rem aperiam, eaque ipsa + quae ab illo inventore veritatis et quasi architecto beatae vitae + dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit + aspernatur aut odit aut fugit, sed quia consequuntur magni dolores + eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, + qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, + sed quia non numquam eius modi tempora incidunt ut labore et dolore + magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis + nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut + aliquid ex ea commodi consequatur? Quis autem vel eum iure + reprehenderit qui in ea voluptate velit esse quam nihil molestiae + consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla + pariatur? +

+
+
+ + ); +};` + } + } +}; const BasicDialogue = () => { const [visible, setVisible] = useState(false); + const button = useRef(); + const handleOnButtonClick = () => { setVisible(true); }; + const handleOnConfirm = () => { setVisible(false); }; + const onToggleModal = (visible) => () => { setVisible(visible); }; + const modalFooter = ( @@ -135,9 +285,15 @@ const BasicDialogue = () => { ); + return ( <> - @@ -146,6 +302,7 @@ const BasicDialogue = () => { handleOnConfirm={handleOnConfirm} onClose={onToggleModal(false)} footerContent={modalFooter} + triggerRef={button} >

@@ -158,19 +315,89 @@ const BasicDialogue = () => { ); }; export const basicDialogueModal = () => ; +basicDialogueModal.parameters = { + docs: { + source: { + code: ` +const BasicDialogue = () => { + const [visible, setVisible] = useState(false); + const button = useRef(); + + const handleOnButtonClick = () => { + setVisible(true); + }; + + const handleOnConfirm = () => { + setVisible(false); + }; + + const onToggleModal = (visible) => () => { + setVisible(visible); + }; + + const modalFooter = ( + + + + + + + ); + + return ( + <> + + + +

+ This will remove all data from the application. +

+

Do you wish to continue?

+
+
+ + ); +};` + } + } +}; const EditDialogue = () => { const [visible, setVisible] = useState(false); + const button = useRef(); + const handleOnButtonClick = () => { setVisible(true); }; + const handleOnConfirm = () => { setVisible(false); }; + const onToggleModal = (visible) => () => { setVisible(visible); }; + const modalHeader =

Modify Details

; + const modalFooter = ( @@ -187,7 +414,7 @@ const EditDialogue = () => { ); return ( <> - @@ -197,6 +424,7 @@ const EditDialogue = () => { onClose={onToggleModal(false)} headerContent={modalHeader} footerContent={modalFooter} + triggerRef={button} > { ); }; export const editDialogueModal = () => ; +editDialogueModal.parameters = { + docs: { + source: { + code: ` +const EditDialogue = () => { + const [visible, setVisible] = useState(false); + const button = useRef(); + + const handleOnButtonClick = () => { + setVisible(true); + }; + + const handleOnConfirm = () => { + setVisible(false); + }; + + const onToggleModal = (visible) => () => { + setVisible(visible); + }; + + const modalHeader =

Modify Details

; + + const modalFooter = ( + + + + + + + ); + return ( + <> + + + + +