Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

S2

Manav Rathi31cdb63c7d99
diff --git a/web/packages/base/components/mui/SidebarDrawer.tsx b/web/packages/base/components/mui/SidebarDrawer.tsx
index aefb731044..9248827985 100644
--- a/web/packages/base/components/mui/SidebarDrawer.tsx
+++ b/web/packages/base/components/mui/SidebarDrawer.tsx
@@ -1,4 +1,5 @@
-import { Drawer, styled } from "@mui/material";
+import { Drawer, styled, type DrawerProps } from "@mui/material";
+import type { ModalVisibilityProps } from "../utils/modal";
/**
* A MUI {@link Drawer} with a standard set of styling that we use for our left
@@ -16,8 +17,38 @@ export const SidebarDrawer = styled(Drawer)(({ theme }) => ({
},
}));
+/**
+ * Common props for a {@link NestedSidebarDrawer} component. In addition to the
+ * regular modal visibility controls for opening and closing itself, these also
+ * surface an option to close the entire drawer.
+ */
+export type NestedSidebarDrawerVisibilityProps = ModalVisibilityProps & {
+ /**
+ * Called when the user wants to close the entire stack of drawers.
+ *
+ * Note that this does not automatically imply onClose. Each step in the
+ * nesting will have to chain their own onCloses to construct a new
+ * `onRootClose` suitable for passing to its children.
+ */
+ onRootClose: () => void;
+};
+
/**
* A variant of {@link SidebarDrawer} for second level, nested drawers that are
* shown atop an already visible {@link SidebarDrawer}.
*/
-// export const NestedDrawerVisibilityProps
+export const NestedSidebarDrawer: React.FC<
+ NestedSidebarDrawerVisibilityProps & DrawerProps
+> = (props) => (
+ // MUI doesn't (currently, AFAIK) have support for nested drawers, so we
+ // emulate that by showing a drawer atop another. To make it fit, we need to
+ // modify two knobs:
+ //
+ // 1. Disable the transition (otherwise our nested drawer visibly slides in
+ // from the wrong direction).
+ //
+ // 2. Disable the backdrop (otherwise we'd end up with two of them - one
+ // from the original drawer, and one from this nested one).
+ //
+ <SidebarDrawer transitionDuration={0} hideBackdrop {...props} />
+);
diff --git a/web/packages/base/components/utils/modal.ts b/web/packages/base/components/utils/modal.ts
index 0a2dd1588e..0b40c9d786 100644
--- a/web/packages/base/components/utils/modal.ts
+++ b/web/packages/base/components/utils/modal.ts
@@ -11,22 +11,6 @@ export interface ModalVisibilityProps {
onClose: () => void;
}
-/**
- * Common props for a nested drawer component. In addition to the regular modal
- * visibility controls for opening and closing itself, these also surface an
- * option to close the entire drawer.
- */
-export type NestedDrawerVisibilityProps = ModalVisibilityProps & {
- /**
- * Called when the user wants to close the entire stack of drawers.
- *
- * Note that this does not automatically imply onClose. Each step in the
- * nesting will have to chain their own onCloses to construct a new
- * `onRootClose` suitable for passing to its children.
- */
- onRootClose: () => void;
-};
-
/**
* A convenience hook for keeping the state for opening and closing a modal, and
* exposing a function to close the modal whose identity is stable.