From e9c66dd358c2d4e75a38855945b91a74b0b0dced Mon Sep 17 00:00:00 2001 From: Pavel Klibani Date: Fri, 15 Sep 2023 16:00:40 +0200 Subject: [PATCH] Docs(web-react): Add Modal demo #DS-902 Modal demo in web-react is now same as in web and web-twig --- .../src/components/Modal/demo/Modal.tsx | 49 ------ .../components/Modal/demo/ModalDefault.tsx | 151 ++++++++++++++++++ .../Modal/demo/ModalScrollingLongContent.tsx | 138 ++++++++++++++++ .../components/Modal/demo/ModalStacking.tsx | 67 ++++++++ .../src/components/Modal/demo/index.tsx | 40 ++--- 5 files changed, 376 insertions(+), 69 deletions(-) delete mode 100644 packages/web-react/src/components/Modal/demo/Modal.tsx create mode 100644 packages/web-react/src/components/Modal/demo/ModalDefault.tsx create mode 100644 packages/web-react/src/components/Modal/demo/ModalScrollingLongContent.tsx create mode 100644 packages/web-react/src/components/Modal/demo/ModalStacking.tsx diff --git a/packages/web-react/src/components/Modal/demo/Modal.tsx b/packages/web-react/src/components/Modal/demo/Modal.tsx deleted file mode 100644 index 40b81f0a25..0000000000 --- a/packages/web-react/src/components/Modal/demo/Modal.tsx +++ /dev/null @@ -1,49 +0,0 @@ -// Because there is no `dist` directory during the CI run -/* eslint-disable import/no-extraneous-dependencies, import/extensions, import/no-unresolved */ -import React, { useState } from 'react'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore: No declaration file -import icons from '@lmc-eu/spirit-icons/dist/icons'; -import { IconsProvider } from '../../../context'; -import Modal from '../Modal'; -import ModalDialog from '../ModalDialog'; -import ModalBody from '../ModalBody'; -import ModalHeader from '../ModalHeader'; -import ModalFooter from '../ModalFooter'; -import { Button } from '../../Button'; - -const Story = () => { - const [isOpen, setOpen] = useState(false); - - const toggleModal = () => setOpen(!isOpen); - - const handleClose = () => { - setOpen(false); - }; - - return ( - -
- -
- - - Modal title - Body - - - - - - -
- ); -}; - -export default Story; diff --git a/packages/web-react/src/components/Modal/demo/ModalDefault.tsx b/packages/web-react/src/components/Modal/demo/ModalDefault.tsx new file mode 100644 index 0000000000..77c9a12a54 --- /dev/null +++ b/packages/web-react/src/components/Modal/demo/ModalDefault.tsx @@ -0,0 +1,151 @@ +import React, { ChangeEvent, useState } from 'react'; +import { AlignmentXDictionaryType } from '../../..'; +import { Button, Checkbox, Modal, ModalBody, ModalDialog, ModalFooter, ModalHeader, Radio, TextField } from '../..'; + +const ModalDefault = () => { + const [isFirstOpen, setFirstOpen] = useState(false); + const [isSecondOpen, setSecondOpen] = useState(false); + const [isThirdOpen, setThirdOpen] = useState(false); + const [footerAlign, setFooterAlign] = useState('right'); + const [isExpanded, setIsExpanded] = useState(false); + + const toggleFirstModal = () => setFirstOpen(!isFirstOpen); + const toggleSecondModal = () => setSecondOpen(!isSecondOpen); + const toggleThirdModal = () => setThirdOpen(!isSecondOpen); + const toggleIsExpanded = () => setIsExpanded(!isExpanded); + + const handleFirstClose = () => setFirstOpen(false); + const handleSecondClose = () => setSecondOpen(false); + const handleThirdClose = () => setThirdOpen(false); + const handleFooterAlignChange = (e: ChangeEvent) => { + setFooterAlign(e.target.value as AlignmentXDictionaryType); + }; + + return ( + <> + + + + + Modal Title + +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+
+
Footer alignment (from tablet up):
+ + + + +
+ + +
+ + + + +
+
+ + + + + + Modal with a Form + + +

+ The primary action is a button with type="submit" and closes the dialog on + submission. +

+
+ + + + +
+
+ + + + + + Modal with Custom Height + +

+ This modal has a custom height of 400px. +
+
+ The max height cannot be customized on mobile though. +

+

+ This modal has a custom height of 500px. +
+
+ The max height of this modal is 700px. +

+
+ + + + +
+
+ + ); +}; + +export default ModalDefault; diff --git a/packages/web-react/src/components/Modal/demo/ModalScrollingLongContent.tsx b/packages/web-react/src/components/Modal/demo/ModalScrollingLongContent.tsx new file mode 100644 index 0000000000..7e8a95a966 --- /dev/null +++ b/packages/web-react/src/components/Modal/demo/ModalScrollingLongContent.tsx @@ -0,0 +1,138 @@ +import React, { useState } from 'react'; +import { Button, Modal, ModalBody, ModalDialog, ModalFooter, ModalHeader, ScrollView } from '../..'; + +const ModalScrollingLongContent = () => { + const [isFirstOpen, setFirstOpen] = useState(false); + const [isSecondOpen, setSecondOpen] = useState(false); + + const toggleFirstModal = () => setFirstOpen(!isFirstOpen); + const toggleSecondModal = () => setSecondOpen(!isSecondOpen); + + const handleFirstClose = () => setFirstOpen(false); + const handleSecondClose = () => setSecondOpen(false); + + return ( + <> + + + + + + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta + + +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+
+ + + + +
+
+ + + + + + Modal with ScrollView + + +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam + mollitia perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus + perferendis provident unde. Eveniet, iste, molestiae? +

+
+
+ + + + +
+
+ + ); +}; + +export default ModalScrollingLongContent; diff --git a/packages/web-react/src/components/Modal/demo/ModalStacking.tsx b/packages/web-react/src/components/Modal/demo/ModalStacking.tsx new file mode 100644 index 0000000000..6b6ba0fae7 --- /dev/null +++ b/packages/web-react/src/components/Modal/demo/ModalStacking.tsx @@ -0,0 +1,67 @@ +import React, { useState } from 'react'; +import { Button, Modal, ModalBody, ModalDialog, ModalFooter, ModalHeader } from '../..'; + +const ModalStacking = () => { + const [isFirstOpen, setFirstOpen] = useState(false); + const [isSecondOpen, setSecondOpen] = useState(false); + + const toggleFirstModal = () => setFirstOpen(!isFirstOpen); + const toggleSecondModal = () => setSecondOpen(!isSecondOpen); + + const handleFirstClose = () => setFirstOpen(false); + const handleSecondClose = () => setSecondOpen(false); + + return ( + <> + + + + + Modal Title + +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+
+ + + +
+
+ + + + Stacked Modal Title + +

+ Dolor quis metus a lorem, et elit pulvinar ligula condimentum non congue rhoncus molestie, at sem viverra + maximus nunc. Posuere pretium accumsan, pharetra vel integer sit amet volutpat neque fringilla, non mauris + erat id augue libero. Porta non congue, et iaculis et vehicula convallis non purus placerat cursus, + rhoncus laoreet nec et elit. Proin luctus, bibendum adipiscing ut ollicitudin vehicula nisi nunc et, + sollicitudin eget tristique nec commodo. Porttitor ligula, tellus vehicula arcu vestibulum sed rutrum + placerat, dui quis facilisis eget. Suscipit molestie, nibh maximus enim vestibulum aenean ut libero sed + imperdiet, curabitur et elit venenatis posuere. +
+ Sapien vitae, dui sollicitudin nullam dolor quis nec nulla sapien, diam a ollicitudin non nulla nisl. Quis + orci porta, ac nec sapien ornare imperdiet a vel convallis, adipiscing ullamcorper lectus quis pharetra. + At nullam rutrum, nisl eget sit amet pulvinar ultricies nec porta, diam a sem odio a mauris eu. Suscipit + sodales, fusce ante cursus convallis dui vel dolor potenti nulla fusce gravida. +

+
+ + + + +
+
+ + ); +}; + +export default ModalStacking; diff --git a/packages/web-react/src/components/Modal/demo/index.tsx b/packages/web-react/src/components/Modal/demo/index.tsx index 55bc13d58b..b8ee02eb55 100644 --- a/packages/web-react/src/components/Modal/demo/index.tsx +++ b/packages/web-react/src/components/Modal/demo/index.tsx @@ -1,28 +1,28 @@ +// Because there is no `dist` directory during the CI run +/* eslint-disable import/no-extraneous-dependencies, import/extensions, import/no-unresolved */ import React from 'react'; import ReactDOM from 'react-dom/client'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: No declaration file +import icons from '@lmc-eu/spirit-icons/dist/icons'; import DocsSection from '../../../../docs/DocsSections'; -import Modal from './Modal'; -import ModalWithCustomHeight from './ModalWithCustomHeight'; -import ModalWithLongText from './ModalWithLongText'; -import ModalWithCheckbox from './ModalWithCheckbox'; -import ModalStacked from './ModalStacked'; +import { IconsProvider } from '../../../context'; +import ModalDefault from './ModalDefault'; +import ModalScrollingLongContent from './ModalScrollingLongContent'; +import ModalStacking from './ModalStacking'; ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - - - - - - - - - - - - - - - + + + + + + + + + + + , );