diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerCustomSize.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerCustomSize.stories.tsx index 768179d12a3994..89bf8ad7e63181 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerCustomSize.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerCustomSize.stories.tsx @@ -54,7 +54,7 @@ export const CustomSize = () => {
diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerInline.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerInline.stories.tsx index d373f672abd20e..5670a0054b041e 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerInline.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerInline.stories.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { DrawerBody, DrawerHeader, DrawerHeaderTitle, DrawerInline } from '@fluentui/react-drawer'; -import { Button, makeStyles, shorthands } from '@fluentui/react-components'; +import { Button, makeStyles, shorthands, tokens } from '@fluentui/react-components'; import { Dismiss24Regular } from '@fluentui/react-icons'; const useStyles = makeStyles({ @@ -18,6 +18,7 @@ const useStyles = makeStyles({ display: 'flex', justifyContent: 'center', alignItems: 'flex-start', + columnGap: tokens.spacingHorizontalXS, }, }); diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerOverlay.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerOverlay.stories.tsx index 378561c7e844ad..19d7a0ff809780 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerOverlay.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerOverlay.stories.tsx @@ -30,7 +30,7 @@ export const Overlay = () => {
); diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerOverlayNoModal.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerOverlayNoModal.stories.tsx new file mode 100644 index 00000000000000..837da6e6ada887 --- /dev/null +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerOverlayNoModal.stories.tsx @@ -0,0 +1,37 @@ +import * as React from 'react'; +import { DrawerBody, DrawerHeader, DrawerHeaderTitle, DrawerOverlay } from '@fluentui/react-drawer'; +import { Button } from '@fluentui/react-components'; +import { Dismiss24Regular } from '@fluentui/react-icons'; + +export const OverlayNoModal = () => { + const [isOpen, setIsOpen] = React.useState(false); + + return ( +
+ setIsOpen(open)}> + + } + onClick={() => setIsOpen(false)} + /> + } + > + Overlay Drawer + + + + +

Drawer content

+
+
+ + +
+ ); +}; diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerPosition.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerPosition.stories.tsx index f03b9ab987e04a..2b05d2b2f00825 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerPosition.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerPosition.stories.tsx @@ -1,15 +1,36 @@ import * as React from 'react'; -import { DrawerBody, DrawerHeader, DrawerHeaderTitle, DrawerOverlay } from '@fluentui/react-drawer'; -import { Button } from '@fluentui/react-components'; +import { DrawerBody, DrawerHeader, DrawerHeaderTitle, DrawerOverlay, DrawerProps } from '@fluentui/react-drawer'; +import { Button, makeStyles, tokens } from '@fluentui/react-components'; import { Dismiss24Regular } from '@fluentui/react-icons'; +const useStyles = makeStyles({ + content: { + display: 'flex', + justifyContent: 'center', + alignItems: 'flex-start', + columnGap: tokens.spacingHorizontalXS, + }, +}); + export const Position = () => { - const [leftOpen, setLeftOpen] = React.useState(false); - const [rightOpen, setRightOpen] = React.useState(false); + const styles = useStyles(); + + const [isOpen, setIsOpen] = React.useState(false); + const [position, setPosition] = React.useState('left'); + + const onClickLeftButton = React.useCallback(() => { + setPosition('left'); + setIsOpen(true); + }, []); + + const onClickRightButton = React.useCallback(() => { + setPosition('right'); + setIsOpen(true); + }, []); return (
- setLeftOpen(open)}> + setIsOpen(open)}> { appearance="subtle" aria-label="Close" icon={} - onClick={() => setLeftOpen(false)} + onClick={() => setIsOpen(false)} /> } > - Left Drawer + {position === 'left' ? 'Left' : 'Right'} Drawer @@ -30,34 +51,15 @@ export const Position = () => { - - - - - setRightOpen(open)}> - - } - onClick={() => setRightOpen(false)} - /> - } - > - Right Drawer - - +
+ - -

Drawer content

