Skip to content

Commit

Permalink
update drawer behavior when other drawer is opened
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcfaul committed Nov 22, 2024
1 parent 16bbed2 commit 8b6aa3b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
28 changes: 20 additions & 8 deletions packages/dev/src/AppCustomDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ const App: React.FC<AppProps> = ({ children, showCardFooters }) => {
};

const [modalOpen, setModalOpen] = React.useState<boolean>(false);
const onClose = () => setActiveQuickStartID('');
const onClose = () => {
setActiveQuickStartID('');
setDrawerContent('none');
};
const handleClose = (activeQuickStartStatus: string | number) => {
if (activeQuickStartStatus === QuickStartStatus.IN_PROGRESS) {
setModalOpen(true);
Expand All @@ -107,14 +110,14 @@ const App: React.FC<AppProps> = ({ children, showCardFooters }) => {
};
const onModalCancel = () => setModalOpen(false);

const [otherDrawerOpen, setOtherDrawerOpen] = React.useState(false);
const [drawerContent, setDrawerContent] = React.useState('none');

const otherDrawerPanelContent = (
<DrawerPanelContent>
<DrawerHead>
<span tabIndex={otherDrawerOpen ? 0 : -1}>Drawer panel header</span>
<span tabIndex={drawerContent === 'custom' ? 0 : -1}>Drawer panel header</span>
<DrawerActions>
<DrawerCloseButton onClick={() => setOtherDrawerOpen(false)} />
<DrawerCloseButton onClick={() => setDrawerContent('none')} />
</DrawerActions>
</DrawerHead>
<DrawerPanelDescription>Drawer panel description</DrawerPanelDescription>
Expand All @@ -125,10 +128,10 @@ const App: React.FC<AppProps> = ({ children, showCardFooters }) => {
return (
<React.Suspense fallback={<LoadingBox />}>
<QuickStartContainer {...containerProps} isManagedDrawer={false}>
<Drawer isExpanded={activeQuickStartID !== '' || otherDrawerOpen} isInline>
<Drawer isExpanded={drawerContent !== 'none'} isInline>
<DrawerContent
panelContent={
activeQuickStartID !== '' ? (
drawerContent === 'quickstart' || activeQuickStartID !== '' ? (
<QuickStartDrawerContent handleDrawerClose={handleClose} />
) : (
otherDrawerPanelContent
Expand All @@ -139,11 +142,20 @@ const App: React.FC<AppProps> = ({ children, showCardFooters }) => {
<Page masthead={AppHeader} sidebar={AppSidebar} isManagedSidebar>
<Button
variant="secondary"
onClick={() => toggleQuickStart('getting-started-with-quick-starts')}
onClick={() => {
toggleQuickStart('getting-started-with-quick-starts');
setDrawerContent('quickstart');
}}
>
Getting started with quick starts
</Button>
<Button variant="secondary" onClick={() => setOtherDrawerOpen(true)}>
<Button
variant="secondary"
onClick={() => {
setActiveQuickStartID('');
setDrawerContent('custom');
}}
>
Open a different drawer
</Button>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export const App = ({ showCardFooters }) => {
};

const [modalOpen, setModalOpen] = React.useState(false);
const onClose = () => setActiveQuickStartID('');
const onClose = () => {
setActiveQuickStartID('');
setDrawerContent('none');
};
const handleClose = (activeQuickStartStatus) => {
if (activeQuickStartStatus === QuickStartStatus.IN_PROGRESS) {
setModalOpen(true);
Expand All @@ -88,14 +91,14 @@ export const App = ({ showCardFooters }) => {
};
const onModalCancel = () => setModalOpen(false);

const [otherDrawerOpen, setOtherDrawerOpen] = React.useState(false);
const [drawerContent, setDrawerContent] = React.useState('none');

const otherDrawerPanelContent = (
<DrawerPanelContent>
<DrawerHead>
<span tabIndex={otherDrawerOpen ? 0 : -1}>Drawer panel header</span>
<span tabIndex={drawerContent === 'custom' ? 0 : -1}>Drawer panel header</span>
<DrawerActions>
<DrawerCloseButton onClick={() => setOtherDrawerOpen(false)} />
<DrawerCloseButton onClick={() => setDrawerContent('none')} />
</DrawerActions>
</DrawerHead>
<DrawerPanelDescription>Drawer panel description</DrawerPanelDescription>
Expand All @@ -106,10 +109,10 @@ export const App = ({ showCardFooters }) => {
return (
<React.Suspense fallback={<LoadingBox />}>
<QuickStartContainer {...drawerProps} isManagedDrawer={false}>
<Drawer isExpanded={activeQuickStartID !== '' || otherDrawerOpen} isInline>
<Drawer isExpanded={drawerContent !== 'none'} isInline>
<DrawerContent
panelContent={
activeQuickStartID !== '' ? (
drawerContent === 'quickstart' || activeQuickStartID !== '' ? (
<QuickStartDrawerContent handleDrawerClose={handleClose} />
) : (
otherDrawerPanelContent
Expand All @@ -119,11 +122,20 @@ export const App = ({ showCardFooters }) => {
<DrawerContentBody>
<Button
variant="secondary"
onClick={() => setActiveQuickStartID('explore-pipelines')}
onClick={() => {
setActiveQuickStartID('explore-pipelines');
setDrawerContent('quickstart');
}}
>
Getting started with quick starts
</Button>
<Button variant="secondary" onClick={() => setOtherDrawerOpen(true)}>
<Button
variant="secondary"
onClick={() => {
setActiveQuickStartID('');
setDrawerContent('custom');
}}
>
Open a different drawer
</Button>
<QuickStartCatalogPage
Expand Down

0 comments on commit 8b6aa3b

Please sign in to comment.