Skip to content

armgit / ente

Public Imported from GitHub
0

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

Polish social logout and delete feedback

Anand Baburajan162653373a03
diff --git a/web/apps/social/src/components/ConfirmationActionSheet.tsx b/web/apps/social/src/components/ConfirmationActionSheet.tsx
index 57d6ecc92c..f931942a7d 100644
--- a/web/apps/social/src/components/ConfirmationActionSheet.tsx
+++ b/web/apps/social/src/components/ConfirmationActionSheet.tsx
@@ -1,4 +1,8 @@
import { Box, Dialog } from "@mui/material";
+import {
+ SocialActionFeedbackIcon,
+ type SocialActionPhase,
+} from "components/SocialActionFeedback";
import React from "react";
const green = "#08C225";
@@ -10,9 +14,13 @@ interface ConfirmationActionSheetProps {
open: boolean;
title: string;
confirmLabel: string;
+ confirmActionPhase?: SocialActionPhase | null;
+ confirmDisabled?: boolean;
cancelLabel?: string;
+ cancelDisabled?: boolean;
onCancel: () => void;
onConfirm: () => void;
+ onExited?: () => void;
}
export const ConfirmationActionSheet: React.FC<
@@ -22,9 +30,13 @@ export const ConfirmationActionSheet: React.FC<
open,
title,
confirmLabel,
+ confirmActionPhase = null,
+ confirmDisabled = false,
cancelLabel = "Cancel",
+ cancelDisabled = false,
onCancel,
onConfirm,
+ onExited,
}) => {
const titleID = React.useId();
const isDark = appearance == "dark";
@@ -32,7 +44,7 @@ export const ConfirmationActionSheet: React.FC<
return (
<Dialog
open={open}
- onClose={onCancel}
+ onClose={confirmActionPhase ? undefined : onCancel}
maxWidth={false}
aria-labelledby={titleID}
sx={
@@ -40,8 +52,7 @@ export const ConfirmationActionSheet: React.FC<
? {
zIndex: 1500,
"& .MuiBackdrop-root": {
- backgroundColor:
- "rgba(0, 0, 0, 0.86) !important",
+ backgroundColor: "rgba(0, 0, 0, 0.86) !important",
},
}
: undefined
@@ -70,6 +81,7 @@ export const ConfirmationActionSheet: React.FC<
maxWidth: 363,
},
},
+ transition: { onExited },
}}
>
<Box
@@ -100,12 +112,15 @@ export const ConfirmationActionSheet: React.FC<
label={confirmLabel}
backgroundColor={dangerColor}
color="#FFFFFF"
+ disabled={confirmDisabled}
+ actionPhase={confirmActionPhase}
onClick={onConfirm}
/>
<SheetButton
label={cancelLabel}
backgroundColor={isDark ? "#333333" : "#F2F2F2"}
color={isDark ? "#D8D8D8" : "#666666"}
+ disabled={cancelDisabled}
onClick={onCancel}
/>
</Box>
@@ -116,6 +131,8 @@ export const ConfirmationActionSheet: React.FC<
interface SheetButtonProps {
backgroundColor: string;
color: string;
+ actionPhase?: SocialActionPhase | null;
+ disabled?: boolean;
label: string;
onClick: () => void;
}
@@ -123,12 +140,16 @@ interface SheetButtonProps {
const SheetButton: React.FC<SheetButtonProps> = ({
backgroundColor,
color,
+ actionPhase = null,
+ disabled = false,
label,
onClick,
}) => (
<Box
component="button"
type="button"
+ aria-label={label}
+ disabled={disabled}
onClick={onClick}
sx={{
alignItems: "center",
@@ -136,7 +157,7 @@ const SheetButton: React.FC<SheetButtonProps> = ({
border: 0,
borderRadius: "20px",
color,
- cursor: "pointer",
+ cursor: disabled ? "default" : "pointer",
display: "flex",
fontFamily: '"Inter Variable", Inter, sans-serif',
fontSize: 14,
@@ -148,14 +169,15 @@ const SheetButton: React.FC<SheetButtonProps> = ({
py: "14px",
transition: "filter 120ms ease, opacity 120ms ease",
width: "100%",
- "&:active": { filter: "brightness(0.96)" },
+ "&:active": disabled ? undefined : { filter: "brightness(0.96)" },
+ "&:disabled": { opacity: 1 },
"&:focus-visible": {
outline: `2px solid ${green}`,
outlineOffset: 2,
},
- "&:hover": { filter: "brightness(0.98)" },
+ "&:hover": disabled ? undefined : { filter: "brightness(0.98)" },
}}
>
- {label}
+ {actionPhase ? <SocialActionFeedbackIcon phase={actionPhase} /> : label}
</Box>
);
diff --git a/web/apps/social/src/components/SocialActionFeedback.tsx b/web/apps/social/src/components/SocialActionFeedback.tsx
new file mode 100644
index 0000000000..af34ca735e
--- /dev/null
+++ b/web/apps/social/src/components/SocialActionFeedback.tsx
@@ -0,0 +1,96 @@
+import { Loading03Icon, Tick02Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { Box } from "@mui/material";
+import { keyframes } from "@mui/material/styles";
+import React from "react";
+
+export const socialActionBusyDurationMs = 2000;
+export const socialActionDoneDurationMs = 2400;
+export const socialActionTransition = "220ms cubic-bezier(0.4, 0, 0.2, 1)";
+
+export type SocialActionPhase = "busy" | "done";
+
+const socialActionSpin = keyframes`
+ from {
+ transform: rotate(0deg);
+ }
+
+ to {
+ transform: rotate(360deg);
+ }
+`;
+
+interface SocialActionFeedbackIconProps {
+ idleIcon?: React.ReactNode;
+ phase: SocialActionPhase | null;
+}
+
+export const SocialActionFeedbackIcon: React.FC<
+ SocialActionFeedbackIconProps
+> = ({ idleIcon, phase }) => (
+ <Box
+ component="span"
+ sx={{
+ display: "grid",
+ height: 18,
+ lineHeight: 0,
+ placeItems: "center",
+ width: 18,
+ }}
+ >
+ {idleIcon && (
+ <Box
+ component="span"
+ sx={{
+ display: "flex",
+ gridArea: "1 / 1",
+ lineHeight: 0,
+ opacity: phase == null ? 1 : 0,
+ transform: phase == null ? "scale(1)" : "scale(0.82)",
+ transition: `opacity ${socialActionTransition}, transform ${socialActionTransition}`,
+ }}
+ >
+ {idleIcon}
+ </Box>
+ )}
+ <Box
+ component="span"
+ sx={{
+ display: "flex",
+ gridArea: "1 / 1",
+ lineHeight: 0,
+ opacity: phase == "busy" ? 1 : 0,
+ transform: phase == "busy" ? "scale(1)" : "scale(0.82)",
+ transition: `opacity ${socialActionTransition}, transform ${socialActionTransition}`,
+ }}
+ >
+ <Box
+ component="span"
+ sx={{
+ animation: `${socialActionSpin} 2.4s linear infinite`,
+ display: "flex",
+ lineHeight: 0,
+ }}
+ >
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ size={22}
+ strokeWidth={1.8}
+ />
+ </Box>
+ </Box>
+ <Box
+ component="span"
+ sx={{
+ display: "flex",
+ gridArea: "1 / 1",
+ lineHeight: 0,
+ opacity: phase == "done" ? 1 : 0,
+ transform: phase == "done" ? "scale(1)" : "scale(0.82)",
+ transition: `opacity ${socialActionTransition}, transform ${socialActionTransition}`,
+ }}
+ >
+ <HugeiconsIcon icon={Tick02Icon} size={22} strokeWidth={1.8} />
+ </Box>
+ </Box>
+);
diff --git a/web/apps/social/src/components/SocialFileViewer.tsx b/web/apps/social/src/components/SocialFileViewer.tsx
index 2db3d7bc65..8f4724740c 100644
--- a/web/apps/social/src/components/SocialFileViewer.tsx
+++ b/web/apps/social/src/components/SocialFileViewer.tsx
@@ -6,6 +6,11 @@ import {
import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Menu, MenuItem } from "@mui/material";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
+import {
+ socialActionBusyDurationMs,
+ socialActionDoneDurationMs,
+ type SocialActionPhase,
+} from "components/SocialActionFeedback";
import type PhotoSwipe from "photoswipe";
import React from "react";
import {
@@ -28,6 +33,8 @@ const viewerHeaderHeight = 56;
const viewerBottomPadding = 0;
const defaultPhotoWidth = 900;
const defaultPhotoHeight = 680;
+const viewerExitDurationMs = 200;
+const viewerExitTransition = `${viewerExitDurationMs}ms cubic-bezier(0.4, 0, 0.2, 1)`;
export interface SocialViewerPhoto {
alt?: string;
@@ -60,22 +67,67 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
const [actionsAnchor, setActionsAnchor] =
React.useState<HTMLElement | null>(null);
const [deleteSheetOpen, setDeleteSheetOpen] = React.useState(false);
+ const [deleteActionPhase, setDeleteActionPhase] =
+ React.useState<SocialActionPhase | null>(null);
+ const [isDeleteExit, setIsDeleteExit] = React.useState(false);
const actionsMenuID = "social-viewer-actions-menu";
const actionsButtonID = "social-viewer-actions-button";
const isActionsOpen = Boolean(actionsAnchor);
+ const isDeleteActionRunning = deleteActionPhase != null;
const closeActions = () => setActionsAnchor(null);
const requestDeletePost = () => {
+ if (isDeleteActionRunning || isDeleteExit) return;
closeActions();
setDeleteSheetOpen(true);
};
- const confirmDeletePost = () => {
+ const closeDeleteSheet = () => {
+ if (isDeleteActionRunning || isDeleteExit) return;
setDeleteSheetOpen(false);
- onDeletePost?.();
};
+ const confirmDeletePost = () => {
+ if (isDeleteActionRunning || isDeleteExit) return;
+ setDeleteActionPhase("busy");
+ };
+
+ React.useEffect(() => {
+ if (!deleteActionPhase) return;
+
+ const timeoutID = window.setTimeout(
+ () => {
+ if (deleteActionPhase == "busy") {
+ setDeleteActionPhase("done");
+ return;
+ }
+
+ setDeleteSheetOpen(false);
+ onDeletePost?.();
+ setIsDeleteExit(true);
+ },
+ deleteActionPhase == "busy"
+ ? socialActionBusyDurationMs
+ : socialActionDoneDurationMs,
+ );
+
+ return () => window.clearTimeout(timeoutID);
+ }, [deleteActionPhase, onDeletePost]);
+
+ const handleDeleteSheetExited = () => {
+ if (!isDeleteExit) return;
+
+ setDeleteActionPhase(null);
+ };
+
+ React.useEffect(() => {
+ if (!isDeleteExit) return;
+
+ const timeoutID = window.setTimeout(onClose, viewerExitDurationMs);
+ return () => window.clearTimeout(timeoutID);
+ }, [isDeleteExit, onClose]);
+
React.useEffect(() => {
const root = viewerRootRef.current;
if (!root) return;
@@ -185,8 +237,11 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
inset: 0,
isolation: "isolate",
minHeight: "100svh",
+ opacity: isDeleteExit ? 0 : 1,
overflow: "hidden",
+ pointerEvents: isDeleteExit ? "none" : "auto",
position: "fixed",
+ transition: `opacity ${viewerExitTransition}`,
width: "100vw",
zIndex: 1300,
}}
@@ -544,8 +599,12 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
open={deleteSheetOpen}
title="Are you sure you want to delete this?"
confirmLabel="Yes, delete"
- onCancel={() => setDeleteSheetOpen(false)}
+ confirmActionPhase={deleteActionPhase}
+ confirmDisabled={isDeleteActionRunning}
+ cancelDisabled={isDeleteActionRunning}
+ onCancel={closeDeleteSheet}
onConfirm={confirmDeletePost}
+ onExited={handleDeleteSheetExited}
/>
)}
</Box>
diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsx
index fb475fa138..f219ed3106 100644
--- a/web/apps/social/src/pages/index.tsx
+++ b/web/apps/social/src/pages/index.tsx
@@ -269,7 +269,7 @@ const Page: React.FC = () => {
setProfile(null);
setSelectedFriendID(null);
setFriends(sampleFriends);
- setScreen("login");
+ setScreen("onboarding");
}}
/>
)}
diff --git a/web/apps/social/src/screens/HomeScreen.tsx b/web/apps/social/src/screens/HomeScreen.tsx
index 1ea4ac9292..be57e57684 100644
--- a/web/apps/social/src/screens/HomeScreen.tsx
+++ b/web/apps/social/src/screens/HomeScreen.tsx
@@ -1,10 +1,11 @@
-import {
- Loading03Icon,
- Tick02Icon,
-} from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
import { Box } from "@mui/material";
-import { keyframes } from "@mui/material/styles";
+import {
+ SocialActionFeedbackIcon,
+ socialActionBusyDurationMs,
+ socialActionDoneDurationMs,
+ socialActionTransition,
+ type SocialActionPhase,
+} from "components/SocialActionFeedback";
import {
SocialFileViewer,
type SocialViewerPhoto,
@@ -25,19 +26,6 @@ const minutesAgo = (minutes: number) => Date.now() - minutes * 60 * 1000;
const hoursAgo = (hours: number) => minutesAgo(hours * 60);
const daysAgo = (days: number) => hoursAgo(days * 24);
const sampleFeedPhotoAspectRatio = 900 / 680;
-const postActionPostingDurationMs = 2000;
-const postActionPostedDurationMs = 2400;
-const postActionTransition = "220ms cubic-bezier(0.4, 0, 0.2, 1)";
-const postActionSpin = keyframes`
- from {
- transform: rotate(0deg);
- }
-
- to {
- transform: rotate(360deg);
- }
-`;
-
type PostActionPhase = "posting" | "posted";
const sampleFeedItems = [
@@ -331,6 +319,12 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
const selectedPhotoFriendID = selectedPhoto?.friendID;
const isPostActionPosting = postActionPhase == "posting";
const isPostActionPosted = postActionPhase == "posted";
+ const postActionFeedbackPhase: SocialActionPhase | null =
+ postActionPhase == "posting"
+ ? "busy"
+ : postActionPhase == "posted"
+ ? "done"
+ : null;
const initialsSource = profile.fullName.trim() || profile.username.trim();
const initials = initialsSource
.split(/\s+/)
@@ -358,8 +352,8 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
postActionPhase == "posting" ? "posted" : null,
),
postActionPhase == "posting"
- ? postActionPostingDurationMs
- : postActionPostedDurationMs,
+ ? socialActionBusyDurationMs
+ : socialActionDoneDurationMs,
);
return () => window.clearTimeout(timeoutID);
}, [postActionPhase]);
@@ -422,16 +416,14 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
border: 0,
color: isPostActionPosted ? green : textBase,
cursor:
- postActionPhase == null
- ? "pointer"
- : "default",
+ postActionPhase == null ? "pointer" : "default",
display: "flex",
height: 24,
justifyContent: "flex-start",
opacity: 1,
p: 0,
width: 24,
- transition: `color ${postActionTransition}`,
+ transition: `color ${socialActionTransition}`,
"&:focus-visible": {
borderRadius: "50%",
outline: `2px solid ${green}`,
@@ -439,75 +431,10 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
},
}}
>
- <Box
- component="span"
- sx={{
- display: "grid",
- height: 18,
- placeItems: "center",
- width: 18,
- }}
- >
- <Box
- component="span"
- sx={{
- display: "flex",
- gridArea: "1 / 1",
- opacity: postActionPhase == null ? 1 : 0,
- transform:
- postActionPhase == null
- ? "scale(1)"
- : "scale(0.82)",
- transition: `opacity ${postActionTransition}, transform ${postActionTransition}`,
- }}
- >
- <PlusIcon />
- </Box>
- <Box
- component="span"
- sx={{
- display: "flex",
- gridArea: "1 / 1",
- opacity: isPostActionPosting ? 1 : 0,
- transform: isPostActionPosting
- ? "scale(1)"
- : "scale(0.82)",
- transition: `opacity ${postActionTransition}, transform ${postActionTransition}`,
- }}
- >
- <Box
- component="span"
- sx={{
- animation: `${postActionSpin} 2.4s linear infinite`,
- display: "flex",
- }}
- >
- <HugeiconsIcon
- icon={Loading03Icon}
- size={22}
- strokeWidth={1.8}
- />
- </Box>
- </Box>
- <Box
- component="span"
- sx={{
- display: "flex",
- gridArea: "1 / 1",
- opacity: isPostActionPosted ? 1 : 0,
- transform: isPostActionPosted
- ? "scale(1)"
- : "scale(0.82)",
- transition: `opacity ${postActionTransition}, transform ${postActionTransition}`,
- }}
- >
- <HugeiconsIcon
- icon={Tick02Icon}
- size={22}
- strokeWidth={1.8}
- />
- </Box>
- </Box>
+ <SocialActionFeedbackIcon
+ idleIcon={<PlusIcon />}
+ phase={postActionFeedbackPhase}
+ />
</Box>
<Box
sx={{
diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsx
index ac6c0e7963..6e324a5fb4 100644
--- a/web/apps/social/src/screens/ProfileScreen.tsx
+++ b/web/apps/social/src/screens/ProfileScreen.tsx
@@ -231,7 +231,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
nextPostIDs.add(selectedPost.id);
return nextPostIDs;
});
- setSelectedPost(null);
};
return (