-
- + +
); }; diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerPreventClose.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerPreventClose.stories.tsx index 58a476fe141f79..d573b7be507c8a 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerPreventClose.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerPreventClose.stories.tsx @@ -30,7 +30,7 @@ export const PreventClose = () => {
); diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerResizable.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerResizable.stories.tsx index 9b7dc34768369e..a6a6fe9aa67b96 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerResizable.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerResizable.stories.tsx @@ -63,6 +63,7 @@ export const Resizable = () => { React.useEffect(() => { window.addEventListener('mousemove', resize); window.addEventListener('mouseup', stopResizing); + return () => { window.removeEventListener('mousemove', resize); window.removeEventListener('mouseup', stopResizing); diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerResponsive.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerResponsive.stories.tsx index 505d012042fcbf..56aac7be93c221 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerResponsive.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerResponsive.stories.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { DrawerBody, DrawerHeader, DrawerHeaderTitle, Drawer, DrawerProps } from '@fluentui/react-drawer'; -import { makeStyles, shorthands, tokens } from '@fluentui/react-components'; +import { Button, makeStyles, shorthands, tokens } from '@fluentui/react-components'; +import { Dismiss24Regular } from '@fluentui/react-icons'; const useStyles = makeStyles({ root: { @@ -15,6 +16,8 @@ const useStyles = makeStyles({ content: { ...shorthands.margin(tokens.spacingVerticalXL, tokens.spacingHorizontalXL), ...shorthands.flex(1), + + gridRowGap: tokens.spacingVerticalXXL, }, }); @@ -26,6 +29,8 @@ export const Responsive = () => { const [isOpen, setIsOpen] = React.useState(true); const [type, setType] = React.useState('inline'); + const onMediaQueryChange = React.useCallback(({ matches }) => setType(matches ? 'overlay' : 'inline'), [setType]); + React.useEffect(() => { const match = window.matchMedia('(max-width: 720px)'); @@ -33,22 +38,41 @@ export const Responsive = () => { setType('overlay'); } - match.addEventListener('change', ({ matches }) => setType(matches ? 'overlay' : 'inline')); - }, []); + match.addEventListener('change', onMediaQueryChange); + + return () => match.removeEventListener('change', onMediaQueryChange); + }, [onMediaQueryChange]); return (
-

Resize the window to see the change

- - setIsOpen(open)}> + setIsOpen(open)}> - Responsive Drawer + } + onClick={() => setIsOpen(false)} + /> + } + > + Responsive Drawer +

Drawer content

+ +
+ + +

Resize the window to see the change

+
); }; diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerSeparator.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerSeparator.stories.tsx index 76a1fa294bdef8..85f5974e61eecd 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerSeparator.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerSeparator.stories.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { DrawerBody, DrawerHeader, DrawerHeaderTitle, DrawerInline } from '@fluentui/react-drawer'; -import { Button, makeStyles, shorthands } from '@fluentui/react-components'; +import { Button, makeStyles, shorthands, tokens } from '@fluentui/react-components'; import { Dismiss24Regular } from '@fluentui/react-icons'; const useStyles = makeStyles({ @@ -18,6 +18,7 @@ const useStyles = makeStyles({ display: 'flex', justifyContent: 'center', alignItems: 'flex-start', + columnGap: tokens.spacingHorizontalXS, }, }); @@ -29,7 +30,7 @@ export const Separator = () => { return (
- + {
diff --git a/packages/react-components/react-drawer/stories/Drawer/DrawerWithNavigation.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/DrawerWithNavigation.stories.tsx index 1c65e72df0d652..b9d81917ba8d72 100644 --- a/packages/react-components/react-drawer/stories/Drawer/DrawerWithNavigation.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/DrawerWithNavigation.stories.tsx @@ -53,7 +53,7 @@ export const WithNavigation = () => {
); diff --git a/packages/react-components/react-drawer/stories/Drawer/index.stories.tsx b/packages/react-components/react-drawer/stories/Drawer/index.stories.tsx index af8ffa40657142..f9be43e8eb0bf5 100644 --- a/packages/react-components/react-drawer/stories/Drawer/index.stories.tsx +++ b/packages/react-components/react-drawer/stories/Drawer/index.stories.tsx @@ -13,15 +13,16 @@ import previewMd from './DrawerPreview.md'; export { Default } from './DrawerDefault.stories'; export { Overlay } from './DrawerOverlay.stories'; +export { OverlayNoModal } from './DrawerOverlayNoModal.stories'; export { Inline } from './DrawerInline.stories'; export { Position } from './DrawerPosition.stories'; export { Size } from './DrawerSize.stories'; export { CustomSize } from './DrawerCustomSize.stories'; export { Separator } from './DrawerSeparator.stories'; -export { AlwaysOpen } from './DrawerAlwaysOpen.stories'; -export { PreventClose } from './DrawerPreventClose.stories'; export { WithNavigation } from './DrawerWithNavigation.stories'; export { WithScroll } from './DrawerWithScroll.stories'; +export { AlwaysOpen } from './DrawerAlwaysOpen.stories'; +export { PreventClose } from './DrawerPreventClose.stories'; export { Responsive } from './DrawerResponsive.stories'; export { Resizable } from './DrawerResizable.stories';