Skip to content

armgit / ente

Public Imported from GitHub
0

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

Improve Space toast feedback

Anand Baburajan64ac6b10128f
diff --git a/web/apps/space/src/components/ActionToast.tsx b/web/apps/space/src/components/ActionToast.tsx
index 90b8387746..6572eec046 100644
--- a/web/apps/space/src/components/ActionToast.tsx
+++ b/web/apps/space/src/components/ActionToast.tsx
@@ -8,7 +8,8 @@ import { spaceTouchTargetSize } from "styles/touch-targets";
const green = "#08C225";
const textBase = spaceText;
-const toastHorizontalPadding = "16px";
+const toastHorizontalPadding = "12px";
+export const spaceToastAutoDismissDurationMs = 2400;
const toastEnter = keyframes`
from {
opacity: 0;
@@ -24,6 +25,7 @@ const toastEnter = keyframes`
interface SpaceActionToastProps {
action?: React.ReactNode;
animateEntrance?: boolean;
+ autoDismissAfterMs?: number;
closeLabel: string;
icon: React.ReactNode;
message: React.ReactNode;
@@ -34,122 +36,132 @@ interface SpaceActionToastProps {
export const SpaceActionToast: React.FC<SpaceActionToastProps> = ({
action,
animateEntrance = false,
+ autoDismissAfterMs,
closeLabel,
icon,
message,
onClose,
zIndex = 20,
-}) => (
- <Box
- sx={{
- animation: animateEntrance
- ? `${toastEnter} 320ms cubic-bezier(0.22, 1, 0.36, 1) both`
- : undefined,
- boxSizing: "border-box",
- left: "50%",
- px: toastHorizontalPadding,
- pointerEvents: "none",
- position: "fixed",
- top: "calc(env(safe-area-inset-top) + 10px)",
- transform: "translateX(-50%)",
- width: "100%",
- zIndex,
- "@media (min-width: 600px)": { maxWidth: 390 },
- "@media (prefers-reduced-motion: reduce)": {
- animation: animateEntrance ? "none" : undefined,
- },
- }}
- >
+}) => {
+ React.useEffect(() => {
+ if (autoDismissAfterMs === undefined || !onClose) return;
+
+ const timeoutID = window.setTimeout(onClose, autoDismissAfterMs);
+ return () => window.clearTimeout(timeoutID);
+ }, [autoDismissAfterMs, onClose]);
+
+ return (
<Box
- role="status"
- aria-live="polite"
sx={{
- alignItems: "center",
- bgcolor: spaceSurface,
- borderRadius: "18px",
- boxShadow: "0 12px 32px rgba(0, 0, 0, 0.18)",
+ animation: animateEntrance
+ ? `${toastEnter} 320ms cubic-bezier(0.22, 1, 0.36, 1) both`
+ : undefined,
boxSizing: "border-box",
- color: textBase,
- display: "flex",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 650,
- gap: "10px",
- lineHeight: "20px",
- minHeight: 50,
- pointerEvents: "auto",
- pl: "10px",
- pr: "6px",
- py: "3px",
+ left: "50%",
+ px: toastHorizontalPadding,
+ pointerEvents: "none",
+ position: "fixed",
+ top: "calc(env(safe-area-inset-top) + 10px)",
+ transform: "translateX(-50%)",
width: "100%",
+ zIndex,
+ "@media (min-width: 600px)": { maxWidth: 390 },
+ "@media (prefers-reduced-motion: reduce)": {
+ animation: animateEntrance ? "none" : undefined,
+ },
}}
>
<Box
- component="span"
- sx={{
- alignItems: "center",
- color: green,
- display: "flex",
- flexShrink: 0,
- height: 24,
- justifyContent: "center",
- width: 24,
- }}
- >
- {icon}
- </Box>
- <Box
- sx={{
- flex: "1 1 auto",
- minWidth: 0,
- overflow: "hidden",
- textOverflow: "ellipsis",
- whiteSpace: "nowrap",
- }}
- >
- {message}
- </Box>
- <Box
+ role="status"
+ aria-live="polite"
sx={{
alignItems: "center",
+ bgcolor: spaceSurface,
+ borderRadius: "18px",
+ boxShadow: "0 12px 32px rgba(0, 0, 0, 0.18)",
+ boxSizing: "border-box",
+ color: textBase,
display: "flex",
- flexShrink: 0,
- gap: 0,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 650,
+ gap: "10px",
+ lineHeight: "20px",
+ minHeight: 50,
+ pointerEvents: "auto",
+ pl: "10px",
+ pr: "6px",
+ py: "3px",
+ width: "100%",
}}
>
- {action}
<Box
- component="button"
- type="button"
- aria-label={closeLabel}
- onClick={onClose}
+ component="span"
sx={{
alignItems: "center",
- appearance: "none",
- bgcolor: "transparent",
- border: 0,
- color: textBase,
- cursor: onClose ? "pointer" : "default",
+ color: green,
display: "flex",
flexShrink: 0,
- height: spaceTouchTargetSize,
+ height: 24,
justifyContent: "center",
- opacity: 0.9,
- p: 0,
- width: 36,
- "&:focus-visible": {
- outline: "2px solid rgba(255 255 255 / 0.72)",
- outlineOffset: 2,
- },
+ width: 24,
+ }}
+ >
+ {icon}
+ </Box>
+ <Box
+ sx={{
+ flex: "1 1 auto",
+ minWidth: 0,
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {message}
+ </Box>
+ <Box
+ sx={{
+ alignItems: "center",
+ display: "flex",
+ flexShrink: 0,
+ gap: 0,
}}
>
- <HugeiconsIcon
- icon={MultiplicationSignIcon}
- size={16}
- strokeWidth={2}
- />
+ {action}
+ <Box
+ component="button"
+ type="button"
+ aria-label={closeLabel}
+ onClick={onClose}
+ sx={{
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: "transparent",
+ border: 0,
+ color: textBase,
+ cursor: onClose ? "pointer" : "default",
+ display: "flex",
+ flexShrink: 0,
+ height: spaceTouchTargetSize,
+ justifyContent: "center",
+ opacity: 0.9,
+ p: 0,
+ width: 36,
+ "&:focus-visible": {
+ outline: "2px solid rgba(255 255 255 / 0.72)",
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={MultiplicationSignIcon}
+ size={16}
+ strokeWidth={2}
+ />
+ </Box>
</Box>
</Box>
</Box>
- </Box>
-);
+ );
+};
diff --git a/web/apps/space/src/components/FriendRequestCanceledToast.tsx b/web/apps/space/src/components/FriendRequestCanceledToast.tsx
index 1e91d7aed9..760fc20a28 100644
--- a/web/apps/space/src/components/FriendRequestCanceledToast.tsx
+++ b/web/apps/space/src/components/FriendRequestCanceledToast.tsx
@@ -1,8 +1,13 @@
import { UserRemove01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { SpaceActionToast } from "components/ActionToast";
+import {
+ SpaceActionToast,
+ spaceToastAutoDismissDurationMs,
+} from "components/ActionToast";
import React from "react";
+const dangerColor = "#F63A3A";
+
interface SpaceFriendRequestCanceledToastProps {
onClose: () => void;
}
@@ -12,10 +17,11 @@ export const SpaceFriendRequestCanceledToast: React.FC<
> = ({ onClose }) => (
<SpaceActionToast
animateEntrance
+ autoDismissAfterMs={spaceToastAutoDismissDurationMs}
closeLabel="Dismiss canceled friend request"
icon={
<HugeiconsIcon
- color="#000000"
+ color={dangerColor}
icon={UserRemove01Icon}
size={20}
strokeWidth={2}
diff --git a/web/apps/space/src/components/MobileBestToast.tsx b/web/apps/space/src/components/MobileBestToast.tsx
index 0e0ed14e3f..d205b14ce1 100644
--- a/web/apps/space/src/components/MobileBestToast.tsx
+++ b/web/apps/space/src/components/MobileBestToast.tsx
@@ -43,7 +43,7 @@ export const SpaceMobileBestToast: React.FC = () => {
py: "4px",
right: "calc(env(safe-area-inset-right) + 24px)",
top: "calc(env(safe-area-inset-top) + 24px)",
- width: 336,
+ width: 366,
zIndex: 20,
}}
>
diff --git a/web/apps/space/src/components/PWAInstallPrompt.tsx b/web/apps/space/src/components/PWAInstallPrompt.tsx
index 16b3342226..69cf249b15 100644
--- a/web/apps/space/src/components/PWAInstallPrompt.tsx
+++ b/web/apps/space/src/components/PWAInstallPrompt.tsx
@@ -206,7 +206,7 @@ export const SpacePWAPromptBanner: React.FC<SpacePWAPromptBannerProps> = ({
: undefined,
boxSizing: "border-box",
left: "50%",
- px: "16px",
+ px: "12px",
pointerEvents: "none",
position: "fixed",
top:
diff --git a/web/apps/space/src/components/PostToast.tsx b/web/apps/space/src/components/PostToast.tsx
index 8594f171d6..d62f16319b 100644
--- a/web/apps/space/src/components/PostToast.tsx
+++ b/web/apps/space/src/components/PostToast.tsx
@@ -1,37 +1,45 @@
+import { AlertCircleIcon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
import { SpaceActionFeedbackIcon } from "components/ActionFeedback";
-import { SpaceActionToast } from "components/ActionToast";
+import {
+ SpaceActionToast,
+ spaceToastAutoDismissDurationMs,
+} from "components/ActionToast";
import React from "react";
import { useSpaceAppState } from "state/app-state";
-const postedToastDurationMs = 2400;
+const dangerColor = "#F63A3A";
export const SpacePostToast: React.FC = () => {
const { dismissPostPublishToast, postPublishPhase } = useSpaceAppState();
- React.useEffect(() => {
- if (postPublishPhase != "posted") return;
-
- const timeoutID = window.setTimeout(
- dismissPostPublishToast,
- postedToastDurationMs,
- );
- return () => window.clearTimeout(timeoutID);
- }, [dismissPostPublishToast, postPublishPhase]);
-
if (!postPublishPhase) return null;
const isPosting = postPublishPhase == "posting";
+ const isFailed = postPublishPhase == "failed";
return (
<SpaceActionToast
animateEntrance={isPosting}
+ autoDismissAfterMs={
+ isPosting ? undefined : spaceToastAutoDismissDurationMs
+ }
closeLabel="Dismiss post status"
icon={
- <SpaceActionFeedbackIcon
- phase={isPosting ? "busy" : "done"}
- size={20}
- />
+ isFailed ? (
+ <HugeiconsIcon
+ color={dangerColor}
+ icon={AlertCircleIcon}
+ size={20}
+ strokeWidth={1.8}
+ />
+ ) : (
+ <SpaceActionFeedbackIcon
+ phase={isPosting ? "busy" : "done"}
+ size={20}
+ />
+ )
}
- message={isPosting ? "Posting..." : "Posted"}
+ message={isPosting ? "Posting..." : isFailed ? "Failed" : "Posted"}
onClose={dismissPostPublishToast}
zIndex={1400}
/>
diff --git a/web/apps/space/src/components/PublicProfileNotificationControl.tsx b/web/apps/space/src/components/PublicProfileNotificationControl.tsx
index b6ad23e1bf..7d73208c4b 100644
--- a/web/apps/space/src/components/PublicProfileNotificationControl.tsx
+++ b/web/apps/space/src/components/PublicProfileNotificationControl.tsx
@@ -1,4 +1,5 @@
import { Notification02Icon, Tick02Icon } from "@hugeicons/core-free-icons";
+import { spaceToastAutoDismissDurationMs } from "components/ActionToast";
import { SpaceNotificationPermissionInstructions } from "components/NotificationPermissionInstructions";
import {
SpacePWAInstallInstructions,
@@ -22,7 +23,6 @@ import {
type SuccessState = "exiting" | "hidden" | "visible";
-const successDisplayDurationMs = 2400;
const toastTransitionDurationMs = 180;
interface SpacePublicProfileNotificationControlProps {
@@ -142,7 +142,7 @@ export const SpacePublicProfileNotificationControl: React.FC<
successTimer.current = undefined;
setSuccessState("hidden");
}, toastTransitionDurationMs);
- }, successDisplayDurationMs);
+ }, spaceToastAutoDismissDurationMs);
} else if (permission == "denied") {
setState("denied");
setPermissionInstructionsOpen(true);
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 3d2e5b3ff2..f2658632b4 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -1,10 +1,10 @@
-import {
- BubbleChatIcon,
- MultiplicationSignIcon,
- UserAdd02Icon,
-} from "@hugeicons/core-free-icons";
+import { BubbleChatIcon, UserAdd02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Skeleton } from "@mui/material";
+import {
+ SpaceActionToast,
+ spaceToastAutoDismissDurationMs,
+} from "components/ActionToast";
import { SpaceAvatarImage } from "components/AvatarImage";
import {
SpaceFileViewer,
@@ -30,7 +30,6 @@ import {
import {
spaceAppBackground,
spaceAppBackgroundColor,
- spaceSurface,
spaceText,
spaceTextMuted,
} from "styles/colors";
@@ -563,96 +562,15 @@ const AddedFriendToast: React.FC<AddedFriendToastProps> = ({
message,
onClose,
}) => (
- <Box
- sx={{
- boxSizing: "border-box",
- left: "50%",
- px: homeHorizontalPadding,
- pointerEvents: "none",
- position: "fixed",
- top: "calc(env(safe-area-inset-top) + 10px)",
- transform: "translateX(-50%)",
- width: "100%",
- zIndex: 20,
- "@media (min-width: 600px)": { maxWidth: 390 },
- }}
- >
- <Box
- role="status"
- aria-live="polite"
- sx={{
- alignItems: "center",
- bgcolor: spaceSurface,
- borderRadius: "18px",
- boxShadow: "0 12px 32px rgba(0, 0, 0, 0.18)",
- boxSizing: "border-box",
- color: textBase,
- display: "flex",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 650,
- gap: "10px",
- lineHeight: "20px",
- minHeight: 50,
- pointerEvents: "auto",
- pl: "16px",
- pr: "6px",
- py: "3px",
- width: "100%",
- }}
- >
- <Box component="span" sx={{ display: "flex", flexShrink: 0 }}>
- <HugeiconsIcon
- icon={UserAdd02Icon}
- size={20}
- strokeWidth={1.8}
- />
- </Box>
- <Box
- component="span"
- sx={{
- flex: "1 1 auto",
- minWidth: 0,
- overflow: "hidden",
- textOverflow: "ellipsis",
- whiteSpace: "nowrap",
- }}
- >
- {message}
- </Box>
- <Box
- component="button"
- type="button"
- aria-label="Close"
- onClick={onClose}
- sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: "transparent",
- border: 0,
- color: textBase,
- cursor: onClose ? "pointer" : "default",
- display: "flex",
- flexShrink: 0,
- height: spaceTouchTargetSize,
- justifyContent: "center",
- opacity: 0.9,
- p: 0,
- width: spaceTouchTargetSize,
- "&:focus-visible": {
- outline: "2px solid rgba(255 255 255 / 0.72)",
- outlineOffset: 2,
- },
- }}
- >
- <HugeiconsIcon
- icon={MultiplicationSignIcon}
- size={16}
- strokeWidth={2}
- />
- </Box>
- </Box>
- </Box>
+ <SpaceActionToast
+ autoDismissAfterMs={spaceToastAutoDismissDurationMs}
+ closeLabel="Dismiss friend request status"
+ icon={
+ <HugeiconsIcon icon={UserAdd02Icon} size={20} strokeWidth={1.8} />
+ }
+ message={message}
+ onClose={onClose}
+ />
);
export const HomeScreen: React.FC<HomeScreenProps> = ({
diff --git a/web/apps/space/src/state/AppStateProvider.tsx b/web/apps/space/src/state/AppStateProvider.tsx
index 78f61d9033..44725a0145 100644
--- a/web/apps/space/src/state/AppStateProvider.tsx
+++ b/web/apps/space/src/state/AppStateProvider.tsx
@@ -104,7 +104,7 @@ export const SpaceAppStateProvider: React.FC<React.PropsWithChildren> = ({
return post;
} catch (error) {
if (postPublishGenerationRef.current == generation) {
- setPostPublishPhase(null);
+ setPostPublishPhase("failed");
}
throw error;
}
diff --git a/web/apps/space/src/state/app-state.tsx b/web/apps/space/src/state/app-state.tsx
index 527e3dccd9..8e3ada11b4 100644
--- a/web/apps/space/src/state/app-state.tsx
+++ b/web/apps/space/src/state/app-state.tsx
@@ -12,7 +12,7 @@ import type { CreateProfileSource } from "utils/routes";
export type OnboardingEntrySource = "direct" | "add-friend-link";
export type SpaceProfileLoadStatus = "error" | "loading" | "ready";
-export type SpacePostPublishPhase = "posted" | "posting";
+export type SpacePostPublishPhase = "failed" | "posted" | "posting";
export type PendingCreateProfile = SetupProfileDetails & {
source: CreateProfileSource;
};