Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refresh Photobook imports and mobile previews

Anand Baburajan4124de52d4e7
diff --git a/web/apps/photobook/public/photobook-duck.png b/web/apps/photobook/public/photobook-duck.png
new file mode 100644
index 0000000000..2007fe950c
Binary files /dev/null and b/web/apps/photobook/public/photobook-duck.png differ
diff --git a/web/apps/photobook/src/components/AppShell.tsx b/web/apps/photobook/src/components/AppShell.tsx
index 15b6a86ce5..314463cde1 100644
--- a/web/apps/photobook/src/components/AppShell.tsx
+++ b/web/apps/photobook/src/components/AppShell.tsx
@@ -2,48 +2,22 @@ import EditPage from "@/components/EditPage";
import ResultsPage from "@/components/ResultsPage";
import { useBook } from "@/context/book";
import { usePhotoImport } from "@/hooks/usePhotoImport";
-import type { AppView } from "@/lib/types";
import { popupShadow, uiColors } from "@/theme/colors";
import {
Alert,
Box,
CircularProgress,
- Dialog,
- DialogContent,
- Fade,
- IconButton,
Snackbar,
- Typography,
useMediaQuery,
} from "@mui/material";
-import { useEffect, useState } from "react";
+import { MOBILE_QUERY } from "./editorLayout";
import EntePasswordDialog from "./EntePasswordDialog";
-import { CloseIcon } from "./icons";
import ImportProgress from "./ImportProgress";
-function BookWorkspace({ view }: { view: AppView }) {
- const [displayedView, setDisplayedView] = useState(view);
- const reduceMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
- const visible = displayedView === view;
-
- return (
- <Fade
- in={visible}
- appear={false}
- timeout={reduceMotion ? 0 : { exit: 120, enter: 220 }}
- easing={{ exit: "ease-in", enter: "ease-out" }}
- onExited={() => setDisplayedView(view)}
- >
- <Box inert={!visible} data-workspace-view={displayedView}>
- {displayedView === "results" ? <ResultsPage /> : <EditPage />}
- </Box>
- </Fade>
- );
-}
-
export default function AppShell() {
- const { appView, loading, book, importNotice, clearImportNotice } =
- useBook();
+ const mobile = useMediaQuery(MOBILE_QUERY, { noSsr: true });
+ const { appView, loading, importNotice, clearImportNotice } = useBook();
+ const showPreview = mobile || appView === "results";
const {
importActive,
enteStage,
@@ -52,21 +26,6 @@ export default function AppShell() {
handleSubmitPassword,
handleCancelPassword,
} = usePhotoImport();
- const [showMobileHint, setShowMobileHint] = useState(false);
-
- useEffect(() => {
- if (
- !importActive &&
- book.pages.length > 0 &&
- appView === "edit" &&
- typeof window !== "undefined" &&
- window.matchMedia("(max-width: 640px)").matches
- ) {
- const dismissed = sessionStorage.getItem("mobile-hint-dismissed");
- if (!dismissed) setShowMobileHint(true);
- }
- }, [appView, importActive, book.pages.length]);
-
if (loading) {
return (
<Box
@@ -87,7 +46,9 @@ export default function AppShell() {
{importActive ? (
<ImportProgress />
) : (
- <BookWorkspace view={appView} />
+ <Box data-workspace-view={showPreview ? "results" : "edit"}>
+ {showPreview ? <ResultsPage /> : <EditPage />}
+ </Box>
)}
<EntePasswordDialog
open={enteStage === "password"}
@@ -116,79 +77,6 @@ export default function AppShell() {
{importNotice}
</Alert>
</Snackbar>
-
- <Dialog
- open={showMobileHint}
- onClose={() => {
- setShowMobileHint(false);
- sessionStorage.setItem("mobile-hint-dismissed", "1");
- }}
- slotProps={{
- paper: {
- sx: {
- borderRadius: 4,
- maxWidth: 300,
- mx: 2,
- p: 0,
- bgcolor: uiColors.surface,
- boxShadow: popupShadow,
- },
- },
- }}
- >
- <DialogContent
- sx={{
- textAlign: "center",
- py: 3.5,
- px: 3,
- position: "relative",
- }}
- >
- <IconButton
- onClick={() => {
- setShowMobileHint(false);
- sessionStorage.setItem(
- "mobile-hint-dismissed",
- "1",
- );
- }}
- size="small"
- sx={{
- position: "absolute",
- top: 6,
- right: 6,
- color: uiColors.muted,
- "&:hover": { color: uiColors.text },
- }}
- >
- <CloseIcon sx={{ fontSize: 18 }} />
- </IconButton>
- <Typography
- variant="body"
- sx={{
- fontFamily: "var(--font-inter)",
- fontWeight: 700,
- mb: 0.5,
- color: uiColors.text,
- fontSize: "1rem",
- }}
- >
- Best on desktop
- </Typography>
- <Typography
- variant="small"
- sx={{
- fontFamily: "var(--font-inter)",
- color: uiColors.muted,
- lineHeight: 1.55,
- fontSize: "0.835rem",
- }}
- >
- The photobook editor works best on a larger screen. For
- the full experience, try it on a desktop or laptop.
- </Typography>
- </DialogContent>
- </Dialog>
</>
);
}
diff --git a/web/apps/photobook/src/components/BookBindingSelect.tsx b/web/apps/photobook/src/components/BookBindingSelect.tsx
index ec1f761470..6a9e0a6d8f 100644
--- a/web/apps/photobook/src/components/BookBindingSelect.tsx
+++ b/web/apps/photobook/src/components/BookBindingSelect.tsx
@@ -1,7 +1,9 @@
import { useBook } from "@/context/book";
import { getBindingPrintSelection, getPrintBinding } from "@/lib/printProducts";
import { accentGreen } from "@/theme/buttons";
-import { dialogSelectMenuProps, dialogSelectSx } from "@/theme/dialogs";
+import { pageMenuColors } from "@/theme/colors";
+import { dialogSelectSx } from "@/theme/dialogs";
+import { pageMenuItemSx, pageMenuPaperSx } from "@/theme/menus";
import { MenuItem, Select } from "@mui/material";
import { ChevronDownIcon } from "./icons";
@@ -18,7 +20,23 @@ export default function BookBindingSelect({
disabled={disabled || processingPhotos}
inputProps={{ "aria-label": "Cover type" }}
IconComponent={ChevronDownIcon}
- MenuProps={dialogSelectMenuProps}
+ MenuProps={{
+ sx: {
+ "& .MuiMenuItem-root": {
+ ...pageMenuItemSx,
+ "&.Mui-selected": { bgcolor: "transparent" },
+ "&.Mui-selected:hover, &.Mui-selected.Mui-focusVisible":
+ { bgcolor: pageMenuColors.hover },
+ "&.Mui-selected:active": {
+ bgcolor: pageMenuColors.active,
+ },
+ },
+ },
+ slotProps: {
+ paper: { sx: pageMenuPaperSx },
+ list: { sx: { p: 0 } },
+ },
+ }}
onChange={(event) => {
const next = event.target.value;
if (!book.printSelection || next !== binding)
@@ -33,6 +51,7 @@ export default function BookBindingSelect({
width: "auto",
mr: "14px",
height: { xs: 38, sm: 40 },
+ "@media (max-width: 959px)": { height: 44, mr: 0 },
flexShrink: 0,
borderRadius: { xs: "12px", sm: "14px" },
fontSize: 13,
@@ -53,6 +72,9 @@ export default function BookBindingSelect({
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
borderColor: "transparent",
},
+ "&.Mui-disabled .MuiOutlinedInput-notchedOutline": {
+ borderColor: "transparent",
+ },
"& .MuiSelect-select:focus-visible": {
outline: `2px solid ${accentGreen}`,
outlineOffset: -2,
@@ -60,8 +82,12 @@ export default function BookBindingSelect({
},
}}
>
- <MenuItem value="Hardcover">Hardcover</MenuItem>
- <MenuItem value="Softcover">Softcover</MenuItem>
+ <MenuItem value="Hardcover" dense disableRipple>
+ Hardcover
+ </MenuItem>
+ <MenuItem value="Softcover" dense disableRipple>
+ Softcover
+ </MenuItem>
</Select>
);
}
diff --git a/web/apps/photobook/src/components/BookBrand.tsx b/web/apps/photobook/src/components/BookBrand.tsx
new file mode 100644
index 0000000000..0dab823f23
--- /dev/null
+++ b/web/apps/photobook/src/components/BookBrand.tsx
@@ -0,0 +1,45 @@
+import { Box, Typography } from "@mui/material";
+
+export default function BookBrand({
+ showTitle = true,
+}: {
+ showTitle?: boolean;
+}) {
+ return (
+ <Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
+ <Box
+ component="img"
+ src="/ente-branding.svg"
+ alt="Ente"
+ sx={{
+ display: "block",
+ height: {
+ xs: showTitle ? 16 : 20,
+ sm: showTitle ? 20 : 24,
+ },
+ width: "auto",
+ filter: "invert(1)",
+ "@media (max-width: 359px)": {
+ height: showTitle ? 13 : 17,
+ },
+ }}
+ />
+ {showTitle && (
+ <Typography
+ sx={{
+ fontFamily: '"Gochi Hand", cursive',
+ fontSize: { xs: 24, sm: 32 },
+ lineHeight: 1.2,
+ fontWeight: 400,
+ color: "#F2C14E",
+ transform: "translateY(1px)",
+ whiteSpace: "nowrap",
+ "@media (max-width: 359px)": { fontSize: 21 },
+ }}
+ >
+ photobook
+ </Typography>
+ )}
+ </Box>
+ );
+}
diff --git a/web/apps/photobook/src/components/BookHeader.tsx b/web/apps/photobook/src/components/BookHeader.tsx
index ab9aa18154..b37ea4e70f 100644
--- a/web/apps/photobook/src/components/BookHeader.tsx
+++ b/web/apps/photobook/src/components/BookHeader.tsx
@@ -1,14 +1,18 @@
-import { Box, Typography } from "@mui/material";
+import { Box } from "@mui/material";
import type { ReactNode } from "react";
+import BookBindingSelect from "./BookBindingSelect";
+import BookBrand from "./BookBrand";
import BookTitleInput from "./BookTitleInput";
import { EDITOR_HEADER_HEIGHT } from "./editorLayout";
export default function BookHeader({
children,
showBookControls = true,
+ titleDisabled = false,
}: {
children: ReactNode;
showBookControls?: boolean;
+ titleDisabled?: boolean;
}) {
return (
<Box
@@ -28,55 +32,44 @@ export default function BookHeader({
flexShrink: 0,
}}
>
+ <Box sx={{ gridColumn: 1, gridRow: 1, justifySelf: "start" }}>
+ <BookBrand />
+ </Box>
+ {showBookControls && <BookTitleInput disabled={titleDisabled} />}
<Box
sx={{
- gridColumn: 1,
+ gridColumn: 3,
gridRow: 1,
- justifySelf: "start",
- display: "flex",
+ justifySelf: "end",
+ display: showBookControls
+ ? { xs: "contents", md: "flex" }
+ : "none",
alignItems: "center",
gap: 1,
}}
>
<Box
- component="img"
- src="/ente-branding.svg"
- alt="Ente"
sx={{
- display: "block",
- height: { xs: 16, sm: 20 },
- width: "auto",
- filter: "invert(1)",
- "@media (max-width: 359px)": { height: 13 },
+ gridColumn: 2,
+ gridRow: 2,
+ justifySelf: "end",
+ display: "flex",
}}
- />
- <Typography
+ >
+ <BookBindingSelect disabled={titleDisabled} />
+ </Box>
+ <Box
sx={{
- fontFamily: '"Gochi Hand", cursive',
- fontSize: { xs: 24, sm: 32 },
- lineHeight: 1.2,
- fontWeight: 400,
- color: "#F2C14E",
- transform: "translateY(1px)",
- whiteSpace: "nowrap",
- "@media (max-width: 359px)": { fontSize: 21 },
+ gridColumn: 2,
+ gridRow: 1,
+ justifySelf: "end",
+ display: "flex",
+ alignItems: "center",
+ gap: 1,
}}
>
- photobook
- </Typography>
- </Box>
- {showBookControls && <BookTitleInput />}
- <Box
- sx={{
- gridColumn: { xs: "1 / -1", md: 3 },
- gridRow: { xs: 2, md: 1 },
- justifySelf: "end",
- display: showBookControls ? "flex" : "none",
- alignItems: "center",
- gap: 1,
- }}
- >
- {children}
+ {children}
+ </Box>
</Box>
</Box>
);
diff --git a/web/apps/photobook/src/components/BookTitleInput.tsx b/web/apps/photobook/src/components/BookTitleInput.tsx
index c90a08c71e..c78161679f 100644
--- a/web/apps/photobook/src/components/BookTitleInput.tsx
+++ b/web/apps/photobook/src/components/BookTitleInput.tsx
@@ -1,10 +1,18 @@
import { useBook } from "@/context/book";
import { headerButtonSx } from "@/theme/buttons";
import { uiColors } from "@/theme/colors";
-import { Box } from "@mui/material";
+import { Box, useMediaQuery } from "@mui/material";
import { useEffect, useState } from "react";
+import { MOBILE_QUERY } from "./editorLayout";
+import MobileTextDialog from "./MobileTextDialog";
-export default function BookTitleInput() {
+export default function BookTitleInput({
+ disabled = false,
+}: {
+ disabled?: boolean;
+}) {
+ const compact = useMediaQuery(MOBILE_QUERY);
+ const [editing, setEditing] = useState(false);
const { book, setBook } = useBook();
const [title, setTitle] = useState(book.title ?? "");
const [focused, setFocused] = useState(false);
@@ -15,74 +23,102 @@ export default function BookTitleInput() {
}, [book.title, focused]);
return (
- <Box
- sx={{
- position: "relative",
- gridColumn: 2,
- gridRow: 1,
- justifySelf: "center",
- width: "max-content",
- maxWidth: { xs: "min(38vw, 160px)", md: "min(360px, 100%)" },
- minWidth: 0,
- fontFamily: "var(--font-inter), sans-serif",
- fontSize: 14,
- fontWeight: 600,
- lineHeight: "20px",
- }}
- >
+ <>
<Box
- component="span"
- aria-hidden="true"
sx={{
- display: "block",
- visibility: "hidden",
- whiteSpace: "pre",
- overflow: "hidden",
- minWidth: "calc(1ch + 34px)",
- p: { xs: "8px 12px", sm: "9px 16px" },
- border: "1px solid transparent",
+ position: "relative",
+ gridColumn: { xs: 1, md: 2 },
+ gridRow: { xs: 2, md: 1 },
+ justifySelf: { xs: "start", md: "center" },
+ width: "max-content",
+ maxWidth: { xs: "100%", md: "min(360px, 100%)" },
+ minWidth: compact ? 0 : !title && !focused ? 167 : 0,
+ minHeight: compact ? 44 : undefined,
+ fontFamily: "var(--font-inter), sans-serif",
+ fontSize: 14,
+ fontWeight: 600,
+ lineHeight: "20px",
}}
>
- {title || placeholder || " "}
+ <Box
+ component="span"
+ aria-hidden="true"
+ sx={{
+ display: "block",
+ visibility: "hidden",
+ whiteSpace: "pre",
+ overflow: "hidden",
+ minWidth: "calc(1ch + 34px)",
+ p: { xs: "8px 12px", sm: "9px 16px" },
+ border: "1px solid transparent",
+ }}
+ >
+ {title || placeholder || " "}
+ </Box>
+ <Box
+ component="input"
+ aria-label="Photobook title"
+ value={title}
+ placeholder={placeholder}
+ autoComplete="off"
+ disabled={disabled}
+ readOnly={compact}
+ onClick={compact ? () => setEditing(true) : undefined}
+ onChange={(event) => setTitle(event.target.value)}
+ onFocus={() => {
+ if (!compact) setFocused(true);
+ }}
+ onBlur={() => {
+ setFocused(false);
+ if (title !== (book.title ?? "")) {
+ setBook((previous) => ({ ...previous, title }));
+ }
+ }}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ if (compact) setEditing(true);
+ else event.currentTarget.blur();
+ }
+ }}
+ sx={{
+ position: "absolute",
+ inset: 0,
+ width: "100%",
+ height: "100%",
+ minWidth: 0,
+ p: { xs: "8px 12px", sm: "9px 16px" },
+ font: "inherit",
+ color: uiColors.text,
+ textAlign: "center",
+ bgcolor: "#262626",
+ border: "1px solid transparent",
+ borderRadius: headerButtonSx.borderRadius,
+ outline: "none",
+ transition:
+ "background-color 120ms ease, border-color 120ms ease",
+ "&::placeholder": { color: uiColors.muted, opacity: 1 },
+ "&:enabled:hover": {
+ bgcolor: "#2E2E2E",
+ borderColor: "#484848",
+ },
+ "&:enabled:focus": {
+ bgcolor: "#2E2E2E",
+ borderColor: "#707070",
+ },
+ "&:disabled": { opacity: 0.45 },
+ }}
+ />
</Box>
- <Box
- component="input"
- aria-label="Photobook title"
- value={title}
- placeholder={placeholder}
- autoComplete="off"
- onChange={(event) => setTitle(event.target.value)}
- onFocus={() => setFocused(true)}
- onBlur={() => {
- setFocused(false);
- if (title !== (book.title ?? "")) {
- setBook((previous) => ({ ...previous, title }));
+ {editing && (
+ <MobileTextDialog
+ title="Book title (on spine)"
+ value={book.title ?? ""}
+ onSave={(value) =>
+ setBook((previous) => ({ ...previous, title: value }))
}
- }}
- onKeyDown={(event) => {
- if (event.key === "Enter") event.currentTarget.blur();
- }}
- sx={{
- position: "absolute",
- inset: 0,
- width: "100%",
- height: "100%",
- minWidth: 0,
- p: { xs: "8px 12px", sm: "9px 16px" },
- font: "inherit",
- color: uiColors.text,
- textAlign: "center",
- bgcolor: "#262626",
- border: "1px solid transparent",
- borderRadius: headerButtonSx.borderRadius,
- outline: "none",
- transition:
- "background-color 120ms ease, border-color 120ms ease",
- "&::placeholder": { color: uiColors.muted, opacity: 1 },
- "&:hover": { bgcolor: "#2E2E2E", borderColor: "#484848" },
- "&:focus": { bgcolor: "#2E2E2E", borderColor: "#707070" },
- }}
- />
- </Box>
+ onClose={() => setEditing(false)}
+ />
+ )}
+ </>
);
}
diff --git a/web/apps/photobook/src/components/BookViewer.tsx b/web/apps/photobook/src/components/BookViewer.tsx
index 983601594d..daabd89dc5 100644
--- a/web/apps/photobook/src/components/BookViewer.tsx
+++ b/web/apps/photobook/src/components/BookViewer.tsx
@@ -9,7 +9,7 @@ import {
} from "@/lib/spreads";
import type { BookPage } from "@/lib/types";
import { uiColors } from "@/theme/colors";
-import { Box, IconButton } from "@mui/material";
+import { Box, IconButton, useMediaQuery } from "@mui/material";
import { PageFlip } from "page-flip";
import {
forwardRef,
@@ -24,8 +24,10 @@ import {
import { createPortal } from "react-dom";
import { Layer, Stage } from "react-konva";
import BookPageNavigation from "./BookPageNavigation";
+import { SINGLE_PAGE_QUERY } from "./editorLayout";
import { ChevronLeftIcon, ChevronRightIcon } from "./icons";
import PageCanvas from "./PageCanvas";
+import PrinterBlankPage from "./PrinterBlankPage";
const PAGE_NAVIGATION_SPACE = 72;
@@ -54,6 +56,8 @@ interface BookViewerProps {
const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
function BookViewer({ pages, onSpreadChange }, ref) {
+ const singlePage = useMediaQuery(SINGLE_PAGE_QUERY);
+ const swipeStart = useRef<{ x: number; y: number } | null>(null);
const { book: bookState, photoUrls, loadPreviews } = useBook();
const binding = getPrintBinding(bookState.printSelection);
const flipPages = useMemo(
@@ -104,10 +108,10 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
1,
Math.floor(
Math.min(
- width / 2,
+ width / (singlePage ? 1 : 2),
Math.max(1, height - PAGE_NAVIGATION_SPACE),
1200,
- ) * 0.768,
+ ) * (singlePage ? 1 : 0.768),
),
),
);
@@ -116,16 +120,36 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
const observer = new ResizeObserver(measure);
observer.observe(container);
return () => observer.disconnect();
- }, []);
+ }, [singlePage]);
+
+ const showMobilePage = useCallback(
+ (index: number) => {
+ const next = Math.max(0, Math.min(index, flipPages.length - 1));
+ setCurrentPage(next);
+ const pageIndex = flipPages[next]?.pageIndex;
+ if (pageIndex !== null && pageIndex !== undefined)
+ startPageRef.current = pageIndex;
+ onSpreadChangeRef.current(flipPages[next]?.spreadIndex ?? 0);
+ },
+ [flipPages],
+ );
const flipNext = useCallback(() => {
+ if (singlePage) {
+ showMobilePage(currentPage + 1);
+ return;
+ }
const book = pageFlipRef.current;
if (book?.getState() === "read") book.flipNext("bottom");
- }, []);
+ }, [singlePage, showMobilePage, currentPage]);
const flipPrev = useCallback(() => {
+ if (singlePage) {
+ showMobilePage(currentPage - 1);
+ return;
+ }
const book = pageFlipRef.current;
if (book?.getState() === "read") book.flipPrev("bottom");
- }, []);
+ }, [singlePage, showMobilePage, currentPage]);
useImperativeHandle(ref, () => ({ flipNext, flipPrev }), [
flipNext,
flipPrev,
@@ -144,6 +168,16 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
);
useEffect(() => {
+ if (singlePage) {
+ showMobilePage(
+ getFlipPageIndex(
+ pages.length,
+ Math.min(startPageRef.current, pages.length - 1),
+ binding,
+ ) ?? 0,
+ );
+ return;
+ }
const mount = mountRef.current;
if (!mount || flipPages.length === 0) return;
@@ -168,6 +202,7 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
});
mount.appendChild(root);
+ const requestedPage = startPageRef.current;
const book = new PageFlip(root, {
width: 600,
height: 600,
@@ -193,11 +228,15 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
usePortrait: false,
});
book.on("flip", (event: { data: number }) => {
- startPageRef.current =
- getSpreadPageIndices(
- spreads[flipPages[event.data]?.spreadIndex ?? 0]!,
- )[0] ??
- (event.data < flipPages.length / 2 ? 0 : pages.length - 1);
+ const indices = getSpreadPageIndices(
+ spreads[flipPages[event.data]?.spreadIndex ?? 0]!,
+ );
+ if (!indices.includes(startPageRef.current))
+ startPageRef.current =
+ indices[0] ??
+ (event.data < flipPages.length / 2
+ ? 0
+ : pages.length - 1);
setCurrentPage(event.data);
onSpreadChangeRef.current(
flipPages[event.data]?.spreadIndex ?? 0,
@@ -217,6 +256,7 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
? clipSoftcoverInsidePages(book)
: undefined;
book.update();
+ startPageRef.current = requestedPage;
pageFlipRef.current = book;
setPageElements(elements);
setCurrentPage(book.getCurrentPageIndex());
@@ -224,20 +264,29 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
return () => {
const index = book.getCurrentPageIndex();
- startPageRef.current =
- getSpreadPageIndices(
- spreads[flipPages[index]?.spreadIndex ?? 0]!,
- )[0] ??
- (index < flipPages.length / 2 ? 0 : pages.length - 1);
+ const indices = getSpreadPageIndices(
+ spreads[flipPages[index]?.spreadIndex ?? 0]!,
+ );
+ if (!indices.includes(startPageRef.current))
+ startPageRef.current =
+ indices[0] ??
+ (index < flipPages.length / 2 ? 0 : pages.length - 1);
pageFlipRef.current = null;
restoreCoverDrawing?.();
book.destroy();
};
- }, [flipPages, spreads, binding, pages.length]);
+ }, [
+ flipPages,
+ spreads,
+ binding,
+ pages.length,
+ singlePage,
+ showMobilePage,
+ ]);
useLayoutEffect(() => {
- pageFlipRef.current?.update();
- }, [pageSize]);
+ if (!singlePage) pageFlipRef.current?.update();
+ }, [pageSize, singlePage]);
const frontCover = currentPage === 0 && flipPages.length > 1;
const backCover = currentPage === flipPages.length - 1;
@@ -245,6 +294,144 @@ const BookViewer = forwardRef<BookViewerHandle, BookViewerProps>(
const showSpread = !closed || turning;
const shift = turning ? 0 : frontCover ? "-25%" : backCover ? "25%" : 0;
+ if (singlePage) {
+ const entry = flipPages[currentPage];
+ const page =
+ entry?.pageIndex != null ? pages[entry.pageIndex] : null;
+ const navigationPages = flipPages.map(({ pageIndex }) => ({
+ left: pageIndex ?? ("printer-blank" as const),
+ right: null,
+ }));
+ return (
+ <Box
+ ref={containerRef}
+ data-binding={binding}
+ sx={{
+ flex: 1,
+ minWidth: 0,
+ minHeight: 0,
+ my: 2,
+ position: "relative",
+ }}
+ >
+ <Box
+ sx={{
+ position: "absolute",
+ top: "50%",
+ left: "50%",
+ transform: "translate(-50%, -50%)",
+ width: pageSize,
+ maxWidth: "100%",
+ }}
+ >
+ <Box
+ aria-label={
+ page
+ ? entry?.pageIndex === 0
+ ? "Front cover"
+ : entry?.pageIndex === pages.length - 1
+ ? "Back cover"
+ : `Page ${entry?.pageIndex}`
+ : "Blank page (required)"
+ }
+ onPointerDown={(event) => {
+ if (event.button !== 0) return;
+ swipeStart.current = {
+ x: event.clientX,
+ y: event.clientY,
+ };
+ event.currentTarget.setPointerCapture(
+ event.pointerId,
+ );
+ }}
+ onPointerUp={(event) => {
+ const start = swipeStart.current;
+ swipeStart.current = null;
+ if (!start) return;
+ const dx = event.clientX - start.x;
+ if (
+ Math.abs(dx) > 45 &&
+ Math.abs(dx) >
+ Math.abs(event.clientY - start.y)
+ ) {
+ if (dx < 0) flipNext();
+ else flipPrev();
+ }
+ }}
+ onPointerCancel={() => {
+ swipeStart.current = null;
+ }}
+ sx={{ touchAction: "pan-y pinch-zoom" }}
+ >
+ {page ? (
+ <Stage
+ width={pageSize}
+ height={pageSize}
+ listening={false}
+ >
+ <Layer>
+ <PageCanvas
+ page={page}
+ photoUrls={photoUrls}
+ pageWidth={pageSize}
+ pageHeight={pageSize}
+ isFrontCover={
+ entry?.pageIndex === 0
+ }
+ isBackCover={
+ entry?.pageIndex ===
+ pages.length - 1
+ }
+ />
+ </Layer>
+ </Stage>
+ ) : (
+ <PrinterBlankPage
+ width={pageSize}
+ height={pageSize}
+ showLabel
+ />
+ )}
+ </Box>
+ <Box
+ sx={{
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ gap: 1,
+ mt: 3,
+ }}
+ >
+ <IconButton
+ aria-label="Previous page"
+ disabled={currentPage === 0}
+ onClick={flipPrev}
+ sx={{ width: 44, height: 44 }}
+ >
+ <ChevronLeftIcon />
+ </IconButton>
+ <BookPageNavigation
+ pageCount={pages.length}
+ spreads={navigationPages}
+ spreadIndex={currentPage}
+ disabled={flipPages.length === 0}
+ turning={false}
+ onGoToSpread={showMobilePage}
+ />
+ <IconButton
+ aria-label="Next page"
+ disabled={currentPage >= flipPages.length - 1}
+ onClick={flipNext}
+ sx={{ width: 44, height: 44 }}
+ >
+ <ChevronRightIcon />
+ </IconButton>
+ </Box>
+ </Box>
+ </Box>
+ );
+ }
+
return (
<Box
ref={containerRef}
diff --git a/web/apps/photobook/src/components/EditPage.tsx b/web/apps/photobook/src/components/EditPage.tsx
index 2d2e0f1662..a06fb73cd5 100644
--- a/web/apps/photobook/src/components/EditPage.tsx
+++ b/web/apps/photobook/src/components/EditPage.tsx
@@ -26,10 +26,8 @@ import React, {
} from "react";
import AddPageDialog from "./AddPageDialog";
import AddPhotosDialog from "./AddPhotosDialog";
-import BookBindingSelect from "./BookBindingSelect";
import BookHeader from "./BookHeader";
import EditorActions, { EditorPreviewButton } from "./EditorActions";
-import EmptyBookState from "./EmptyBookState";
import type { PageInsertPosition } from "./PageMenu";
import PageStrip from "./PageStrip";
import PrinterBlankPage from "./PrinterBlankPage";
@@ -413,7 +411,6 @@ export default function EditPage() {
}}
>
<BookHeader showBookControls={pages.length > 0}>
- <BookBindingSelect />
<EditorPreviewButton />
</BookHeader>
@@ -482,307 +479,293 @@ export default function EditPage() {
...EDITOR_SCROLLBAR_SX,
}}
>
- {pages.length === 0 ? (
- <EmptyBookState />
- ) : (
- containerWidth > 0 && (
- <Box
- sx={{
- display: "flex",
- flexDirection: "column",
- alignItems: "center",
- px: `${EDITOR_CANVAS_PADDING}px`,
- pt: 4,
- pb: {
- xs: "calc(144px + env(safe-area-inset-bottom))",
- sm: "calc(96px + env(safe-area-inset-bottom))",
- },
- gap: 3,
- }}
- >
- {spreads.map((spread, spreadIdx) => {
- const isVisible =
- visibleSpreads.has(spreadIdx) ||
- Math.abs(
- spreadIdx - currentSpreadRow,
- ) <= NEIGHBORHOOD_RADIUS;
- const leftIndex =
- typeof spread.left === "number"
- ? spread.left
- : null;
- const rightIndex =
- typeof spread.right === "number"
- ? spread.right
- : null;
- const lp =
- leftIndex !== null
- ? pages[leftIndex]
- : null;
- const rp =
- rightIndex !== null
- ? pages[rightIndex]
- : null;
-
- return (
- <Box
- key={spreadIdx}
- ref={spreadRefCallback(
- spreadIdx,
+ {containerWidth > 0 && (
+ <Box
+ sx={{
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ px: `${EDITOR_CANVAS_PADDING}px`,
+ pt: 4,
+ pb: {
+ xs: "calc(144px + env(safe-area-inset-bottom))",
+ sm: "calc(96px + env(safe-area-inset-bottom))",
+ },
+ gap: 3,
+ }}
+ >
+ {spreads.map((spread, spreadIdx) => {
+ const isVisible =
+ visibleSpreads.has(spreadIdx) ||
+ Math.abs(
+ spreadIdx - currentSpreadRow,
+ ) <= NEIGHBORHOOD_RADIUS;
+ const leftIndex =
+ typeof spread.left === "number"
+ ? spread.left
+ : null;
+ const rightIndex =
+ typeof spread.right === "number"
+ ? spread.right
+ : null;
+ const lp =
+ leftIndex !== null
+ ? pages[leftIndex]
+ : null;
+ const rp =
+ rightIndex !== null
+ ? pages[rightIndex]
+ : null;
+
+ return (
+ <Box
+ key={spreadIdx}
+ ref={spreadRefCallback(spreadIdx)}
+ data-spread-index={spreadIdx}
+ sx={{
+ display: "flex",
+ gap: `${PAGE_GAP}px`,
+ alignItems: "start",
+ width:
+ PICKER_WIDTH +
+ pageWidth * 2 +
+ PAGE_GAP +
+ PICKER_WIDTH,
+ justifyContent:
+ spread.left !== null
+ ? "flex-start"
+ : "flex-end",
+ minHeight: pageHeight,
+ }}
+ >
+ {isVisible &&
+ spread.left ===
+ "printer-blank" && (
+ <Box
+ sx={{
+ pl: `${PICKER_WIDTH}px`,
+ }}
+ >
+ <PrinterBlankPage
+ width={pageWidth}
+ height={pageHeight}
+ showLabel
+ />
+ </Box>
)}
- data-spread-index={spreadIdx}
- sx={{
- display: "flex",
- gap: `${PAGE_GAP}px`,
- alignItems: "start",
- width:
- PICKER_WIDTH +
- pageWidth * 2 +
- PAGE_GAP +
- PICKER_WIDTH,
- justifyContent:
- spread.left !== null
- ? "flex-start"
- : "flex-end",
- minHeight: pageHeight,
- }}
- >
- {isVisible &&
- spread.left ===
- "printer-blank" && (
- <Box
- sx={{
- pl: `${PICKER_WIDTH}px`,
- }}
- >
- <PrinterBlankPage
- width={
- pageWidth
- }
- height={
- pageHeight
- }
- showLabel
- />
- </Box>
- )}
- {isVisible && lp && (
- <SpreadPage
- page={lp}
- pageIndex={leftIndex!}
- pickerSide="left"
- pageWidth={pageWidth}
- pageHeight={pageHeight}
- totalPages={totalPages}
- selectedSlotId={
- selectedSlotId
- }
- selectedPageId={
- selectedPageId
- }
- selectedTextId={
- selectedTextId
- }
- editingTextId={
- editingTextId
- }
- onSlotClick={
- handleSlotClick
- }
- onTextClick={
- handleTextClick
- }
- onTextDblClick={
- handleTextDblClick
- }
- onTextUpdate={
- handleTextUpdate
- }
- onTextDelete={
- handleTextDelete
- }
- onTextEditEnd={
- handleTextEditEnd
- }
- onClearSelection={
- clearSelection
- }
- onInsertPage={
- handleInsertPage
- }
- onAddPhotos={
- handleAddPhotos
- }
- dragSourceInfo={
- photoDrag.dragSourceInfo
- }
- dragOverInfo={
- photoDrag.dragOverInfo
- }
- dragOverPageId={
- photoDrag.dragOverPageId
- }
- onPhotoDragStart={
- photoDrag.handleDragStart
- }
- onSlotDragOver={
- photoDrag.handleSlotDragOver
- }
- onPhotoDrop={
- photoDrag.handleDrop
- }
- onPhotoDragEnd={
- photoDrag.handleDragEnd
- }
- onPageDragOver={
- photoDrag.handlePageDragOver
- }
- onPageDrop={
- photoDrag.handlePageDrop
- }
- pageDragSource={
- pageDrag.pageDragSource
- }
- pageDragTarget={
- pageDrag.pageDragTarget
- }
- pageDragSourceRef={
- pageDrag.pageDragSourceRef
- }
- onPageDragStart={
- pageDrag.handlePageDragStart
- }
- onPageDragOverPage={
- pageDrag.handlePageDragOverPage
- }
- onPageDropOnPage={
- pageDrag.handlePageDropOnPage
- }
- onPageDragEndCleanup={
- pageDrag.handlePageDragEndCleanup
- }
- />
+ {isVisible && lp && (
+ <SpreadPage
+ page={lp}
+ pageIndex={leftIndex!}
+ pickerSide="left"
+ pageWidth={pageWidth}
+ pageHeight={pageHeight}
+ totalPages={totalPages}
+ selectedSlotId={
+ selectedSlotId
+ }
+ selectedPageId={
+ selectedPageId
+ }
+ selectedTextId={
+ selectedTextId
+ }
+ editingTextId={
+ editingTextId
+ }
+ onSlotClick={
+ handleSlotClick
+ }
+ onTextClick={
+ handleTextClick
+ }
+ onTextDblClick={
+ handleTextDblClick
+ }
+ onTextUpdate={
+ handleTextUpdate
+ }
+ onTextDelete={
+ handleTextDelete
+ }
+ onTextEditEnd={
+ handleTextEditEnd
+ }
+ onClearSelection={
+ clearSelection
+ }
+ onInsertPage={
+ handleInsertPage
+ }
+ onAddPhotos={
+ handleAddPhotos
+ }
+ dragSourceInfo={
+ photoDrag.dragSourceInfo
+ }
+ dragOverInfo={
+ photoDrag.dragOverInfo
+ }
+ dragOverPageId={
+ photoDrag.dragOverPageId
+ }
+ onPhotoDragStart={
+ photoDrag.handleDragStart
+ }
+ onSlotDragOver={
+ photoDrag.handleSlotDragOver
+ }
+ onPhotoDrop={
+ photoDrag.handleDrop
+ }
+ onPhotoDragEnd={
+ photoDrag.handleDragEnd
+ }
+ onPageDragOver={
+ photoDrag.handlePageDragOver
+ }
+ onPageDrop={
+ photoDrag.handlePageDrop
+ }
+ pageDragSource={
+ pageDrag.pageDragSource
+ }
+ pageDragTarget={
+ pageDrag.pageDragTarget
+ }
+ pageDragSourceRef={
+ pageDrag.pageDragSourceRef
+ }
+ onPageDragStart={
+ pageDrag.handlePageDragStart
+ }
+ onPageDragOverPage={
+ pageDrag.handlePageDragOverPage
+ }
+ onPageDropOnPage={
+ pageDrag.handlePageDropOnPage
+ }
+ onPageDragEndCleanup={
+ pageDrag.handlePageDragEndCleanup
+ }
+ />
+ )}
+ {isVisible && rp && (
+ <SpreadPage
+ page={rp}
+ pageIndex={rightIndex!}
+ pickerSide="right"
+ pageWidth={pageWidth}
+ pageHeight={pageHeight}
+ totalPages={totalPages}
+ selectedSlotId={
+ selectedSlotId
+ }
+ selectedPageId={
+ selectedPageId
+ }
+ selectedTextId={
+ selectedTextId
+ }
+ editingTextId={
+ editingTextId
+ }
+ onSlotClick={
+ handleSlotClick
+ }
+ onTextClick={
+ handleTextClick
+ }
+ onTextDblClick={
+ handleTextDblClick
+ }
+ onTextUpdate={
+ handleTextUpdate
+ }
+ onTextDelete={
+ handleTextDelete
+ }
+ onTextEditEnd={
+ handleTextEditEnd
+ }
+ onClearSelection={
+ clearSelection
+ }
+ onInsertPage={
+ handleInsertPage
+ }
+ onAddPhotos={
+ handleAddPhotos
+ }
+ dragSourceInfo={
+ photoDrag.dragSourceInfo
+ }
+ dragOverInfo={
+ photoDrag.dragOverInfo
+ }
+ dragOverPageId={
+ photoDrag.dragOverPageId
+ }
+ onPhotoDragStart={
+ photoDrag.handleDragStart
+ }
+ onSlotDragOver={
+ photoDrag.handleSlotDragOver
+ }
+ onPhotoDrop={
+ photoDrag.handleDrop
+ }
+ onPhotoDragEnd={
+ photoDrag.handleDragEnd
+ }
+ onPageDragOver={
+ photoDrag.handlePageDragOver
+ }
+ onPageDrop={
+ photoDrag.handlePageDrop
+ }
+ pageDragSource={
+ pageDrag.pageDragSource
+ }
+ pageDragTarget={
+ pageDrag.pageDragTarget
+ }
+ pageDragSourceRef={
+ pageDrag.pageDragSourceRef
+ }
+ onPageDragStart={
+ pageDrag.handlePageDragStart
+ }
+ onPageDragOverPage={
+ pageDrag.handlePageDragOverPage
+ }
+ onPageDropOnPage={
+ pageDrag.handlePageDropOnPage
+ }
+ onPageDragEndCleanup={
+ pageDrag.handlePageDragEndCleanup
+ }
+ />
+ )}
+ {isVisible &&
+ spread.right ===
+ "printer-blank" && (
+ <Box
+ sx={{
+ pr: `${PICKER_WIDTH}px`,
+ }}
+ >
+ <PrinterBlankPage
+ width={pageWidth}
+ height={pageHeight}
+ showLabel
+ />
+ </Box>
)}
- {isVisible && rp && (
- <SpreadPage
- page={rp}
- pageIndex={rightIndex!}
- pickerSide="right"
- pageWidth={pageWidth}
- pageHeight={pageHeight}
- totalPages={totalPages}
- selectedSlotId={
- selectedSlotId
- }
- selectedPageId={
- selectedPageId
- }
- selectedTextId={
- selectedTextId
- }
- editingTextId={
- editingTextId
- }
- onSlotClick={
- handleSlotClick
- }
- onTextClick={
- handleTextClick
- }
- onTextDblClick={
- handleTextDblClick
- }
- onTextUpdate={
- handleTextUpdate
- }
- onTextDelete={
- handleTextDelete
- }
- onTextEditEnd={
- handleTextEditEnd
- }
- onClearSelection={
- clearSelection
- }
- onInsertPage={
- handleInsertPage
- }
- onAddPhotos={
- handleAddPhotos
- }
- dragSourceInfo={
- photoDrag.dragSourceInfo
- }
- dragOverInfo={
- photoDrag.dragOverInfo
- }
- dragOverPageId={
- photoDrag.dragOverPageId
- }
- onPhotoDragStart={
- photoDrag.handleDragStart
- }
- onSlotDragOver={
- photoDrag.handleSlotDragOver
- }
- onPhotoDrop={
- photoDrag.handleDrop
- }
- onPhotoDragEnd={
- photoDrag.handleDragEnd
- }
- onPageDragOver={
- photoDrag.handlePageDragOver
- }
- onPageDrop={
- photoDrag.handlePageDrop
- }
- pageDragSource={
- pageDrag.pageDragSource
- }
- pageDragTarget={
- pageDrag.pageDragTarget
- }
- pageDragSourceRef={
- pageDrag.pageDragSourceRef
- }
- onPageDragStart={
- pageDrag.handlePageDragStart
- }
- onPageDragOverPage={
- pageDrag.handlePageDragOverPage
- }
- onPageDropOnPage={
- pageDrag.handlePageDropOnPage
- }
- onPageDragEndCleanup={
- pageDrag.handlePageDragEndCleanup
- }
- />
- )}
- {isVisible &&
- spread.right ===
- "printer-blank" && (
- <Box
- sx={{
- pr: `${PICKER_WIDTH}px`,
- }}
- >
- <PrinterBlankPage
- width={
- pageWidth
- }
- height={
- pageHeight
- }
- showLabel
- />
- </Box>
- )}
- </Box>
- );
- })}
- </Box>
- )
+ </Box>
+ );
+ })}
+ </Box>
)}
</Box>
</Box>
diff --git a/web/apps/photobook/src/components/EmptyBookState.tsx b/web/apps/photobook/src/components/EmptyBookState.tsx
deleted file mode 100644
index fda730f5ca..0000000000
--- a/web/apps/photobook/src/components/EmptyBookState.tsx
+++ /dev/null
@@ -1,269 +0,0 @@
-import { usePhotoImport } from "@/hooks/usePhotoImport";
-import {
- accentGreen,
- editorButtonSx,
- editorToolbarButtonSx,
-} from "@/theme/buttons";
-import { uiColors } from "@/theme/colors";
-import {
- Alert,
- Box,
- Button,
- InputBase,
- LinearProgress,
- Typography,
-} from "@mui/material";
-import { AddPhotosIcon, LinkIcon } from "./icons";
-
-export default function EmptyBookState() {
- const {
- fileInputRef,
- dragOver,
- enteUrl,
- setEnteUrl,
- enteError,
- importError,
- processingPhotos,
- processingProgress,
- processingMessage,
- handleImportEnte,
- handleFiles,
- handleDrop,
- handleDragOver,
- handleDragLeave,
- } = usePhotoImport();
-
- return (
- <Box
- onDrop={processingPhotos ? undefined : handleDrop}
- onDragOver={processingPhotos ? undefined : handleDragOver}
- onDragLeave={(event) => {
- if (
- !event.currentTarget.contains(
- event.relatedTarget as Node | null,
- )
- )
- handleDragLeave();
- }}
- sx={{
- flex: 1,
- minHeight: "min-content",
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- px: 2,
- py: 5,
- }}
- >
- <Box sx={{ width: "100%", maxWidth: 480 }}>
- {processingPhotos ? (
- <Box
- role="status"
- aria-live="polite"
- sx={{ py: 5, textAlign: "center" }}
- >
- <Typography
- sx={{ fontSize: 18, fontWeight: 600, mb: 3 }}
- >
- {processingMessage}
- </Typography>
- <LinearProgress
- variant="determinate"
- value={processingProgress}
- aria-label="Import progress"
- sx={{
- height: 5,
- borderRadius: 3,
- bgcolor: uiColors.control,
- "& .MuiLinearProgress-bar": { borderRadius: 3 },
- }}
- />
- <Typography
- sx={{ fontSize: 13, color: uiColors.muted, mt: 2 }}
- >
- {processingProgress}%
- </Typography>
- </Box>
- ) : (
- <>
- <Typography
- component="h1"
- sx={{
- fontSize: { xs: 28, sm: 32 },
- lineHeight: 1.25,
- fontWeight: 600,
- letterSpacing: "-0.8px",
- mb: 4,
- textAlign: "center",
- }}
- >
- Create your photobook
- </Typography>
- <Box
- component="form"
- onSubmit={(event) => {
- event.preventDefault();
- if (enteUrl.trim()) void handleImportEnte();
- }}
- >
- <Box
- sx={{
- display: "flex",
- alignItems: "center",
- gap: { xs: 1, sm: 1.5 },
- p: "6px",
- pl: { xs: "12px", sm: "18px" },
- borderRadius: "20px",
- border: `1px solid ${enteError ? uiColors.danger : "#414141"}`,
- bgcolor: "#242424",
- transition:
- "border-color 120ms ease, background-color 120ms ease",
- "&:hover": { borderColor: "#626262" },
- "&:focus-within": {
- borderColor: accentGreen,
- },
- }}
- >
- <LinkIcon
- aria-hidden="true"
- sx={{
- fontSize: 22,
- color: uiColors.muted,
- flexShrink: 0,
- }}
- />
- <InputBase
- id="empty-book-album-url"
- placeholder="Paste an Ente Photos album link"
- value={enteUrl}
- onChange={(event) =>
- setEnteUrl(event.target.value)
- }
- error={Boolean(enteError)}
- autoComplete="off"
- inputProps={{
- "aria-label": "Ente Photos album link",
- inputMode: "url",
- spellCheck: false,
- "aria-describedby": enteError
- ? "empty-book-import-error"
- : undefined,
- }}
- sx={{
- flex: 1,
- minWidth: 0,
- fontSize: { xs: 14, sm: 15 },
- "& input": { py: 1.5 },
- "& input::placeholder": {
- color: uiColors.muted,
- opacity: 1,
- },
- }}
- />
- <Button
- type="submit"
- variant="contained"
- disabled={!enteUrl.trim()}
- sx={{
- ...editorButtonSx,
- height: 46,
- px: { xs: 2, sm: 3 },
- fontWeight: 700,
- flexShrink: 0,
- borderRadius: "13px",
- }}
- >
- Import
- </Button>
- </Box>
- {enteError && (
- <Alert
- id="empty-book-import-error"
- severity="error"
- sx={{ mt: 2, borderRadius: "14px" }}
- >
- {enteError}
- </Alert>
- )}
- </Box>
- <Typography
- sx={{
- my: 2.5,
- fontSize: 12,
- lineHeight: "18px",
- color: "#808080",
- textAlign: "center",
- }}
- >
- or
- </Typography>
- <Box
- role="group"
- aria-label="Add or drop photos"
- sx={{
- textAlign: "center",
- p: 3,
- borderRadius: "20px",
- minHeight: 300,
- display: "flex",
- flexDirection: "column",
- alignItems: "center",
- justifyContent: "center",
- border: `1px dashed ${dragOver ? accentGreen : "#484848"}`,
- bgcolor: dragOver ? "#1B2A1D" : "transparent",
- transition:
- "border-color 120ms ease, background-color 120ms ease",
- }}
- >
- <Button
- startIcon={
- <AddPhotosIcon sx={{ fontSize: 20 }} />
- }
- onClick={() => fileInputRef.current?.click()}
- sx={{
- ...editorToolbarButtonSx,
- borderRadius: "14px",
- px: 2,
- }}
- >
- Add photos
- </Button>
- <Typography
- sx={{
- mt: 1.5,
- fontSize: 12,
- lineHeight: "18px",
- color: dragOver ? uiColors.text : "#898989",
- }}
- >
- {dragOver
- ? "Drop photos here"
- : "or drop photos here"}
- </Typography>
- </Box>
- {importError && (
- <Alert
- severity="error"
- sx={{ mt: 2, borderRadius: "14px" }}
- >
- {importError}
- </Alert>
- )}
- </>
- )}
- </Box>
- <input
- ref={fileInputRef}
- type="file"
- accept="image/jpeg,image/png,image/webp,image/heic,image/heif,.heic,.heif"
- multiple
- style={{ display: "none" }}
- onChange={(event) => {
- if (event.currentTarget.files)
- void handleFiles(event.currentTarget.files);
- event.currentTarget.value = "";
- }}
- />
- </Box>
- );
-}
diff --git a/web/apps/photobook/src/components/MobileTextDialog.tsx b/web/apps/photobook/src/components/MobileTextDialog.tsx
new file mode 100644
index 0000000000..d3a4f3df5a
--- /dev/null
+++ b/web/apps/photobook/src/components/MobileTextDialog.tsx
@@ -0,0 +1,107 @@
+import {
+ Button,
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogTitle,
+ TextField,
+} from "@mui/material";
+import { useEffect, useState } from "react";
+
+export default function MobileTextDialog({
+ title,
+ value,
+ multiline = false,
+ onSave,
+ onClose,
+}: {
+ title: string;
+ value: string;
+ multiline?: boolean;
+ onSave: (value: string) => void;
+ onClose: () => void;
+}) {
+ const [draft, setDraft] = useState(value);
+ const [viewport, setViewport] = useState<{ height: number; top: number }>();
+ useEffect(() => {
+ const visualViewport = window.visualViewport;
+ if (!visualViewport) return;
+ const measure = () =>
+ setViewport({
+ height: visualViewport.height,
+ top: visualViewport.offsetTop,
+ });
+ measure();
+ visualViewport.addEventListener("resize", measure);
+ visualViewport.addEventListener("scroll", measure);
+ return () => {
+ visualViewport.removeEventListener("resize", measure);
+ visualViewport.removeEventListener("scroll", measure);
+ };
+ }, []);
+ const save = () => {
+ onSave(draft);
+ onClose();
+ };
+ return (
+ <Dialog
+ open
+ onClose={onClose}
+ fullWidth
+ maxWidth="xs"
+ aria-labelledby="mobile-text-title"
+ sx={{
+ "& .MuiDialog-container": {
+ alignItems: "flex-start",
+ height: viewport?.height,
+ transform: viewport
+ ? `translateY(${viewport.top}px)`
+ : undefined,
+ },
+ }}
+ slotProps={{
+ paper: {
+ sx: {
+ m: 2,
+ mt: "max(16px, env(safe-area-inset-top))",
+ width: "calc(100% - 32px)",
+ maxHeight: "calc(100% - 32px)",
+ },
+ },
+ }}
+ >
+ <DialogTitle id="mobile-text-title">{title}</DialogTitle>
+ <DialogContent>
+ <TextField
+ autoFocus
+ fullWidth
+ multiline={multiline}
+ minRows={multiline ? 3 : undefined}
+ maxRows={6}
+ label={title}
+ value={draft}
+ onChange={(event) => setDraft(event.target.value)}
+ onKeyDown={(event) => {
+ if (
+ event.key === "Enter" &&
+ !multiline &&
+ !event.nativeEvent.isComposing
+ ) {
+ event.preventDefault();
+ save();
+ }
+ }}
+ sx={{ mt: 1, "& input, & textarea": { fontSize: 16 } }}
+ />
+ </DialogContent>
+ <DialogActions sx={{ p: 2, "& button": { minHeight: 44 } }}>
+ <Button variant="text" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button variant="contained" onClick={save}>
+ Done
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+}
diff --git a/web/apps/photobook/src/components/PageCanvas.tsx b/web/apps/photobook/src/components/PageCanvas.tsx
index 58f994b83b..a94e3bf935 100644
--- a/web/apps/photobook/src/components/PageCanvas.tsx
+++ b/web/apps/photobook/src/components/PageCanvas.tsx
@@ -6,6 +6,7 @@ import {
} from "@/lib/imageCache";
import {
CAPTION_FONT_WEIGHT,
+ CAPTION_TEXT_COLOR,
CENTER_TEXT_FONT_WEIGHT,
getBrandingLayout,
getCaptionLayout,
@@ -305,6 +306,7 @@ function CaptionText({
lineHeight = TEXT_LINE_HEIGHT,
fontFamily = getInterFont(),
fontWeight = CAPTION_FONT_WEIGHT,
+ color = "#2a2a2a",
}: {
text: string;
layout: CaptionLayout | null;
@@ -314,6 +316,7 @@ function CaptionText({
lineHeight?: number;
fontFamily?: string;
fontWeight?: number;
+ color?: string;
}) {
if (isEditing) return null;
if (!text) return null;
@@ -335,7 +338,7 @@ function CaptionText({
wrap="none"
fontFamily={fontFamily}
fontStyle={String(fontWeight)}
- fill="#2a2a2a"
+ fill={color}
align="center"
verticalAlign="middle"
/>
@@ -376,6 +379,8 @@ export default function PageCanvas({
const topCaption = getCaptionLayout(page, "top", isFrontCover);
const bottomCaption = getCaptionLayout(page, "bottom", isFrontCover);
const centerText = getCenterTextLayout(page);
+ const captionColor =
+ isFrontCover || isBackCover ? "#2a2a2a" : CAPTION_TEXT_COLOR;
return (
<>
@@ -420,6 +425,7 @@ export default function PageCanvas({
pageWidth={pageWidth}
pageHeight={pageHeight}
isEditing={editingCaption === "top"}
+ color={captionColor}
fontFamily={isFrontCover ? getOutfitFont() : getInterFont()}
fontWeight={
isFrontCover
@@ -438,6 +444,7 @@ export default function PageCanvas({
pageWidth={pageWidth}
pageHeight={pageHeight}
isEditing={editingCaption === "bottom"}
+ color={captionColor}
fontFamily={
isFrontCover ? getOutfitFont() : getInterFont()
}
diff --git a/web/apps/photobook/src/components/PageMenu.tsx b/web/apps/photobook/src/components/PageMenu.tsx
index 69c914a78a..be122bd217 100644
--- a/web/apps/photobook/src/components/PageMenu.tsx
+++ b/web/apps/photobook/src/components/PageMenu.tsx
@@ -1,5 +1,6 @@
import { MAX_PAGE_PHOTOS } from "@/lib/photoPlacement";
-import { pageMenuColors, popupShadow, uiColors } from "@/theme/colors";
+import { pageMenuColors, uiColors } from "@/theme/colors";
+import { pageMenuItemSx, pageMenuPaperSx } from "@/theme/menus";
import { IconButton, Menu, MenuItem } from "@mui/material";
import { useState } from "react";
import {
@@ -13,28 +14,6 @@ import RequiredPageDialog from "./RequiredPageDialog";
export type PageInsertPosition = "before" | "after";
-const menuItemSx = {
- alignItems: "center",
- borderRadius: "10px",
- color: pageMenuColors.text,
- display: "flex",
- gap: "8px",
- minHeight: 36,
- px: "9px",
- py: "4px",
- fontSize: 13,
- fontWeight: 500,
- lineHeight: "18px",
- whiteSpace: "nowrap",
- transition: "background-color 120ms ease, color 120ms ease",
- "& .MuiSvgIcon-root": { color: pageMenuColors.icon },
- "&:hover, &.Mui-focusVisible": {
- bgcolor: pageMenuColors.hover,
- "& .MuiSvgIcon-root": { color: pageMenuColors.text },
- },
- "&:active": { bgcolor: pageMenuColors.active },
-};
-
interface PageMenuProps {
pageId: string;
pageIndex: number;
@@ -124,18 +103,7 @@ export default function PageMenu({
anchorOrigin={{ vertical: "bottom", horizontal: side }}
transformOrigin={{ vertical: "top", horizontal: side }}
slotProps={{
- paper: {
- sx: {
- bgcolor: pageMenuColors.background,
- backgroundImage: "none",
- borderRadius: "14px",
- boxShadow: popupShadow,
- mt: "6px",
- minWidth: 0,
- p: "4px",
- width: "max-content",
- },
- },
+ paper: { sx: pageMenuPaperSx },
list: { "aria-labelledby": buttonId, sx: { p: 0 } },
}}
>
@@ -144,7 +112,7 @@ export default function PageMenu({
dense
disableRipple
onClick={() => runAction(onAddPhotos)}
- sx={menuItemSx}
+ sx={pageMenuItemSx}
>
<EditPhotoIcon sx={{ fontSize: 18, flexShrink: 0 }} />
Change cover image
@@ -155,7 +123,7 @@ export default function PageMenu({
dense
disableRipple
onClick={() => runAction(onAddPhotos)}
- sx={menuItemSx}
+ sx={pageMenuItemSx}
>
<AddPhotosIcon sx={{ fontSize: 18, flexShrink: 0 }} />
Add photos
@@ -166,7 +134,7 @@ export default function PageMenu({
dense
disableRipple
onClick={() => runAction(() => onInsert("before"))}
- sx={menuItemSx}
+ sx={pageMenuItemSx}
>
<AddPageIcon sx={{ fontSize: 18, flexShrink: 0 }} />
Insert page before
@@ -177,7 +145,7 @@ export default function PageMenu({
dense
disableRipple
onClick={() => runAction(() => onInsert("after"))}
- sx={menuItemSx}
+ sx={pageMenuItemSx}
>
<AddPageIcon sx={{ fontSize: 18, flexShrink: 0 }} />
Insert page after
@@ -195,7 +163,7 @@ export default function PageMenu({
})
}
sx={{
- ...menuItemSx,
+ ...pageMenuItemSx,
color: pageMenuColors.danger,
"& .MuiSvgIcon-root": {
color: pageMenuColors.danger,
diff --git a/web/apps/photobook/src/components/ResetBookButton.tsx b/web/apps/photobook/src/components/ResetBookButton.tsx
index cd5b9d3562..5e8caae92b 100644
--- a/web/apps/photobook/src/components/ResetBookButton.tsx
+++ b/web/apps/photobook/src/components/ResetBookButton.tsx
@@ -14,7 +14,11 @@ import { Box, Button, Dialog, IconButton, Typography } from "@mui/material";
import { useState } from "react";
import { CloseIcon, DeleteIcon } from "./icons";
-export default function ResetBookButton() {
+export default function ResetBookButton({
+ disabled = false,
+}: {
+ disabled?: boolean;
+}) {
const { startOver, processingPhotos, book } = useBook();
const [open, setOpen] = useState(false);
const [resetting, setResetting] = useState(false);
@@ -45,7 +49,10 @@ export default function ResetBookButton() {
setOpen(true);
}}
disabled={
- processingPhotos || resetting || book.pages.length === 0
+ disabled ||
+ processingPhotos ||
+ resetting ||
+ book.pages.length === 0
}
sx={{
...editorButtonSx,
diff --git a/web/apps/photobook/src/components/ResultsPage.tsx b/web/apps/photobook/src/components/ResultsPage.tsx
index a8f3fda2b0..ef99118048 100644
--- a/web/apps/photobook/src/components/ResultsPage.tsx
+++ b/web/apps/photobook/src/components/ResultsPage.tsx
@@ -20,20 +20,23 @@ import {
LinearProgress,
Snackbar,
Typography,
+ useMediaQuery,
} from "@mui/material";
import { saveAsFileAndRevokeObjectURL } from "ente-base/utils/web";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import BookBindingSelect from "./BookBindingSelect";
import BookHeader from "./BookHeader";
import BookViewer, { type BookViewerHandle } from "./BookViewer";
import {
EDITOR_PANEL_BOTTOM_INSET,
EDITOR_PANEL_INSET,
EDITOR_PANEL_SX,
+ MOBILE_QUERY,
} from "./editorLayout";
import { DownloadIcon, EditIcon } from "./icons";
+import ResetBookButton from "./ResetBookButton";
export default function ResultsPage() {
+ const mobile = useMediaQuery(MOBILE_QUERY, { noSsr: true });
const { book, photos, setAppView, waitForEnteOriginals } = useBook();
const viewerRef = useRef<BookViewerHandle>(null);
const [spreadIndex, setSpreadIndex] = useState(0);
@@ -128,10 +131,7 @@ export default function ResultsPage() {
return;
}
- const initiallyBlocked = getBlockedEntePhotos();
- const pendingIds = initiallyBlocked
- .filter((photo) => photo.originalStatus === "pending")
- .map((photo) => photo.id);
+ const pendingIds = getBlockedEntePhotos().map((photo) => photo.id);
downloadInProgress.current = true;
setExportError(null);
@@ -142,27 +142,23 @@ export default function ResultsPage() {
try {
if (pendingIds.length > 0) {
setOriginalsProgress({ done: 0, total: pendingIds.length });
- await waitForEnteOriginals(pendingIds, (done, total) => {
- setOriginalsProgress({ done, total });
- setExportProgress(
- total
- ? Math.round((done / total) * preparationShare)
- : 0,
- );
- });
- }
-
- const remainingBlocked = getBlockedEntePhotos();
- if (remainingBlocked.length > 0) {
- const failedCount = remainingBlocked.filter(
- (photo) => photo.originalStatus === "failed",
- ).length;
- setExportError(
- failedCount > 0
- ? "Some Ente photos failed to prepare. Re-import the album before exporting."
- : "Ente originals are still being prepared. Please wait a moment and try again.",
+ const ready = await waitForEnteOriginals(
+ pendingIds,
+ (done, total) => {
+ setOriginalsProgress({ done, total });
+ setExportProgress(
+ total
+ ? Math.round((done / total) * preparationShare)
+ : 0,
+ );
+ },
);
- return;
+ if (!ready) {
+ setExportError(
+ "Some photos couldn't download. Click Download to try again. Your edits are unchanged.",
+ );
+ return;
+ }
}
setDownloadPhase("exporting");
@@ -212,28 +208,36 @@ export default function ResultsPage() {
bgcolor: uiColors.background,
}}
>
- <BookHeader>
- <BookBindingSelect disabled={busy} />
- <Button
- aria-label="Edit"
- startIcon={<EditIcon />}
- onClick={() => setAppView("edit")}
- disabled={busy}
- sx={{
- ...headerButtonSx,
- color: toolbarColors.text,
- bgcolor: toolbarColors.control,
- "&:hover": { bgcolor: toolbarColors.hover },
- "&:active": { bgcolor: toolbarColors.active },
- }}
- >
- <Box
- component="span"
- sx={{ display: { xs: "none", sm: "inline" } }}
+ <BookHeader titleDisabled={busy}>
+ {mobile ? (
+ <ResetBookButton disabled={busy} />
+ ) : (
+ <Button
+ aria-label="Edit"
+ startIcon={<EditIcon />}
+ onClick={() => setAppView("edit")}
+ disabled={busy}
+ sx={{
+ ...headerButtonSx,
+ color: toolbarColors.text,
+ bgcolor: toolbarColors.control,
+ "&:hover": { bgcolor: toolbarColors.hover },
+ "&:active": { bgcolor: toolbarColors.active },
+ "&.Mui-disabled": {
+ color: toolbarColors.disabled,
+ bgcolor: toolbarColors.control,
+ opacity: 1,
+ },
+ }}
>
- Edit
- </Box>
- </Button>
+ <Box
+ component="span"
+ sx={{ display: { xs: "none", sm: "inline" } }}
+ >
+ Edit
+ </Box>
+ </Button>
+ )}
<Button
id="download-button"
variant="contained"
@@ -343,6 +347,11 @@ export default function ResultsPage() {
borderRadius: 3,
bgcolor: uiColors.surface,
minWidth: 360,
+ "@media (max-width: 959px)": {
+ minWidth: 0,
+ width: 360,
+ maxWidth: "calc(100% - 32px)",
+ },
boxShadow: popupShadow,
},
},
diff --git a/web/apps/photobook/src/components/SpreadPage.tsx b/web/apps/photobook/src/components/SpreadPage.tsx
index f8d543b437..ccbc90d053 100644
--- a/web/apps/photobook/src/components/SpreadPage.tsx
+++ b/web/apps/photobook/src/components/SpreadPage.tsx
@@ -3,6 +3,7 @@ import type { DragInfo } from "@/hooks/usePhotoDrag";
import { isRequiredBlankPage } from "@/lib/bookPages";
import {
CAPTION_FONT_WEIGHT,
+ CAPTION_TEXT_COLOR,
CENTER_TEXT_FONT_WEIGHT,
getCaptionLayout,
getCenterTextLayout,
@@ -1010,7 +1011,10 @@ export default function SpreadPage({
? CENTER_TEXT_FONT_WEIGHT
: CAPTION_FONT_WEIGHT,
lineHeight: TEXT_LINE_HEIGHT,
- color: "#2a2a2a",
+ color:
+ isFrontCover || isBackCover
+ ? "#2a2a2a"
+ : CAPTION_TEXT_COLOR,
textAlign: "center",
boxSizing: "border-box",
};
@@ -1055,7 +1059,11 @@ export default function SpreadPage({
>
<span
style={{
- color: page[key] ? "#2a2a2a" : "#aaa",
+ color:
+ page[key] ||
+ (!isFrontCover && !isBackCover)
+ ? "inherit"
+ : "#aaa",
pointerEvents: "none",
}}
>
diff --git a/web/apps/photobook/src/components/StartPage.tsx b/web/apps/photobook/src/components/StartPage.tsx
index 70b2276f72..796a50c324 100644
--- a/web/apps/photobook/src/components/StartPage.tsx
+++ b/web/apps/photobook/src/components/StartPage.tsx
@@ -1,9 +1,16 @@
import { useBook } from "@/context/book";
import { usePhotoImport } from "@/hooks/usePhotoImport";
-import { Alert, Box, Button, TextField, Typography } from "@mui/material";
+import {
+ Alert,
+ Box,
+ Button,
+ InputAdornment,
+ TextField,
+ Typography,
+} from "@mui/material";
import { useRouter } from "next/router";
import { useEffect } from "react";
-import NavBar from "./NavBar";
+import { AddPhotosIcon } from "./icons";
export default function StartPage() {
const router = useRouter();
@@ -30,18 +37,17 @@ export default function StartPage() {
return (
<Box
sx={{
- minHeight: "100vh",
+ minHeight: "100svh",
bgcolor: "#fff",
- color: "#1A1C1D",
+ color: "#003D12",
display: "flex",
flexDirection: "column",
- position: "relative",
- overflow: "hidden",
+ p: { xs: 1, sm: 1.5 },
}}
>
- <NavBar />
<Box
component="main"
+ className="green-bg"
onDrop={busy ? undefined : handleDrop}
onDragOver={busy ? undefined : handleDragOver}
onDragLeave={handleDragLeave}
@@ -50,10 +56,16 @@ export default function StartPage() {
display: "flex",
flexDirection: "column",
alignItems: "center",
+ justifyContent: "center",
position: "relative",
- px: 3,
- pt: { xs: "128px", sm: "170px" },
- pb: 8,
+ overflow: "hidden",
+ borderRadius: { xs: "20px", sm: "28px" },
+ px: { xs: 2.5, sm: 4 },
+ pt: { xs: 3, sm: "clamp(24px, 4vh, 48px)" },
+ pb: {
+ xs: "max(20px, env(safe-area-inset-bottom))",
+ sm: "clamp(24px, 4vh, 48px)",
+ },
}}
>
{dragOver && (
@@ -62,9 +74,9 @@ export default function StartPage() {
position: "absolute",
inset: 0,
zIndex: 30,
- bgcolor: "rgba(8,194,37,0.08)",
- border: "3px dashed #08C225",
- borderRadius: 2,
+ bgcolor: "rgba(0,61,18,0.9)",
+ border: "3px dashed #FFF",
+ borderRadius: "inherit",
display: "grid",
placeItems: "center",
pointerEvents: "none",
@@ -74,7 +86,7 @@ export default function StartPage() {
sx={{
fontSize: "1.5rem",
fontWeight: 700,
- color: "#08C225",
+ color: "#FFF",
}}
>
Drop your photos here
@@ -86,127 +98,117 @@ export default function StartPage() {
position: "relative",
zIndex: 10,
display: "flex",
+ flex: { xs: 1, sm: "initial" },
flexDirection: "column",
alignItems: "center",
textAlign: "center",
- maxWidth: 1100,
+ maxWidth: 660,
width: "100%",
}}
>
- <Typography
- component="h1"
- sx={{
- fontFamily: "var(--font-inter), sans-serif",
- fontSize: { xs: "2.5rem", md: "4rem" },
- fontWeight: 800,
- letterSpacing: "-0.02em",
- mb: 2,
- lineHeight: 1.1,
- color: "#1A1C1D",
- }}
- >
- Your memories deserve a book
- </Typography>
- <Typography
- sx={{
- fontFamily: "var(--font-inter), sans-serif",
- fontSize: "1.15rem",
- color: "#666",
- maxWidth: 560,
- lineHeight: 1.7,
- mb: 6,
- }}
- >
- Drop in your photos and get a print-ready photobook.
- <br />
- Beautifully arranged, completely private, and free.
- </Typography>
<Box
sx={{
- mb: 8,
- position: "relative",
- "& .card": { transition: "transform 0.5s ease" },
- "&:hover .card": {
- transform: "rotate(0deg) !important",
- },
+ display: "flex",
+ flex: { xs: 1, sm: "initial" },
+ flexDirection: "column",
+ alignItems: "center",
+ justifyContent: "center",
+ width: "100%",
+ pb: { xs: 4, sm: 5 },
+ "@media (max-width: 599px) and (max-height: 640px)":
+ { pb: 3, "& > img": { width: 140, mb: 2 } },
}}
>
<Box
- className="card"
component="img"
- src="/hero-photo.jpg"
- alt="A photobook page with photos from Delhi"
+ src="/photobook-duck.png"
+ alt="A happy duck reading a photobook"
+ width={430}
+ height={468}
draggable={false}
sx={{
- width: { xs: 260, md: 380 },
+ display: "block",
+ mb: { xs: 3, sm: 4 },
+ width: {
+ xs: "clamp(160px, 28vh, 220px)",
+ sm: "clamp(180px, 27vh, 300px)",
+ },
maxWidth: "100%",
height: "auto",
- borderRadius: 2,
- boxShadow:
- "0px 16px 40px rgba(0,0,0,0.15), 0px 4px 12px rgba(0,0,0,0.08)",
- transform: "rotate(-3deg)",
- position: "relative",
- zIndex: 20,
userSelect: "none",
pointerEvents: "none",
}}
/>
+ <Typography
+ component="h1"
+ sx={{
+ fontFamily: "var(--font-outfit), sans-serif",
+ fontSize: {
+ xs: "clamp(2rem, 10vw, 2.5rem)",
+ sm: "clamp(2.5rem, 6vh, 3.5rem)",
+ },
+ fontWeight: 800,
+ letterSpacing: "-0.02em",
+ mb: { xs: 1.5, sm: 2 },
+ lineHeight: 1.1,
+ color: "#FFF",
+ }}
+ >
+ Your memories{" "}
+ <Box
+ component="span"
+ sx={{
+ display: "block",
+ fontFamily: '"Gochi Hand", cursive',
+ fontSize: "1.15em",
+ fontWeight: 400,
+ letterSpacing: "-0.025em",
+ }}
+ >
+ deserve a book
+ </Box>
+ </Typography>
+ <Typography
+ sx={{
+ fontFamily: "var(--font-outfit), sans-serif",
+ fontSize: { xs: "0.95rem", sm: "1.125rem" },
+ fontWeight: 500,
+ color: "rgba(0,61,18,0.65)",
+ maxWidth: { xs: 560, md: 480 },
+ lineHeight: 1.5,
+ }}
+ >
+ Turn the photos you love into a beautifully arranged
+ photobook, ready to print and keep for years to
+ come.
+ </Typography>
</Box>
- <Button
- variant="contained"
- size="large"
- disabled={busy}
- onClick={() => fileInputRef.current?.click()}
- sx={{
- bgcolor: "#08C225",
- fontFamily: "var(--font-inter), sans-serif",
- fontSize: "1.15rem",
- fontWeight: 700,
- px: 6,
- py: 2,
- boxShadow: "none",
- "&:hover": {
- transform: "scale(1.02)",
- bgcolor: "#07AE22",
- },
- "&:active": { transform: "scale(0.95)" },
- transition:
- "transform 0.3s ease, background-color 0.3s ease",
- }}
- >
- Add photos
- </Button>
- {importError && (
- <Alert severity="error" sx={{ mt: 2, maxWidth: 480 }}>
- {importError}
- </Alert>
- )}
<Box
- component="form"
- onSubmit={(event) => {
- event.preventDefault();
- if (!busy && enteUrl.trim())
- void handleImportEnte();
+ sx={{
+ display: "grid",
+ gridTemplateColumns: "minmax(0, 1fr)",
+ alignItems: "start",
+ gap: 2,
+ width: "100%",
+ maxWidth: { xs: "100%", sm: 370 },
+ mt: { xs: "auto", sm: 0 },
}}
- sx={{ mt: 3, mb: 3, width: "100%", maxWidth: 480 }}
>
- <Typography
- component="label"
- htmlFor="landing-album-url"
- sx={{
- display: "block",
- mb: 1.5,
- color: "#777",
- fontSize: 14,
+ <Box
+ component="form"
+ onSubmit={(event) => {
+ event.preventDefault();
+ if (!busy && enteUrl.trim())
+ void handleImportEnte();
}}
+ sx={{ minWidth: 0 }}
>
- or import an Ente album
- </Typography>
- <Box sx={{ display: "flex", gap: 1 }}>
<TextField
id="landing-album-url"
+ variant="outlined"
+ margin="none"
fullWidth
- placeholder="Paste an album link"
+ placeholder="Paste an Ente album link"
value={enteUrl}
onChange={(event) =>
setEnteUrl(event.target.value)
@@ -215,7 +217,47 @@ export default function StartPage() {
autoComplete="off"
disabled={busy}
slotProps={{
+ input: {
+ endAdornment: (
+ <InputAdornment position="end">
+ <Button
+ type="submit"
+ disabled={
+ busy || !enteUrl.trim()
+ }
+ sx={{
+ minWidth: 84,
+ height: 42,
+ px: 2,
+ borderRadius: "999px",
+ color: "#08652D",
+ bgcolor: "#FFF",
+ fontFamily:
+ "var(--font-outfit), sans-serif",
+ fontSize: 14,
+ fontWeight: 600,
+ "&:hover": {
+ bgcolor: "#ECF8EF",
+ },
+ "&.Mui-disabled": {
+ color: "#497755",
+ bgcolor: "#DAEEDF",
+ opacity: 1,
+ },
+ "&.Mui-focusVisible": {
+ outline:
+ "2px solid #FFF",
+ outlineOffset: 2,
+ },
+ }}
+ >
+ Import
+ </Button>
+ </InputAdornment>
+ ),
+ },
htmlInput: {
+ "aria-label": "Ente album link",
inputMode: "url",
spellCheck: false,
"aria-describedby": enteError
@@ -224,65 +266,99 @@ export default function StartPage() {
},
}}
sx={{
+ "& .MuiInputAdornment-root": { mr: 0 },
"& .MuiOutlinedInput-root": {
- height: 48,
- borderRadius: "14px",
- color: "#333",
- bgcolor: "#FFF",
- fontSize: 14,
- "& fieldset": { borderColor: "#DDD" },
+ height: 56,
+ pl: 1,
+ pr: "7px",
+ borderRadius: "999px",
+ color: "#FFF",
+ bgcolor: "rgba(0,80,20,0.38)",
+ transition:
+ "background-color 150ms ease",
+ fontFamily:
+ "var(--font-outfit), sans-serif",
+ fontSize: 16,
+ "& fieldset": {
+ borderColor: "transparent",
+ },
+ "&:hover": {
+ bgcolor: "rgba(0,80,20,0.46)",
+ },
"&:hover fieldset": {
- borderColor: "#BBB",
+ borderColor: "transparent",
+ },
+ "&.Mui-focused": {
+ bgcolor: "rgba(0,80,20,0.52)",
},
"&.Mui-focused fieldset": {
- borderColor: "#08C225",
+ borderColor: "transparent",
+ },
+ "& input::placeholder": {
+ color: "#D7E8DB",
+ opacity: 1,
},
},
}}
/>
- <Button
- type="submit"
- disabled={busy || !enteUrl.trim()}
- sx={{
- height: 48,
- px: 2.5,
- borderRadius: "14px",
- color: "#006E0F",
- bgcolor: "#EEF8EF",
- "&:hover": { bgcolor: "#E1F2E3" },
- "&.Mui-disabled": {
- color: "#999",
- bgcolor: "#F2F2F2",
- },
- }}
- >
- Import
- </Button>
+ {enteError && (
+ <Alert
+ id="landing-import-error"
+ severity="error"
+ sx={{
+ mt: 2,
+ borderRadius: 2,
+ textAlign: "left",
+ }}
+ >
+ {enteError}
+ </Alert>
+ )}
</Box>
- {enteError && (
+ <Button
+ variant="outlined"
+ size="large"
+ disabled={busy}
+ onClick={() => fileInputRef.current?.click()}
+ startIcon={
+ <AddPhotosIcon sx={{ width: 20, height: 20 }} />
+ }
+ sx={{
+ height: 53,
+ color: "#FFF2CD",
+ borderColor: "rgba(255,242,205,0.3)",
+ fontFamily: "var(--font-outfit), sans-serif",
+ fontSize: 14,
+ fontWeight: 500,
+ whiteSpace: "nowrap",
+ px: 3,
+ py: 0,
+ borderRadius: "999px",
+ "&:hover": {
+ bgcolor: "rgba(255,242,205,0.12)",
+ borderColor: "rgba(255,242,205,0.55)",
+ },
+ "&.Mui-disabled": {
+ color: "rgba(255,242,205,0.45)",
+ borderColor: "rgba(255,242,205,0.2)",
+ },
+ "&.Mui-focusVisible": {
+ outline: "3px solid #FFF2CD",
+ outlineOffset: 3,
+ },
+ }}
+ >
+ Add photos instead
+ </Button>
+ {importError && (
<Alert
- id="landing-import-error"
severity="error"
- sx={{
- mt: 2,
- borderRadius: 2,
- textAlign: "left",
- }}
+ sx={{ gridColumn: "1 / -1", textAlign: "left" }}
>
- {enteError}
+ {importError}
</Alert>
)}
</Box>
- <Typography
- sx={{
- fontFamily: "var(--font-inter), sans-serif",
- fontSize: "0.85rem",
- color: "#999",
- letterSpacing: "0.04em",
- }}
- >
- Print-ready. Auto-arranged. 100% in your browser.
- </Typography>
</Box>
</Box>
<input
diff --git a/web/apps/photobook/src/components/editorLayout.ts b/web/apps/photobook/src/components/editorLayout.ts
index 123694035f..0f7f7c148d 100644
--- a/web/apps/photobook/src/components/editorLayout.ts
+++ b/web/apps/photobook/src/components/editorLayout.ts
@@ -1,5 +1,8 @@
import { uiColors } from "@/theme/colors";
+export const MOBILE_QUERY = "(max-width: 959px)";
+export const SINGLE_PAGE_QUERY = "(max-width: 599px)";
+
export const EDITOR_SIDEBAR_WIDTH = { xs: 156, sm: 366 };
export const EDITOR_CANVAS_PADDING = 16;
export const EDITOR_HEADER_HEIGHT = { xs: 60, sm: 76 };
diff --git a/web/apps/photobook/src/context/BookContext.tsx b/web/apps/photobook/src/context/BookContext.tsx
index c42f7c663d..614cd1e2bf 100644
--- a/web/apps/photobook/src/context/BookContext.tsx
+++ b/web/apps/photobook/src/context/BookContext.tsx
@@ -59,6 +59,7 @@ import React, {
} from "react";
import { BookContext } from "./book";
+const MAX_PHOTOS = 650;
const emptyBook: BookState = { pages: [], currentSpreadIndex: 0 };
function isPendingEnteOriginal(photo: Photo): boolean {
@@ -277,8 +278,6 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
}
return next;
}, [photos]);
- const pendingEnteOriginalsRef = useRef<Set<string>>(pendingEnteOriginals);
- pendingEnteOriginalsRef.current = pendingEnteOriginals;
const activeEnteOriginalDownloadsRef = useRef<Set<string>>(new Set());
const enteOriginalWaitersRef = useRef<Map<string, (() => void)[]>>(
new Map(),
@@ -359,6 +358,10 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
const addPhotos = useCallback(
async (files: File[], options: AddPhotosOptions = {}) => {
const replace = options.replace ?? false;
+ const skippedByLimit = replace
+ ? Math.max(0, files.length - MAX_PHOTOS)
+ : 0;
+ if (replace) files = files.slice(0, MAX_PHOTOS);
const destination = options.destination ?? { kind: "end" as const };
if (!replace) {
const error = photoDestinationError(
@@ -491,10 +494,16 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
);
}
const skipped = files.length - newPhotos.length;
+ const notices: string[] = [];
if (skipped > 0)
- setImportNotice(
+ notices.push(
`${skipped} photo${skipped === 1 ? "" : "s"} couldn't be imported.`,
);
+ if (skippedByLimit > 0)
+ notices.push(
+ `${skippedByLimit} photo${skippedByLimit === 1 ? " was" : "s were"} skipped because of the ${MAX_PHOTOS}-photo limit.`,
+ );
+ setImportNotice(notices.join(" ") || null);
const allPhotos = replace
? newPhotos
@@ -549,23 +558,22 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
status: PhotoOriginalStatus,
originalError?: string,
) => {
- setPhotos((prev) =>
- prev.map((photo) => {
- if (photo.id !== photoId || photo.source !== "ente") {
- return photo;
- }
+ photosRef.current = photosRef.current.map((photo) => {
+ if (photo.id !== photoId || photo.source !== "ente") {
+ return photo;
+ }
- const next: Photo = {
- ...photo,
- originalStatus: status,
- originalError,
- };
- if (status === "ready" || status === "failed") {
- next.enteOriginal = undefined;
- }
- return next;
- }),
- );
+ const next: Photo = {
+ ...photo,
+ originalStatus: status,
+ originalError,
+ };
+ if (status === "ready") {
+ next.enteOriginal = undefined;
+ }
+ return next;
+ });
+ setPhotos(photosRef.current);
const waiters = enteOriginalWaitersRef.current.get(photoId);
if (waiters) {
enteOriginalWaitersRef.current.delete(photoId);
@@ -587,6 +595,7 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
}
const job = buildEnteOriginalDownloadJob(photo);
if (!job) {
+ activeEnteOriginalDownloadsRef.current.delete(photoId);
markEnteOriginalDone(
photoId,
"failed",
@@ -763,7 +772,6 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
}
const { credentials, files } = preparation;
- const MAX_PHOTOS = 800;
const limited = files.slice(0, MAX_PHOTOS);
if (files.length > MAX_PHOTOS) {
setImportNotice(
@@ -917,28 +925,41 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
const waitForEnteOriginals = useCallback(
async (
- photoIds?: string[],
+ photoIds: string[],
onProgress?: (done: number, total: number) => void,
) => {
- const requested =
- photoIds ?? Array.from(pendingEnteOriginalsRef.current);
- const pending = requested.filter((id) =>
- pendingEnteOriginalsRef.current.has(id),
+ const requested = new Set(photoIds);
+ const pending = photosRef.current.filter(
+ (photo) =>
+ requested.has(photo.id) &&
+ photo.source === "ente" &&
+ photo.originalStatus !== "ready",
);
- if (pending.length === 0) return;
+ if (pending.length === 0) return true;
+ const failedIds = new Set(
+ pending
+ .filter((photo) => photo.originalStatus === "failed")
+ .map((photo) => photo.id),
+ );
+ if (failedIds.size > 0) {
+ photosRef.current = photosRef.current.map((photo) =>
+ failedIds.has(photo.id)
+ ? {
+ ...photo,
+ originalStatus: "pending",
+ originalError: undefined,
+ }
+ : photo,
+ );
+ setPhotos(photosRef.current);
+ }
const total = pending.length;
let done = 0;
onProgress?.(done, total);
await Promise.all(
pending.map(
- (id) =>
+ ({ id }) =>
new Promise<void>((resolve) => {
- if (!pendingEnteOriginalsRef.current.has(id)) {
- done++;
- onProgress?.(done, total);
- resolve();
- return;
- }
const existing =
enteOriginalWaitersRef.current.get(id) ?? [];
existing.push(() => {
@@ -950,6 +971,11 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
}),
),
);
+ return pending.every(
+ ({ id }) =>
+ photosRef.current.find((photo) => photo.id === id)
+ ?.originalStatus === "ready",
+ );
},
[],
);
@@ -1413,7 +1439,6 @@ export function BookProvider({ children }: { children: React.ReactNode }) {
clearImageCache();
photosRef.current = [];
- pendingEnteOriginalsRef.current = new Set();
setPhotos([]);
setThumbnailUrls(new Map());
setPreviewUrls(new Map());
diff --git a/web/apps/photobook/src/context/book.ts b/web/apps/photobook/src/context/book.ts
index 3d4e269bad..0e6e37ef54 100644
--- a/web/apps/photobook/src/context/book.ts
+++ b/web/apps/photobook/src/context/book.ts
@@ -38,9 +38,9 @@ interface BookContextValue {
clearImportNotice: () => void;
pendingEnteOriginals: Set<string>;
waitForEnteOriginals: (
- photoIds?: string[],
+ photoIds: string[],
onProgress?: (done: number, total: number) => void,
- ) => Promise<void>;
+ ) => Promise<boolean>;
book: BookState;
setBook: Dispatch<SetStateAction<BookState>>;
diff --git a/web/apps/photobook/src/globals.css b/web/apps/photobook/src/globals.css
index 380520f264..ad2508566e 100644
--- a/web/apps/photobook/src/globals.css
+++ b/web/apps/photobook/src/globals.css
@@ -51,3 +51,8 @@ textarea {
::-webkit-scrollbar-thumb:hover {
background: #657177;
}
+
+.green-bg {
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAsTAAALEwEAmpwYAAABaWlDQ1BEaXNwbGF5IFAzAAB4nHWQvUvDUBTFT6tS0DqIDh0cMolD1NIKdnFoKxRFMFQFq1OafgltfCQpUnETVyn4H1jBWXCwiFRwcXAQRAcR3Zw6KbhoeN6XVNoi3sfl/Ticc7lcwBtQGSv2AijplpFMxKS11Lrke4OHnlOqZrKooiwK/v276/PR9d5PiFlNu3YQ2U9cl84ul3aeAlN//V3Vn8maGv3f1EGNGRbgkYmVbYsJ3iUeMWgp4qrgvMvHgtMunzuelWSc+JZY0gpqhrhJLKc79HwHl4plrbWD2N6f1VeXxRzqUcxhEyYYilBRgQQF4X/8044/ji1yV2BQLo8CLMpESRETssTz0KFhEjJxCEHqkLhz634PrfvJbW3vFZhtcM4v2tpCAzidoZPV29p4BBgaAG7qTDVUR+qh9uZywPsJMJgChu8os2HmwiF3e38M6Hvh/GMM8B0CdpXzryPO7RqFn4Er/QcXKWq8MSlPPgAAABBJREFUeAEBBQD6/wAIwiX/A7QB7/maltEAAAAASUVORK5CYII=")
+ repeat;
+}
diff --git a/web/apps/photobook/src/hooks/usePhotoImport.ts b/web/apps/photobook/src/hooks/usePhotoImport.ts
index 68cc4a8a7a..53f4058d1c 100644
--- a/web/apps/photobook/src/hooks/usePhotoImport.ts
+++ b/web/apps/photobook/src/hooks/usePhotoImport.ts
@@ -19,8 +19,6 @@ const ACCEPTED_TYPES = [
"image/heif",
];
-const MAX_PHOTOS = 800;
-
type EnteDialogStage = "closed" | "url" | "password";
function usePhotoImportSession() {
@@ -139,20 +137,18 @@ function usePhotoImportSession() {
const handleFiles = useCallback(
async (files: FileList | File[]) => {
- const valid = Array.from(files)
- .filter((f) => {
- const ext = f.name.toLowerCase().split(".").pop();
- return (
- ACCEPTED_TYPES.includes(f.type) ||
- ext === "heic" ||
- ext === "heif" ||
- ext === "jpg" ||
- ext === "jpeg" ||
- ext === "png" ||
- ext === "webp"
- );
- })
- .slice(0, MAX_PHOTOS);
+ const valid = Array.from(files).filter((f) => {
+ const ext = f.name.toLowerCase().split(".").pop();
+ return (
+ ACCEPTED_TYPES.includes(f.type) ||
+ ext === "heic" ||
+ ext === "heif" ||
+ ext === "jpg" ||
+ ext === "jpeg" ||
+ ext === "png" ||
+ ext === "webp"
+ );
+ });
if (valid.length > 0) {
if (!beginImport()) return;
diff --git a/web/apps/photobook/src/lib/ente/url.test.ts b/web/apps/photobook/src/lib/ente/url.test.ts
index 6b63df9ac9..02355c93bf 100644
--- a/web/apps/photobook/src/lib/ente/url.test.ts
+++ b/web/apps/photobook/src/lib/ente/url.test.ts
@@ -8,25 +8,37 @@ describe("public album links", () => {
test.each(["albums.ente.com", "albums.ente.io", "albums.example.org"])(
"reads a link on %s without changing the configured API",
(host) => {
- expect(
- parseEnteAlbumUrl(`https://${host}/?t=token#${base58}`),
- ).toEqual({
- accessToken: "token",
- collectionKey: btoa("\0".repeat(32)),
- });
+ for (const path of ["/?t=token", "/token", "/token/"]) {
+ expect(
+ parseEnteAlbumUrl(`https://${host}${path}#${base58}`),
+ ).toEqual({
+ accessToken: "token",
+ collectionKey: btoa("\0".repeat(32)),
+ });
+ }
},
);
- test("accepts legacy hexadecimal keys", () => {
+ test("prefers the query token when both formats are present", () => {
expect(
- parseEnteAlbumUrl(`https://albums.ente.com/?t=token#${hex}`),
- ).toEqual(
- parseEnteAlbumUrl(`https://albums.ente.com/?t=token#${base58}`),
- );
+ parseEnteAlbumUrl(`https://albums.ente.com/path?t=query#${base58}`)
+ .accessToken,
+ ).toBe("query");
});
+ test.each(["/?t=token", "/token"])(
+ "accepts legacy hexadecimal keys with %s",
+ (path) => {
+ expect(
+ parseEnteAlbumUrl(`https://albums.ente.com${path}#${hex}`),
+ ).toEqual(
+ parseEnteAlbumUrl(`https://albums.ente.com${path}#${base58}`),
+ );
+ },
+ );
test.each([
"bad URL",
- "https://albums.ente.com/#key",
+ `https://albums.ente.com/#${base58}`,
"https://albums.ente.com/?t=token",
+ "https://albums.ente.com/token",
`javascript:alert(1)?t=token#${base58}`,
"https://albums.ente.com/?t=token#111",
`https://albums.ente.com/?t=token#${"0g".repeat(32)}`,
diff --git a/web/apps/photobook/src/lib/ente/url.ts b/web/apps/photobook/src/lib/ente/url.ts
index 87c65f2375..85ff5eb27b 100644
--- a/web/apps/photobook/src/lib/ente/url.ts
+++ b/web/apps/photobook/src/lib/ente/url.ts
@@ -9,9 +9,10 @@ export function parseEnteAlbumUrl(input: string) {
}
if (url.protocol !== "https:" && url.protocol !== "http:")
throw new Error("Album links must use HTTP or HTTPS.");
- const accessToken = url.searchParams.get("t");
+ const accessToken =
+ url.searchParams.get("t") || url.pathname.split("/").find(Boolean);
if (!accessToken)
- throw new Error("Album link is missing the access token (?t=…).");
+ throw new Error("Album link is missing the access token.");
const hash = url.hash.slice(1);
if (!hash)
throw new Error(
diff --git a/web/apps/photobook/src/lib/export.ts b/web/apps/photobook/src/lib/export.ts
index e606b16b03..0a84fff0f2 100644
--- a/web/apps/photobook/src/lib/export.ts
+++ b/web/apps/photobook/src/lib/export.ts
@@ -4,6 +4,7 @@ import { getPhotoBlob } from "./db";
import { createPdfWriter } from "./pdfx";
import {
CAPTION_FONT_WEIGHT,
+ CAPTION_TEXT_COLOR,
CENTER_TEXT_FONT_WEIGHT,
getBrandingLayout,
getCaptionLayout,
@@ -155,7 +156,10 @@ export async function renderPageToCanvas(
(layout.height / 100) * height,
);
ctx.clip();
- ctx.fillStyle = "#2a2a2a";
+ ctx.fillStyle =
+ position !== "center" && !isFrontCover && !isBackCover
+ ? CAPTION_TEXT_COLOR
+ : "#2a2a2a";
const isTitle = position === "center" || isFrontCover;
const fontFamily = isTitle ? getOutfitFont() : getInterFont();
const fontWeight = isTitle
diff --git a/web/apps/photobook/src/lib/printLayout.ts b/web/apps/photobook/src/lib/printLayout.ts
index 868d5b255f..85c455450a 100644
--- a/web/apps/photobook/src/lib/printLayout.ts
+++ b/web/apps/photobook/src/lib/printLayout.ts
@@ -9,6 +9,7 @@ import type { BookPage, TextBlock } from "./types";
export const TEXT_LINE_HEIGHT = 1.4;
export const CENTER_TEXT_FONT_WEIGHT = 600;
export const CAPTION_FONT_WEIGHT = 300;
+export const CAPTION_TEXT_COLOR = "#555555";
const TITLE_FONT_SIZE = Math.min(
5,
((BOOK_LAYOUT.coverInsetMarginMm.v / BOOK_SIZE_MM) * 100 -
diff --git a/web/apps/photobook/src/pages/app.tsx b/web/apps/photobook/src/pages/app.tsx
index 012ef22732..3968b1eac8 100644
--- a/web/apps/photobook/src/pages/app.tsx
+++ b/web/apps/photobook/src/pages/app.tsx
@@ -1,5 +1,9 @@
+import { useBook } from "@/context/book";
+import { usePhotoImport } from "@/hooks/usePhotoImport";
import { Box, CircularProgress } from "@mui/material";
import dynamic from "next/dynamic";
+import { useRouter } from "next/router";
+import { useEffect } from "react";
const AppShell = dynamic(() => import("@/components/AppShell"), {
ssr: false,
@@ -18,5 +22,14 @@ const AppShell = dynamic(() => import("@/components/AppShell"), {
});
export default function Home() {
- return <AppShell />;
+ const router = useRouter();
+ const { book, loading } = useBook();
+ const { importActive } = usePhotoImport();
+ const emptyBook = !loading && !importActive && book.pages.length === 0;
+
+ useEffect(() => {
+ if (emptyBook) void router.replace("/");
+ }, [emptyBook, router]);
+
+ return loading || emptyBook ? null : <AppShell />;
}
diff --git a/web/apps/photobook/src/pages/index.tsx b/web/apps/photobook/src/pages/index.tsx
index 6d057ca277..38f87a76f3 100644
--- a/web/apps/photobook/src/pages/index.tsx
+++ b/web/apps/photobook/src/pages/index.tsx
@@ -1 +1,16 @@
-export { default } from "@/components/StartPage";
+import StartPage from "@/components/StartPage";
+import { useBook } from "@/context/book";
+import { useRouter } from "next/router";
+import { useEffect } from "react";
+
+export default function Home() {
+ const router = useRouter();
+ const { book, loading } = useBook();
+ const hasBook = book.pages.length > 0;
+
+ useEffect(() => {
+ if (!loading && hasBook) void router.replace("/app");
+ }, [loading, hasBook, router]);
+
+ return loading || hasBook ? null : <StartPage />;
+}
diff --git a/web/apps/photobook/src/theme/buttons.ts b/web/apps/photobook/src/theme/buttons.ts
index a280048abc..9e14ad7339 100644
--- a/web/apps/photobook/src/theme/buttons.ts
+++ b/web/apps/photobook/src/theme/buttons.ts
@@ -24,6 +24,7 @@ export const editorButtonSx = {
export const headerButtonSx = {
...editorButtonSx,
+ "@media (max-width: 959px)": { height: 44, minWidth: 44 },
flexShrink: 0,
minWidth: { xs: 38, sm: 0 },
width: "auto",
diff --git a/web/apps/photobook/src/theme/menus.ts b/web/apps/photobook/src/theme/menus.ts
new file mode 100644
index 0000000000..24d7548887
--- /dev/null
+++ b/web/apps/photobook/src/theme/menus.ts
@@ -0,0 +1,34 @@
+import { pageMenuColors, popupShadow } from "./colors";
+
+export const pageMenuPaperSx = {
+ bgcolor: pageMenuColors.background,
+ backgroundImage: "none",
+ borderRadius: "14px",
+ boxShadow: popupShadow,
+ mt: "6px",
+ minWidth: 0,
+ p: "4px",
+ width: "max-content",
+} as const;
+
+export const pageMenuItemSx = {
+ alignItems: "center",
+ borderRadius: "10px",
+ color: pageMenuColors.text,
+ display: "flex",
+ gap: "8px",
+ minHeight: 36,
+ px: "9px",
+ py: "4px",
+ fontSize: 13,
+ fontWeight: 500,
+ lineHeight: "18px",
+ whiteSpace: "nowrap",
+ transition: "background-color 120ms ease, color 120ms ease",
+ "& .MuiSvgIcon-root": { color: pageMenuColors.icon },
+ "&:hover, &.Mui-focusVisible": {
+ bgcolor: pageMenuColors.hover,
+ "& .MuiSvgIcon-root": { color: pageMenuColors.text },
+ },
+ "&:active": { bgcolor: pageMenuColors.active },
+} as const;