Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refine Space likes and notifications UI

Anand Baburajan2b801a7a3388
diff --git a/web/apps/space/src/components/SpaceFileViewer.tsx b/web/apps/space/src/components/SpaceFileViewer.tsx
index 5845b81c81..d6d3281dd2 100644
--- a/web/apps/space/src/components/SpaceFileViewer.tsx
+++ b/web/apps/space/src/components/SpaceFileViewer.tsx
@@ -1755,12 +1755,12 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
fontSize: 14,
fontWeight: 750,
height: 48,
+ gap: "5px",
justifyContent: "center",
lineHeight: "20px",
- position: "relative",
- width: 48,
+ minWidth: 48,
p: 0,
- py: 0,
+ px: "2px",
"&:disabled": { opacity: 1 },
"&:focus-visible": {
outline: `2px solid ${green}`,
@@ -1783,30 +1783,20 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
fill="none"
icon={FavouriteIcon}
primaryColor="currentColor"
- size={30}
+ size={24}
strokeWidth={1.8}
/>
</Box>
<Box
component="span"
sx={{
- alignItems: "center",
- bgcolor: textBase,
- border: "2px solid #000000",
- borderRadius: "999px",
- color: "#111111",
- display: "flex",
+ color: "currentColor",
fontFamily:
'"Inter Variable", Inter, sans-serif',
- fontSize: 10,
- fontWeight: 800,
- height: 18,
- justifyContent: "center",
- lineHeight: "11px",
- width: 18,
- position: "absolute",
- right: 2,
- top: 8,
+ fontSize: 14,
+ fontWeight: 750,
+ lineHeight: "20px",
+ transform: "translateY(0.5px)",
}}
>
{activePhoto.likeCount ?? 0}
@@ -1830,6 +1820,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
)}
<SpacePostLikersDialog
errorMessage={postLikersError}
+ likeCount={activePhoto.likeCount ?? 0}
likers={postLikers}
loading={postLikersLoading}
open={postLikersOpen}
diff --git a/web/apps/space/src/components/SpacePostLikersDialog.tsx b/web/apps/space/src/components/SpacePostLikersDialog.tsx
index 997f1049f2..6a69d2fea8 100644
--- a/web/apps/space/src/components/SpacePostLikersDialog.tsx
+++ b/web/apps/space/src/components/SpacePostLikersDialog.tsx
@@ -5,12 +5,22 @@ import type { SpacePostLiker } from "services/space";
const textBase = "#F4F4F4";
const textSecondary = "#A6A6A6";
+const lightTextBase = "#000000";
+const lightTextSecondary = "#777777";
const dangerColor = "#F63A3A";
const sheetBackground = "#1E1E1E";
+const lightSheetBackground = "#F2F2F2";
const avatarBackground = "#333333";
+const lightAvatarBackground = "#E6E6E6";
+const skeletonFill = "#3A3A3A";
+const lightSkeletonFill = "#D7D7D7";
+const darkBackdropBackground = "rgba(0, 0, 0, 0.86)";
+const lightBackdropBackground = "rgba(255, 255, 255, 0.72)";
interface SpacePostLikersDialogProps {
+ appearance?: "dark" | "light";
errorMessage?: string | null;
+ likeCount: number;
likers: SpacePostLiker[];
loading: boolean;
open: boolean;
@@ -18,13 +28,24 @@ interface SpacePostLikersDialogProps {
}
export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
+ appearance = "dark",
errorMessage,
+ likeCount,
likers,
loading,
open,
onClose,
}) => {
const isBottomSheet = useMediaQuery("(max-width: 599px)");
+ const isLight = appearance == "light";
+ const panelBackground = isLight ? lightSheetBackground : sheetBackground;
+ const primaryText = isLight ? lightTextBase : textBase;
+ const secondaryText = isLight ? lightTextSecondary : textSecondary;
+ const avatarFill = isLight ? lightAvatarBackground : avatarBackground;
+ const loadingFill = isLight ? lightSkeletonFill : skeletonFill;
+ const backdropBackground = isLight
+ ? lightBackdropBackground
+ : darkBackdropBackground;
return (
<Dialog
@@ -40,19 +61,20 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
sx={{
zIndex: 1500,
"& .MuiBackdrop-root": {
- backgroundColor: "rgba(0, 0, 0, 0.86) !important",
+ backgroundColor: `${backdropBackground} !important`,
},
"& .MuiDialog-container": { backgroundColor: "transparent" },
"& .MuiPaper-root": {
- backgroundColor: `${sheetBackground} !important`,
+ backgroundColor: `${panelBackground} !important`,
},
}}
slotProps={{
- backdrop: { sx: { backgroundColor: "rgba(0, 0, 0, 0.86)" } },
+ backdrop: { sx: { backgroundColor: backdropBackground } },
paper: {
sx: {
- bgcolor: sheetBackground,
- backgroundColor: sheetBackground,
+ bgcolor: panelBackground,
+ backgroundColor: panelBackground,
+ border: 0,
borderRadius: "28px 28px 0 0",
bottom: 0,
boxShadow: "none",
@@ -80,7 +102,12 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
>
<Box sx={{ width: "100%" }}>
<Box sx={{ maxHeight: "min(420px, 62vh)", overflowY: "auto" }}>
- {loading ? null : errorMessage ? (
+ {loading ? (
+ <SpacePostLikerSkeletonRows
+ rowCount={likeCount}
+ skeletonFill={loadingFill}
+ />
+ ) : errorMessage ? (
<Box
role="alert"
sx={{
@@ -99,7 +126,7 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
) : likers.length == 0 ? (
<Box
sx={{
- color: textSecondary,
+ color: secondaryText,
fontFamily:
'"Inter Variable", Inter, sans-serif',
fontSize: 14,
@@ -126,7 +153,9 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
{likers.map((liker) => (
<SpacePostLikerRow
key={`${liker.profile.id}:${liker.createdAtMs}`}
+ avatarFill={avatarFill}
liker={liker}
+ textColor={primaryText}
/>
))}
</Box>
@@ -137,7 +166,70 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
);
};
-const SpacePostLikerRow: React.FC<{ liker: SpacePostLiker }> = ({ liker }) => {
+const SpacePostLikerSkeletonRows: React.FC<{
+ rowCount: number;
+ skeletonFill: string;
+}> = ({ rowCount, skeletonFill }) => (
+ <Box
+ component="ul"
+ sx={{
+ display: "flex",
+ flexDirection: "column",
+ gap: "8px",
+ listStyle: "none",
+ m: 0,
+ p: 0,
+ }}
+ >
+ {Array.from({ length: rowCount }, (_, index) => (
+ <Box
+ component="li"
+ key={index}
+ sx={{
+ alignItems: "center",
+ display: "grid",
+ gap: "8px",
+ gridTemplateColumns: "32px minmax(0, 1fr) 24px",
+ minHeight: 42,
+ py: "4px",
+ }}
+ >
+ <Box
+ sx={{
+ bgcolor: skeletonFill,
+ borderRadius: "50%",
+ height: 32,
+ width: 32,
+ }}
+ />
+ <Box
+ sx={{
+ bgcolor: skeletonFill,
+ borderRadius: "999px",
+ height: 12,
+ opacity: 0.9,
+ width: "42%",
+ }}
+ />
+ <Box
+ sx={{
+ bgcolor: skeletonFill,
+ borderRadius: "50%",
+ height: 18,
+ justifySelf: "center",
+ width: 18,
+ }}
+ />
+ </Box>
+ ))}
+ </Box>
+);
+
+const SpacePostLikerRow: React.FC<{
+ avatarFill: string;
+ liker: SpacePostLiker;
+ textColor: string;
+}> = ({ avatarFill, liker, textColor }) => {
const profile = liker.profile;
const displayName =
profile.fullName.trim() || profile.username.trim() || "Someone";
@@ -156,7 +248,7 @@ const SpacePostLikerRow: React.FC<{ liker: SpacePostLiker }> = ({ liker }) => {
>
<Box
sx={{
- bgcolor: avatarBackground,
+ bgcolor: avatarFill,
borderRadius: "50%",
height: 32,
overflow: "hidden",
@@ -180,7 +272,7 @@ const SpacePostLikerRow: React.FC<{ liker: SpacePostLiker }> = ({ liker }) => {
</Box>
<Box
sx={{
- color: textBase,
+ color: textColor,
fontFamily: '"Inter Variable", Inter, sans-serif',
fontSize: 15,
fontWeight: 650,
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 5167fa7f72..487a8b908b 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -21,6 +21,7 @@ import {
spacePostLikePopDurationMs,
spacePostLikePopTiming,
} from "components/SpacePostLikeAnimation";
+import { SpacePostLikersDialog } from "components/SpacePostLikersDialog";
import { SpaceLoadingSpinner } from "components/SpaceRouteFallback";
import { EnteLogo } from "ente-base/components/EnteLogo";
import { useBrowserBackClose } from "hooks/useBrowserBackClose";
@@ -31,6 +32,7 @@ import type {
SpacePost,
SpacePostAssetURLLoader,
SpacePostAvatarURLLoader,
+ SpacePostLiker,
SpacePostLikersLoader,
} from "services/space";
import type { LocalSpaceFeedPost } from "state/spaceAppState";
@@ -184,6 +186,7 @@ interface FeedItemProps {
name: string;
onLoadAvatar?: () => Promise<string | null | undefined>;
onLoadImage?: () => Promise<string | undefined>;
+ onLoadPostLikers?: SpacePostLikersLoader;
onOpenFriend?: (friendID: string) => void;
onOpenPhoto?: (photo: SpaceViewerPhoto, focusReplyOnOpen?: boolean) => void;
onOpenProfile?: () => void;
@@ -628,6 +631,7 @@ const FeedItem: React.FC<FeedItemProps> = ({
name,
onLoadAvatar,
onLoadImage,
+ onLoadPostLikers,
onOpenFriend,
onOpenPhoto,
onOpenProfile,
@@ -647,7 +651,8 @@ const FeedItem: React.FC<FeedItemProps> = ({
const dateLabel = formatSpaceDate(timestampMs);
const postingDotCount = usePostingDotCount(timestampStatus == "posting");
const displayCaption = caption?.trim();
- const showFooter = !isOwnPost || Boolean(displayCaption);
+ const showOwnPostLikeButton = isOwnPost && postId > 0;
+ const showFooter = !isOwnPost || Boolean(displayCaption) || showOwnPostLikeButton;
const canOpenAuthor = isOwnPost
? Boolean(onOpenProfile)
: Boolean(onOpenFriend);
@@ -1094,12 +1099,12 @@ const FeedItem: React.FC<FeedItemProps> = ({
display: "grid",
gap: "8px",
gridTemplateColumns: isOwnPost
- ? "minmax(0, 1fr)"
+ ? "minmax(0, 1fr) auto"
: "minmax(0, 1fr) auto",
minHeight: feedLikeActionSize,
mt: "8px",
pl: "9px",
- pr: isOwnPost ? "9px" : 0,
+ pr: isOwnPost ? "3px" : 0,
width: "100%",
}}
>
@@ -1182,12 +1187,146 @@ const FeedItem: React.FC<FeedItemProps> = ({
/>
</Box>
)}
+ {showOwnPostLikeButton && (
+ <FeedOwnPostLikeButton
+ likeCount={likeCount}
+ onLoadPostLikers={onLoadPostLikers}
+ postId={postId}
+ />
+ )}
</Box>
)}
</Box>
);
};
+const FeedOwnPostLikeButton: React.FC<{
+ likeCount: number;
+ onLoadPostLikers?: SpacePostLikersLoader;
+ postId: number;
+}> = ({ likeCount, onLoadPostLikers, postId }) => {
+ const [postLikersOpen, setPostLikersOpen] = React.useState(false);
+ const [postLikersLoading, setPostLikersLoading] = React.useState(false);
+ const [postLikersError, setPostLikersError] = React.useState<string | null>(
+ null,
+ );
+ const [postLikers, setPostLikers] = React.useState<SpacePostLiker[]>([]);
+ const postLikersRequestIDRef = React.useRef(0);
+
+ const openPostLikers = () => {
+ if (!onLoadPostLikers) return;
+
+ const requestID = postLikersRequestIDRef.current + 1;
+ postLikersRequestIDRef.current = requestID;
+ setPostLikersOpen(true);
+ setPostLikersLoading(true);
+ setPostLikersError(null);
+
+ void onLoadPostLikers(postId)
+ .then((likers) => {
+ if (postLikersRequestIDRef.current == requestID) {
+ setPostLikers(likers);
+ }
+ })
+ .catch((error: unknown) => {
+ console.error("Failed to load post likers", error);
+ if (postLikersRequestIDRef.current == requestID) {
+ setPostLikers([]);
+ setPostLikersError(
+ "Couldn't load likes. Please try again.",
+ );
+ }
+ })
+ .finally(() => {
+ if (postLikersRequestIDRef.current == requestID) {
+ setPostLikersLoading(false);
+ }
+ });
+ };
+
+ const closePostLikers = () => {
+ postLikersRequestIDRef.current += 1;
+ setPostLikersOpen(false);
+ setPostLikersLoading(false);
+ };
+
+ React.useEffect(() => {
+ postLikersRequestIDRef.current += 1;
+ setPostLikers([]);
+ setPostLikersError(null);
+ setPostLikersLoading(false);
+ setPostLikersOpen(false);
+ }, [postId]);
+
+ return (
+ <>
+ <Box
+ component="button"
+ type="button"
+ aria-label={`View ${likeCount} likes`}
+ disabled={!onLoadPostLikers}
+ onClick={openPostLikers}
+ sx={{
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: "transparent",
+ border: 0,
+ borderRadius: "8px",
+ color: textBase,
+ cursor: onLoadPostLikers ? "pointer" : "default",
+ display: "inline-flex",
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 750,
+ gap: "4px",
+ height: feedLikeActionSize,
+ justifyContent: "center",
+ justifySelf: "flex-end",
+ lineHeight: "18px",
+ minWidth: feedLikeActionSize,
+ px: "6px",
+ "&:disabled": { opacity: 1 },
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ }}
+ >
+ <Box
+ component="span"
+ sx={{ alignItems: "center", display: "flex", lineHeight: 0 }}
+ >
+ <HugeiconsIcon
+ fill="none"
+ icon={FavouriteIcon}
+ primaryColor="currentColor"
+ size={feedActionIconSize}
+ strokeWidth={2}
+ />
+ </Box>
+ <Box
+ component="span"
+ sx={{
+ color: "currentColor",
+ transform: "translateY(0.5px)",
+ }}
+ >
+ {likeCount}
+ </Box>
+ </Box>
+ <SpacePostLikersDialog
+ appearance="light"
+ errorMessage={postLikersError}
+ likeCount={likeCount}
+ likers={postLikers}
+ loading={postLikersLoading}
+ open={postLikersOpen}
+ onClose={closePostLikers}
+ />
+ </>
+ );
+};
+
const AddedFriendToast: React.FC<AddedFriendToastProps> = ({
name,
onClose,
@@ -1527,6 +1666,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
onLoadImage={
imageUrl ? undefined : () => loadFeedPostImage(item)
}
+ onLoadPostLikers={onLoadPostLikers}
onOpenFriend={onOpenFriend}
onOpenPhoto={openFeedPhoto}
onOpenProfile={onOpenProfile}
diff --git a/web/apps/space/src/screens/NotificationsScreen.tsx b/web/apps/space/src/screens/NotificationsScreen.tsx
index 379fa1f627..e01fd26ce9 100644
--- a/web/apps/space/src/screens/NotificationsScreen.tsx
+++ b/web/apps/space/src/screens/NotificationsScreen.tsx
@@ -15,7 +15,6 @@ const green = "#08C225";
const avatarSkeletonBackground = "#E6E6E6";
const textBase = "#000000";
const textSecondary = "#777777";
-const rowHover = "#F6F6F6";
const dayMs = 24 * 60 * 60 * 1000;
const microsForTimestamp = (timestampMs: number) => timestampMs * 1000;
@@ -317,7 +316,6 @@ const NotificationRow: React.FC<{
outline: `2px solid ${green}`,
outlineOffset: 2,
},
- "&:hover": { bgcolor: rowHover },
}}
>
<AvatarStack actors={avatarActors} />