Skip to content

armgit / ente

Public Imported from GitHub
0

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

New layout

Manav Rathi6bef1d2e208b
diff --git a/web/packages/accounts/components/AccountsPageContents.tsx b/web/packages/accounts/components/AccountsPageContents.tsx
deleted file mode 100644
index ffc473c78e..0000000000
--- a/web/packages/accounts/components/AccountsPageContents.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { CenteredFill, Stack100vhCenter } from "@/base/components/containers";
-import { FormPaper } from "@/base/components/FormPaper";
-import { AppNavbar } from "@/base/components/Navbar";
-
-/**
- * An ad-hoc component that abstracts the layout common to many of the pages
- * exported by the the accounts package.
- *
- * The layout is roughly:
- * - Set height to 100vh
- * - An app bar at the top
- * - Center a {@link FormPaper} in the rest of the space.
- * - The children passed to this component go within this {@link FormPaper}.
- */
-export const AccountsPageContents: React.FC<React.PropsWithChildren> = ({
- children,
-}) => (
- <Stack100vhCenter>
- <AppNavbar />
- <CenteredFill>
- <FormPaper>{children}</FormPaper>
- </CenteredFill>
- </Stack100vhCenter>
-);
diff --git a/web/packages/accounts/components/layouts/centered-paper.tsx b/web/packages/accounts/components/layouts/centered-paper.tsx
new file mode 100644
index 0000000000..cdbf9e6ff4
--- /dev/null
+++ b/web/packages/accounts/components/layouts/centered-paper.tsx
@@ -0,0 +1,73 @@
+import { CenteredFill } from "@/base/components/containers";
+import { AppNavbarNormalFlow } from "@/base/components/Navbar";
+import { isSxArray } from "@/base/components/utils/sx";
+import {
+ Paper,
+ Stack,
+ styled,
+ Typography,
+ type TypographyProps,
+} from "@mui/material";
+
+/**
+ * An ad-hoc component that abstracts the layout common to many of the pages
+ * exported by the the accounts package.
+ *
+ * The layout is roughly:
+ * - Set height to 100vh
+ * - An app bar at the top
+ * - Center a {@link FormPaper} in the rest of the space.
+ * - The children passed to this component go within this {@link FormPaper}.
+ */
+export const AccountsPageContents: React.FC<React.PropsWithChildren> = ({
+ children,
+}) => (
+ <Stack sx={{ minHeight: "100vh" }}>
+ <AppNavbarNormalFlow />
+ <CenteredFill>
+ <AccountsPagePaper>{children}</AccountsPagePaper>
+ </CenteredFill>
+ </Stack>
+);
+
+const AccountsPagePaper = styled(Paper)(({ theme }) => ({
+ marginBlock: theme.spacing(2),
+ padding: theme.spacing(4, 2),
+ width: "min(375px, 80vw)",
+ minHeight: "375px",
+ display: "flex",
+ flexDirection: "column",
+ gap: theme.spacing(4),
+ overflowY: "scroll",
+}));
+
+export const AccountsPageTitle: React.FC<TypographyProps> = ({
+ sx,
+ children,
+ ...rest
+}) => (
+ <Typography
+ variant="h3"
+ sx={[{ flex: 1 }, ...(sx ? (isSxArray(sx) ? sx : [sx]) : [])]}
+ {...rest}
+ >
+ {children}
+ </Typography>
+);
+
+export const AccountsPageFooter: React.FC<React.PropsWithChildren> = ({
+ children,
+}) => (
+ <Stack
+ direction="row"
+ sx={{
+ mx: "4px",
+ // Put the items to the side,
+ justifyContent: "space-between",
+ // Unless there is just one, in which case center it.
+ "& :only-child": { "margin-inline": "auto" },
+ }}
+ >
+ {children}
+ </Stack>
+);
diff --git a/web/packages/accounts/pages/two-factor/recover.tsx b/web/packages/accounts/pages/two-factor/recover.tsx
index 7afc184ef7..518a07a73d 100644
--- a/web/packages/accounts/pages/two-factor/recover.tsx
+++ b/web/packages/accounts/pages/two-factor/recover.tsx
@@ -1,4 +1,8 @@
-import { AccountsPageContents } from "@/accounts/components/AccountsPageContents";
+import {
+ AccountsPageContents,
+ AccountsPageFooter,
+ AccountsPageTitle,
+} from "@/accounts/components/layouts/centered-paper";
import { PAGES } from "@/accounts/constants/pages";
import {
recoverTwoFactor,
@@ -6,7 +10,6 @@ import {
type TwoFactorType,
} from "@/accounts/services/user";
import type { AccountsContextT } from "@/accounts/types/context";
-import { FormPaperFooter, FormPaperTitle } from "@/base/components/FormPaper";
import type { MiniDialogAttributes } from "@/base/components/MiniDialog";
import { sharedCryptoWorker } from "@/base/crypto";
import type { B64EncryptionResult } from "@/base/crypto/libsodium";
@@ -163,7 +166,7 @@ const Page: React.FC<RecoverPageProps> = ({ appContext, twoFactorType }) => {
return (
<AccountsPageContents>
- <FormPaperTitle>{t("recover_two_factor")}</FormPaperTitle>
+ <AccountsPageTitle>{t("recover_two_factor")}</AccountsPageTitle>
<SingleInputForm
callback={recover}
fieldType="text"
@@ -171,12 +174,12 @@ const Page: React.FC<RecoverPageProps> = ({ appContext, twoFactorType }) => {
buttonText={t("recover")}
disableAutoComplete
/>
- <FormPaperFooter>
+ <AccountsPageFooter>
<LinkButton onClick={() => showContactSupportDialog()}>
{t("no_recovery_key_title")}
</LinkButton>
<LinkButton onClick={router.back}>{t("go_back")}</LinkButton>
- </FormPaperFooter>
+ </AccountsPageFooter>
</AccountsPageContents>
);
};
diff --git a/web/packages/base/components/Navbar.tsx b/web/packages/base/components/Navbar.tsx
index 4d93f87c37..79034aa722 100644
--- a/web/packages/base/components/Navbar.tsx
+++ b/web/packages/base/components/Navbar.tsx
@@ -34,6 +34,24 @@ export const AppNavbar: React.FC = () => {
);
};
+const NavbarBaseNormalFlow = styled("div")`
+ height: 64px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
+`;
+
+/**
+ * A variant of AppNavbar that places itself normally in the document flow
+ * instead of using a fixed positioning.
+ */
+export const AppNavbarNormalFlow: React.FC = () => (
+ <NavbarBaseNormalFlow>
+ <EnteLogo />
+ </NavbarBaseNormalFlow>
+);
+
export const SelectionBar = styled(NavbarBase)`
position: fixed;
z-index: 12;
diff --git a/web/packages/base/components/containers.tsx b/web/packages/base/components/containers.tsx
index 9ddfdb2580..e95893f2dc 100644
--- a/web/packages/base/components/containers.tsx
+++ b/web/packages/base/components/containers.tsx
@@ -1,11 +1,11 @@
import { Stack, styled } from "@mui/material";
/**
- * A {@link Stack} that takes up the height of the entire viewport, and both
- * vertically and horizontally centers its children.
+ * A {@link Stack} that takes up at least the height of the entire viewport, and
+ * centers its children both vertically and horizontally.
*/
export const Stack100vhCenter = styled(Stack)`
- height: 100vh;
+ min-height: 100vh;
justify-content: center;
align-items: center;
`;
diff --git a/web/packages/base/components/mui/SidebarDrawer.tsx b/web/packages/base/components/mui/SidebarDrawer.tsx
index b0c79042a5..5838f31b7a 100644
--- a/web/packages/base/components/mui/SidebarDrawer.tsx
+++ b/web/packages/base/components/mui/SidebarDrawer.tsx
@@ -10,8 +10,8 @@ import {
type DrawerProps,
} from "@mui/material";
import React from "react";
+import { SpaceBetweenFlex } from "../containers";
import type { ModalVisibilityProps } from "../utils/modal";
-import { SpaceBetweenFlex } from "./Container";
/**
* A MUI {@link Drawer} with a standard set of styling that we use for our left