From 436801b0dc220b196224f5af4bef649fd74d112c Mon Sep 17 00:00:00 2001 From: Marija Najdova Date: Mon, 18 Sep 2023 08:44:20 +0200 Subject: [PATCH] [docs][Dialog] Add non-modal dialog docs & demo (#38684) --- .../components/dialogs/CookiesBanner.js | 108 ++++++++++++++++++ .../components/dialogs/CookiesBanner.tsx | 108 ++++++++++++++++++ .../material/components/dialogs/dialogs.md | 9 ++ 3 files changed, 225 insertions(+) create mode 100644 docs/data/material/components/dialogs/CookiesBanner.js create mode 100644 docs/data/material/components/dialogs/CookiesBanner.tsx diff --git a/docs/data/material/components/dialogs/CookiesBanner.js b/docs/data/material/components/dialogs/CookiesBanner.js new file mode 100644 index 00000000000000..93b32a2e461b05 --- /dev/null +++ b/docs/data/material/components/dialogs/CookiesBanner.js @@ -0,0 +1,108 @@ +import * as React from 'react'; +import Stack from '@mui/material/Stack'; +import TrapFocus from '@mui/material/Unstable_TrapFocus'; +import CssBaseline from '@mui/material/CssBaseline'; +import AppBar from '@mui/material/AppBar'; +import Toolbar from '@mui/material/Toolbar'; +import Container from '@mui/material/Container'; +import IconButton from '@mui/material/IconButton'; +import MenuIcon from '@mui/icons-material/Menu'; +import Paper from '@mui/material/Paper'; +import Fade from '@mui/material/Fade'; +import Button from '@mui/material/Button'; +import Box from '@mui/material/Box'; +import Typography from '@mui/material/Typography'; + +export default function CookiesBanner() { + const [bannerOpen, setBannerOpen] = React.useState(true); + + const closeBanner = () => { + setBannerOpen(false); + }; + + return ( + + + + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Rhoncus dolor purus non + enim praesent elementum facilisis leo vel. Risus at ultrices mi tempus + imperdiet. + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Rhoncus dolor purus non + enim praesent elementum facilisis leo vel. Risus at ultrices mi tempus + imperdiet. + + + + + + + + This website uses cookies + + example.com relies on cookies to improve your experience. + + + + + + + + + + + + ); +} diff --git a/docs/data/material/components/dialogs/CookiesBanner.tsx b/docs/data/material/components/dialogs/CookiesBanner.tsx new file mode 100644 index 00000000000000..93b32a2e461b05 --- /dev/null +++ b/docs/data/material/components/dialogs/CookiesBanner.tsx @@ -0,0 +1,108 @@ +import * as React from 'react'; +import Stack from '@mui/material/Stack'; +import TrapFocus from '@mui/material/Unstable_TrapFocus'; +import CssBaseline from '@mui/material/CssBaseline'; +import AppBar from '@mui/material/AppBar'; +import Toolbar from '@mui/material/Toolbar'; +import Container from '@mui/material/Container'; +import IconButton from '@mui/material/IconButton'; +import MenuIcon from '@mui/icons-material/Menu'; +import Paper from '@mui/material/Paper'; +import Fade from '@mui/material/Fade'; +import Button from '@mui/material/Button'; +import Box from '@mui/material/Box'; +import Typography from '@mui/material/Typography'; + +export default function CookiesBanner() { + const [bannerOpen, setBannerOpen] = React.useState(true); + + const closeBanner = () => { + setBannerOpen(false); + }; + + return ( + + + + + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Rhoncus dolor purus non + enim praesent elementum facilisis leo vel. Risus at ultrices mi tempus + imperdiet. + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Rhoncus dolor purus non + enim praesent elementum facilisis leo vel. Risus at ultrices mi tempus + imperdiet. + + + + + + + + This website uses cookies + + example.com relies on cookies to improve your experience. + + + + + + + + + + + + ); +} diff --git a/docs/data/material/components/dialogs/dialogs.md b/docs/data/material/components/dialogs/dialogs.md index 914cfeb72f5f42..cbf62b794778ed 100644 --- a/docs/data/material/components/dialogs/dialogs.md +++ b/docs/data/material/components/dialogs/dialogs.md @@ -108,6 +108,15 @@ Touching "Cancel" in a confirmation dialog, or pressing Back, cancels the action {{"demo": "ConfirmationDialog.js"}} +## Non-modal dialog + +Dialogs can also be non-modal, meaning they don't interrupt user interaction behind it. +Visit [the Nielsen Norman Group article](https://www.nngroup.com/articles/modal-nonmodal-dialog/) for more in-depth guidance about modal vs. non-modal dialog usage. + +The demo below shows a persistent cookie banner, a common non-modal dialog use case. + +{{"demo": "CookiesBanner.js", "iframe": true}} + ## Draggable dialog You can create a draggable dialog by using [react-draggable](https://github.com/react-grid-layout/react-draggable).