Skip to content

armgit / ente

Public Imported from GitHub
0

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

update(default-options):make-it-responsive

Aswin Asok30e1e5a1c1f6
diff --git a/web/apps/albums/src/public-album/upload/components/Upload.tsx b/web/apps/albums/src/public-album/upload/components/Upload.tsx
index e99dba3e36..86d874667e 100644
--- a/web/apps/albums/src/public-album/upload/components/Upload.tsx
+++ b/web/apps/albums/src/public-album/upload/components/Upload.tsx
@@ -35,6 +35,10 @@ import { useBaseContext } from "ente-base/context";
import { basename } from "ente-base/file-name";
import type { PublicAlbumsCredentials } from "ente-base/http";
import log from "ente-base/log";
+import {
+ uploadSheetPaperSx,
+ useIsUploadSheet,
+} from "ente-gallery/components/upload-progress/bottom-sheet";
import { UploadProgress } from "ente-gallery/components/upload-progress/UploadProgress";
import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";
import { DefaultOptions } from "ente-gallery/components/upload/DefaultOptions";
@@ -42,6 +46,7 @@ import { useFileInput } from "ente-gallery/components/utils/use-file-input";
import { hasReliableCanvasReadback } from "ente-gallery/utils/upload/canvas-integrity";
import type { Collection } from "ente-media/collection";
import type { EnteFile } from "ente-media/file";
+import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
import { firstNonEmpty } from "ente-utils/array";
import { t } from "i18next";
import React, { useCallback, useEffect, useRef, useState } from "react";
@@ -520,25 +525,31 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({
onClose();
};
+ const isSheet = useIsUploadSheet();
+
return (
<Dialog
open={open}
onClose={handleClose}
fullWidth
+ slots={isSheet ? { transition: SlideUpTransition } : undefined}
slotProps={{
paper: {
- sx: (theme) => ({
- maxWidth: "440px",
- p: 0,
- borderRadius: "20px",
- boxShadow: "none",
- border: "1px solid",
- borderColor: "stroke.faint",
- backgroundColor: "secondary.main",
- ...theme.applyStyles("dark", {
- backgroundColor: "background.paper",
+ sx: [
+ (theme) => ({
+ maxWidth: "440px",
+ p: 0,
+ borderRadius: "20px",
+ boxShadow: "none",
+ border: "1px solid",
+ borderColor: "stroke.faint",
+ backgroundColor: "secondary.main",
+ ...theme.applyStyles("dark", {
+ backgroundColor: "background.paper",
+ }),
}),
- }),
+ uploadSheetPaperSx,
+ ],
},
}}
sx={{
diff --git a/web/apps/photos/src/components/TakeoutOptions.tsx b/web/apps/photos/src/components/TakeoutOptions.tsx
index f745da4936..7cae7d4f47 100644
--- a/web/apps/photos/src/components/TakeoutOptions.tsx
+++ b/web/apps/photos/src/components/TakeoutOptions.tsx
@@ -3,13 +3,40 @@ import { HugeiconsIcon } from "@hugeicons/react";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import CloseIcon from "@mui/icons-material/Close";
-import { Box, IconButton, Link, Stack, Typography } from "@mui/material";
+import {
+ Box,
+ CircularProgress,
+ IconButton,
+ Link,
+ Stack,
+ Typography,
+} from "@mui/material";
import { isDesktop } from "ente-base/app";
import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
+import {
+ uploadSheetMediaQuery,
+ useIsUploadSheet,
+} from "ente-gallery/components/upload-progress/bottom-sheet";
import { t } from "i18next";
import React from "react";
+/**
+ * Title style for the takeout options surface.
+ *
+ * Per the mobile design, this second-level sheet uses the app's base font for
+ * its title (unlike the top-level options titles, which keep the display
+ * font); the desktop dialog keeps the display font.
+ */
+const optionsTitleSx = {
+ fontFamily: "'Outfit Variable', sans-serif",
+ fontSize: "24px",
+ fontWeight: 600,
+ lineHeight: "32px",
+ [uploadSheetMediaQuery]: { fontFamily: '"Inter Variable", sans-serif' },
+};
+
interface TakeoutOptionsProps {
+ isFolderSelectionPending?: boolean;
onBack: () => void;
onClose: () => void;
onSelectFolder: () => void;
@@ -17,13 +44,27 @@ interface TakeoutOptionsProps {
}
export function TakeoutOptions({
+ isFolderSelectionPending,
onBack,
onClose,
onSelectFolder,
onSelectZips,
}: TakeoutOptionsProps): React.JSX.Element {
+ const isSheet = useIsUploadSheet();
+
return (
- <Stack data-takeout-options sx={{ gap: "36px", p: "20px" }}>
+ <Stack
+ data-takeout-options
+ sx={{
+ gap: "36px",
+ p: "20px",
+ [uploadSheetMediaQuery]: {
+ p: "12px 16px",
+ pb: "calc(20px + env(safe-area-inset-bottom, 0px))",
+ overflowY: "auto",
+ },
+ }}
+ >
<Stack
direction="row"
sx={{ alignItems: "center", justifyContent: "space-between" }}
@@ -40,15 +81,12 @@ export function TakeoutOptions({
>
<ArrowBackIcon sx={{ fontSize: "24px" }} />
</IconButton>
- <Typography
- sx={{
- fontFamily: "'Outfit Variable', sans-serif",
- fontSize: "24px",
- fontWeight: 600,
- lineHeight: "32px",
- }}
- >
- {t("import_from_google_photos")}
+ <Typography sx={optionsTitleSx}>
+ {t(
+ isSheet
+ ? "google_takeout"
+ : "import_from_google_photos",
+ )}
</Typography>
</Stack>
<IconButton
@@ -74,6 +112,7 @@ export function TakeoutOptions({
icon={<HugeiconsIcon icon={Folder01Icon} size={18} />}
label={t("unzipped_folder")}
description={t("unzipped_folder_hint")}
+ pending={isFolderSelectionPending}
onClick={onSelectFolder}
/>
<TakeoutOptionButton
@@ -121,6 +160,7 @@ interface TakeoutOptionButtonProps {
label: string;
description: string;
disabled?: boolean;
+ pending?: boolean;
onClick: () => void;
}
@@ -129,6 +169,7 @@ function TakeoutOptionButton({
label,
description,
disabled,
+ pending,
onClick,
}: TakeoutOptionButtonProps): React.JSX.Element {
return (
@@ -137,7 +178,7 @@ function TakeoutOptionButton({
disabled={disabled}
onClick={onClick}
sx={(theme) => ({
- height: "60px",
+ minHeight: "60px",
p: "12px",
borderRadius: "20px",
backgroundColor: "background.paper",
@@ -168,7 +209,14 @@ function TakeoutOptionButton({
color: "text.muted",
}}
>
- {icon}
+ {pending ? (
+ <CircularProgress
+ size={18}
+ sx={{ color: "stroke.muted" }}
+ />
+ ) : (
+ icon
+ )}
</Box>
<Stack
sx={{ flex: 1, minWidth: 0, textAlign: "left", gap: "4px" }}
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index 9b0ce645f4..89f8613f0f 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -48,6 +48,11 @@ import type {
ZipItem,
} from "ente-base/types/ipc";
import type { UploadTypeSelectorIntent } from "ente-gallery/components/Upload";
+import {
+ uploadSheetMediaQuery,
+ uploadSheetPaperSx,
+ useIsUploadSheet,
+} from "ente-gallery/components/upload-progress/bottom-sheet";
import { UploadProgress } from "ente-gallery/components/upload-progress/UploadProgress";
import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";
import { DefaultOptions } from "ente-gallery/components/upload/DefaultOptions";
@@ -73,6 +78,7 @@ import {
import { hasReliableCanvasReadback } from "ente-gallery/utils/upload/canvas-integrity";
import { CollectionSubType, type Collection } from "ente-media/collection";
import type { EnteFile } from "ente-media/file";
+import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
import { suppressAutoLockOnBlurForTrustedPrompt } from "ente-new/photos/services/app-lock";
import {
addOrCopyToCollection,
@@ -1487,6 +1493,8 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({
pendingUploadType,
onSelect,
}) => {
+ const isSheet = useIsUploadSheet();
+
const handleClose: DialogProps["onClose"] = () => {
// The browser may still be processing the selection after the picker closes.
if (pendingUploadType) return;
@@ -1498,27 +1506,42 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({
open={open}
onClose={handleClose}
fullWidth
+ slots={isSheet ? { transition: SlideUpTransition } : undefined}
slotProps={{
paper: {
- sx: (theme) => ({
- maxWidth: "375px",
- p: 1,
- borderRadius: "28px",
- boxShadow: "none",
- border: "1px solid",
- borderColor: "stroke.faint",
- "&:has([data-default-options], [data-takeout-options])":
- {
- maxWidth: "621px",
- p: 0,
- borderRadius: "20px",
- backgroundColor: "secondary.main",
- ...theme.applyStyles("dark", {
- backgroundColor: "background.paper",
- }),
+ sx: [
+ (theme) => ({
+ maxWidth: "375px",
+ p: 1,
+ borderRadius: "28px",
+ boxShadow: "none",
+ border: "1px solid",
+ borderColor: "stroke.faint",
+ "&:has([data-default-options], [data-takeout-options])":
+ {
+ maxWidth: "621px",
+ p: 0,
+ borderRadius: "20px",
+ backgroundColor: "secondary.main",
+ ...theme.applyStyles("dark", {
+ backgroundColor: "background.paper",
+ }),
+ },
+ [theme.breakpoints.down(360)]: { p: 0 },
+ }),
+ uploadSheetPaperSx,
+ // The ":has()" selector above outweighs the media query
+ // styles in uploadSheetPaperSx; re-assert the sheet
+ // shape at matching specificity.
+ {
+ [uploadSheetMediaQuery]: {
+ "&&": {
+ maxWidth: "none",
+ borderRadius: "20px 20px 0 0",
+ },
},
- [theme.breakpoints.down(360)]: { p: 0 },
- }),
+ },
+ ],
},
}}
sx={{
@@ -1574,6 +1597,7 @@ const UploadOptions: React.FC<UploadOptionsProps> = ({
return showTakeoutOptions ? (
<TakeoutOptions
+ isFolderSelectionPending={pendingUploadType == "folders"}
onBack={handleTakeoutClose}
onSelectFolder={handleSelectFolder}
onSelectZips={handleSelectGooglePhotos}
diff --git a/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx b/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx
index 188c1548e5..2115c070c2 100644
--- a/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx
+++ b/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx
@@ -125,7 +125,7 @@ const minimizedPaperSx = (theme: Theme): SystemStyleObject<Theme> => ({
color: "text.base",
overflow: "hidden",
[uploadSheetMediaQuery]: {
- width: "100%",
+ width: "calc(100svw - 32px)",
animation: `${minimizedRiseAnimation} 320ms cubic-bezier(0.2, 0.8, 0.2, 1)`,
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
},
diff --git a/web/packages/gallery/components/upload/DefaultOptions.tsx b/web/packages/gallery/components/upload/DefaultOptions.tsx
index 9fdc2082c0..84140c12d0 100644
--- a/web/packages/gallery/components/upload/DefaultOptions.tsx
+++ b/web/packages/gallery/components/upload/DefaultOptions.tsx
@@ -17,6 +17,7 @@ import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton"
import { t } from "i18next";
import React from "react";
import type { UploadTypeSelectorIntent } from "../Upload";
+import { uploadSheetMediaQuery } from "../upload-progress/bottom-sheet";
interface DefaultOptionsBaseProps {
isFileSelectionPending: boolean;
@@ -50,30 +51,20 @@ export function DefaultOptions({
gap: usesUploadSpacing ? "20px" : "36px",
p: "20px",
pb: usesUploadSpacing ? "28px" : "20px",
+ [uploadSheetMediaQuery]: {
+ p: "12px 16px",
+ pb: "calc(28px + env(safe-area-inset-bottom, 0px))",
+ overflowY: "auto",
+ },
}}
>
<SpacedRow>
{intent == "collect" ? (
- <DialogTitle
- sx={{
- "&&": { p: 0 },
- fontFamily: "'Outfit Variable', sans-serif",
- fontSize: "24px",
- fontWeight: 600,
- lineHeight: "32px",
- }}
- >
+ <DialogTitle sx={[{ "&&": { p: 0 } }, optionsTitleSx]}>
{t("select_photos")}
</DialogTitle>
) : (
- <Typography
- sx={{
- fontFamily: "'Outfit Variable', sans-serif",
- fontSize: "24px",
- fontWeight: 600,
- lineHeight: "32px",
- }}
- >
+ <Typography sx={optionsTitleSx}>
{t(intent == "import" ? "import_library" : "upload")}
</Typography>
)}
@@ -502,3 +493,16 @@ function DragAndDropHint({
function PendingIndicator(): React.JSX.Element {
return <CircularProgress size={18} sx={{ color: "stroke.muted" }} />;
}
+
+/**
+ * Title style for the upload options surfaces.
+ *
+ * Per the mobile design, these titles keep the display font in both the
+ * desktop dialog and the bottom sheet presentations.
+ */
+const optionsTitleSx = {
+ fontFamily: "'Outfit Variable', sans-serif",
+ fontSize: "24px",
+ fontWeight: 600,
+ lineHeight: "32px",
+};