Skip to content

armgit / ente

Public Imported from GitHub
0

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

update(albums):use-default-options-v2

Aswin Asokd302a372ae86
diff --git a/web/apps/albums/package.json b/web/apps/albums/package.json
index 3834b47d87..3ccb947217 100644
--- a/web/apps/albums/package.json
+++ b/web/apps/albums/package.json
@@ -7,6 +7,7 @@
"@emotion/styled": "11.14.1",
"@ffmpeg/ffmpeg": "0.12.15",
"@fontsource-variable/inter": "5.2.8",
+ "@fontsource-variable/outfit": "5.2.8",
"@hugeicons/core-free-icons": "1.2.1",
"@hugeicons/react": "1.1.6",
"@mui/icons-material": "9.2.0",
diff --git a/web/apps/albums/src/pages/_app.tsx b/web/apps/albums/src/pages/_app.tsx
index 7a8fe07a18..3e8be42201 100644
--- a/web/apps/albums/src/pages/_app.tsx
+++ b/web/apps/albums/src/pages/_app.tsx
@@ -1,4 +1,5 @@
import { AlbumsAppProviders } from "@/app/providers/AlbumsAppProviders";
+import "@fontsource-variable/outfit";
import type { AppProps } from "next/app";
import "@/app/styles/fonts.css";
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 643c5379bd..272cea4d74 100644
--- a/web/apps/albums/src/public-album/upload/components/Upload.tsx
+++ b/web/apps/albums/src/public-album/upload/components/Upload.tsx
@@ -25,21 +25,7 @@ import type {
UploadItemWithCollection,
} from "@/public-album/upload/services/upload-manager";
import { uploadManager } from "@/public-album/upload/services/upload-manager";
-import { Album02Icon, Folder01Icon } from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
-import ChevronRightIcon from "@mui/icons-material/ChevronRight";
-import {
- Box,
- CircularProgress,
- Dialog,
- DialogTitle,
- styled,
- Typography,
- type DialogProps,
-} from "@mui/material";
-import { SpacedRow } from "ente-base/components/containers";
-import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton";
-import { RowButton } from "ente-base/components/RowButton";
+import { Dialog, type DialogProps } from "@mui/material";
import { useIsTouchscreen } from "ente-base/components/utils/hooks";
import {
useModalVisibility,
@@ -51,6 +37,7 @@ import type { PublicAlbumsCredentials } from "ente-base/http";
import log from "ente-base/log";
import { UploadProgressV2 } from "ente-gallery/components/upload-progress-v2/UploadProgressV2";
import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";
+import { DefaultOptionsV2 } from "ente-gallery/components/upload/DefaultOptionsV2";
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";
@@ -573,13 +560,16 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({
slotProps={{
paper: {
sx: (theme) => ({
- maxWidth: "375px",
- p: 1,
- borderRadius: "28px",
+ maxWidth: "440px",
+ p: 0,
+ borderRadius: "20px",
boxShadow: "none",
border: "1px solid",
borderColor: "stroke.faint",
- [theme.breakpoints.down(360)]: { p: 0 },
+ backgroundColor: "secondary.main",
+ ...theme.applyStyles("dark", {
+ backgroundColor: "background.paper",
+ }),
}),
},
}}
@@ -589,76 +579,14 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({
},
}}
>
- <UploadOptions {...{ pendingUploadType, onSelect, onClose }} />
+ <DefaultOptionsV2
+ intent="collect"
+ isFileSelectionPending={pendingUploadType == "files"}
+ isFolderSelectionPending={pendingUploadType == "folders"}
+ onSelectFiles={() => onSelect("files")}
+ onSelectFolder={() => onSelect("folders")}
+ onClose={onClose}
+ />
</Dialog>
);
};
-
-type UploadOptionsProps = Pick<
- UploadTypeSelectorProps,
- "onClose" | "pendingUploadType" | "onSelect"
->;
-
-const UploadOptions: React.FC<UploadOptionsProps> = ({
- pendingUploadType,
- onSelect,
- onClose,
-}) => (
- <>
- <SpacedRow>
- <DialogTitle variant="h5">{t("select_photos")}</DialogTitle>
- <DialogCloseIconButton {...{ onClose }} />
- </SpacedRow>
- <Box sx={{ p: "12px", pt: "16px" }}>
- <RoundedButtonStack>
- <RowButton
- startIcon={<HugeiconsIcon icon={Album02Icon} size={20} />}
- endIcon={
- pendingUploadType == "files" ? (
- <PendingIndicator />
- ) : (
- <ChevronRightIcon />
- )
- }
- label={t("files")}
- onClick={() => onSelect("files")}
- />
- <RowButton
- startIcon={<HugeiconsIcon icon={Folder01Icon} size={20} />}
- endIcon={
- pendingUploadType == "folders" ? (
- <PendingIndicator />
- ) : (
- <ChevronRightIcon />
- )
- }
- label={t("folder")}
- onClick={() => onSelect("folders")}
- />
- </RoundedButtonStack>
- <Typography
- sx={{
- color: "text.muted",
- p: "12px",
- pt: "24px",
- textAlign: "center",
- }}
- >
- {t("drag_and_drop_hint")}
- </Typography>
- </Box>
- </>
-);
-
-const PendingIndicator = () => (
- <CircularProgress size={18} sx={{ color: "stroke.muted" }} />
-);
-
-const RoundedButtonStack = styled("div")`
- display: flex;
- flex-direction: column;
- gap: 4px;
- & > button {
- border-radius: 16px;
- }
-`;
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index d1eea1e4e2..ad984694eb 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -3,7 +3,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable @typescript-eslint/no-misused-promises */
/* eslint-disable @typescript-eslint/no-floating-promises */
-import { DefaultOptionsV2 } from "@/components/DefaultOptionsV2";
import { TakeoutOptionsV2 } from "@/components/TakeoutOptionsV2";
import { UploadConfirmationDialog } from "@/components/UploadConfirmationDialog";
import type {
@@ -47,6 +46,7 @@ import type {
import type { UploadTypeSelectorIntent } from "ente-gallery/components/Upload";
import { UploadProgressV2 } from "ente-gallery/components/upload-progress-v2/UploadProgressV2";
import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";
+import { DefaultOptionsV2 } from "ente-gallery/components/upload/DefaultOptionsV2";
import { useFileInput } from "ente-gallery/components/utils/use-file-input";
import {
groupItemsBasedOnParentFolder,
diff --git a/web/package-lock.json b/web/package-lock.json
index aea16a3c12..b1fb0c6681 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -36,6 +36,7 @@
"@emotion/styled": "11.14.1",
"@ffmpeg/ffmpeg": "0.12.15",
"@fontsource-variable/inter": "5.2.8",
+ "@fontsource-variable/outfit": "5.2.8",
"@hugeicons/core-free-icons": "1.2.1",
"@hugeicons/react": "1.1.6",
"@mui/icons-material": "9.2.0",
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index 769dd91d3b..dfe498f25a 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -770,7 +770,6 @@
"view_logs": "View logs",
"view_logs_message": "<p>This will show debug logs, which you can email to us to help debug your issue.</p><p>Note that file names will be included to help track issues with specific files.</p>",
"weak_device_hint": "The web browser you're using is not powerful enough to encrypt your photos. Please try to log in to Ente on your computer, or download the Ente mobile/desktop app.",
- "drag_and_drop_hint": "Or drag and drop into the Ente window",
"authenticate": "Authenticate",
"uploaded_to_single_collection": "Uploaded to single collection",
"uploaded_to_separate_collections": "Uploaded to separate collections",
diff --git a/web/apps/photos/src/components/DefaultOptionsV2.tsx b/web/packages/gallery/components/upload/DefaultOptionsV2.tsx
similarity index 73%
rename from web/apps/photos/src/components/DefaultOptionsV2.tsx
rename to web/packages/gallery/components/upload/DefaultOptionsV2.tsx
index 9082330c48..9a18001341 100644
--- a/web/apps/photos/src/components/DefaultOptionsV2.tsx
+++ b/web/packages/gallery/components/upload/DefaultOptionsV2.tsx
@@ -6,6 +6,7 @@ import GoogleIcon from "@mui/icons-material/Google";
import {
Box,
CircularProgress,
+ DialogTitle,
IconButton,
Link,
Stack,
@@ -15,17 +16,22 @@ import { SpacedRow } from "ente-base/components/containers";
import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
import { t } from "i18next";
import React from "react";
+import type { UploadTypeSelectorIntent } from "../Upload";
-interface DefaultOptionsV2Props {
- intent: "import" | "upload";
+interface DefaultOptionsV2BaseProps {
isFileSelectionPending: boolean;
isFolderSelectionPending: boolean;
onClose: () => void;
onSelectFiles: () => void;
- onSelectGooglePhotos: () => void;
onSelectFolder: () => void;
}
+type DefaultOptionsV2Props = DefaultOptionsV2BaseProps &
+ (
+ | { intent: UploadTypeSelectorIntent; onSelectGooglePhotos: () => void }
+ | { intent: "collect"; onSelectGooglePhotos?: never }
+ );
+
export function DefaultOptionsV2({
intent,
isFileSelectionPending,
@@ -35,26 +41,42 @@ export function DefaultOptionsV2({
onSelectGooglePhotos,
onSelectFolder,
}: DefaultOptionsV2Props): React.JSX.Element {
+ const usesUploadSpacing = intent == "upload" || intent == "collect";
+
return (
<Stack
data-default-options-v2
sx={{
- gap: intent == "upload" ? "20px" : "36px",
+ gap: usesUploadSpacing ? "20px" : "36px",
p: "20px",
- pb: intent == "upload" ? "28px" : "20px",
+ pb: usesUploadSpacing ? "28px" : "20px",
}}
>
<SpacedRow>
- <Typography
- sx={{
- fontFamily: "'Outfit Variable', sans-serif",
- fontSize: "24px",
- fontWeight: 600,
- lineHeight: "32px",
- }}
- >
- {t(intent == "import" ? "import_library" : "upload")}
- </Typography>
+ {intent == "collect" ? (
+ <DialogTitle
+ sx={{
+ "&&": { p: 0 },
+ fontFamily: "'Outfit Variable', sans-serif",
+ fontSize: "24px",
+ fontWeight: 600,
+ lineHeight: "32px",
+ }}
+ >
+ {t("select_photos")}
+ </DialogTitle>
+ ) : (
+ <Typography
+ sx={{
+ fontFamily: "'Outfit Variable', sans-serif",
+ fontSize: "24px",
+ fontWeight: 600,
+ lineHeight: "32px",
+ }}
+ >
+ {t(intent == "import" ? "import_library" : "upload")}
+ </Typography>
+ )}
<IconButton
aria-label={t("close")}
onClick={onClose}
@@ -80,6 +102,15 @@ export function DefaultOptionsV2({
onSelectFolder,
}}
/>
+ ) : intent == "collect" ? (
+ <CollectOptions
+ {...{
+ isFileSelectionPending,
+ isFolderSelectionPending,
+ onSelectFiles,
+ onSelectFolder,
+ }}
+ />
) : (
<UploadOptions
{...{
@@ -96,9 +127,9 @@ export function DefaultOptionsV2({
}
type ImportOptionsProps = Pick<
- DefaultOptionsV2Props,
- "isFolderSelectionPending" | "onSelectGooglePhotos" | "onSelectFolder"
->;
+ DefaultOptionsV2BaseProps,
+ "isFolderSelectionPending" | "onSelectFolder"
+> & { onSelectGooglePhotos: () => void };
function ImportOptions({
isFolderSelectionPending,
@@ -139,13 +170,12 @@ function ImportOptions({
}
type UploadOptionsProps = Pick<
- DefaultOptionsV2Props,
+ DefaultOptionsV2BaseProps,
| "isFileSelectionPending"
| "isFolderSelectionPending"
| "onSelectFiles"
- | "onSelectGooglePhotos"
| "onSelectFolder"
->;
+> & { onSelectGooglePhotos: () => void };
function UploadOptions({
isFileSelectionPending,
@@ -201,6 +231,55 @@ function UploadOptions({
);
}
+type CollectOptionsProps = Pick<
+ DefaultOptionsV2BaseProps,
+ | "isFileSelectionPending"
+ | "isFolderSelectionPending"
+ | "onSelectFiles"
+ | "onSelectFolder"
+>;
+
+function CollectOptions({
+ isFileSelectionPending,
+ isFolderSelectionPending,
+ onSelectFiles,
+ onSelectFolder,
+}: CollectOptionsProps): React.JSX.Element {
+ return (
+ <Stack sx={{ gap: "16px" }}>
+ <Stack sx={{ gap: "10px" }}>
+ <OptionRowButton
+ icon={
+ <HugeiconsIcon
+ icon={Album02Icon}
+ size={20}
+ color="var(--mui-palette-text-muted)"
+ />
+ }
+ label={t("files")}
+ pending={isFileSelectionPending}
+ size="large"
+ onClick={onSelectFiles}
+ />
+ <OptionRowButton
+ icon={
+ <HugeiconsIcon
+ icon={Folder01Icon}
+ size={20}
+ color="var(--mui-palette-text-muted)"
+ />
+ }
+ label={t("folder")}
+ pending={isFolderSelectionPending}
+ size="large"
+ onClick={onSelectFolder}
+ />
+ </Stack>
+ <DragAndDropHint size="large" />
+ </Stack>
+ );
+}
+
interface ImportSectionProps {
title: string;
gap?: string;
@@ -276,6 +355,7 @@ interface OptionRowButtonProps {
label: string;
description?: string;
pending?: boolean;
+ size?: "medium" | "large";
onClick: () => void;
}
@@ -284,6 +364,7 @@ function OptionRowButton({
label,
description,
pending,
+ size = "medium",
onClick,
}: OptionRowButtonProps): React.JSX.Element {
return (
@@ -324,9 +405,9 @@ function OptionRowButton({
>
<Typography
sx={{
- fontSize: "14px",
+ fontSize: size == "large" ? "16px" : "14px",
fontWeight: 500,
- lineHeight: "20px",
+ lineHeight: size == "large" ? "24px" : "20px",
}}
>
{label}
@@ -357,7 +438,9 @@ function OptionRowButton({
{pending ? (
<PendingIndicator />
) : (
- <ChevronRightIcon sx={{ fontSize: "18px" }} />
+ <ChevronRightIcon
+ sx={{ fontSize: size == "large" ? "20px" : "18px" }}
+ />
)}
</Box>
</Stack>
@@ -393,14 +476,20 @@ function ImportHelp(): React.JSX.Element {
);
}
-function DragAndDropHint(): React.JSX.Element {
+interface DragAndDropHintProps {
+ size?: "medium" | "large";
+}
+
+function DragAndDropHint({
+ size = "medium",
+}: DragAndDropHintProps): React.JSX.Element {
return (
<Typography
sx={{
color: "text.faint",
- fontSize: "12px",
+ fontSize: size == "large" ? "14px" : "12px",
fontWeight: 500,
- lineHeight: "16px",
+ lineHeight: size == "large" ? "20px" : "16px",
opacity: 0.7,
textAlign: "center",
}}