Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(CollectionSelector):added-pinned-favorite-icons

Aswin Asok41f7013a2111
diff --git a/web/apps/photos/src/components/Collections/AllAlbums.tsx b/web/apps/photos/src/components/Collections/AllAlbums.tsx
index 02723324b8..c7ed2f852e 100644
--- a/web/apps/photos/src/components/Collections/AllAlbums.tsx
+++ b/web/apps/photos/src/components/Collections/AllAlbums.tsx
@@ -1,6 +1,8 @@
// TODO: Audit this file.
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
import CloseIcon from "@mui/icons-material/Close";
+import FavoriteIcon from "@mui/icons-material/Favorite";
+import PushPinIcon from "@mui/icons-material/PushPin";
import SearchIcon from "@mui/icons-material/Search";
import {
Box,
@@ -14,6 +16,7 @@ import {
Stack,
styled,
TextField,
+ Tooltip,
Typography,
useMediaQuery,
} from "@mui/material";
@@ -573,18 +576,54 @@ const AlbumCard: React.FC<AlbumCardProps> = ({
onCollectionClick,
collectionSummary,
isScrolling,
-}) => (
- <ItemCard
- TileComponent={LargeTileButton}
- coverFile={collectionSummary.coverFile}
- onClick={() => onCollectionClick(collectionSummary.id)}
- isScrolling={isScrolling}
- >
- <LargeTileTextOverlay>
- <Typography>{collectionSummary.name}</Typography>
- <Typography variant="small" sx={{ opacity: 0.7 }}>
- {t("photos_count", { count: collectionSummary.fileCount })}
- </Typography>
- </LargeTileTextOverlay>
- </ItemCard>
-);
+}) => {
+ const isFavorite = collectionSummary.type === "userFavorites";
+ const isPinned = collectionSummary.attributes.has("pinned");
+
+ return (
+ <ItemCard
+ TileComponent={LargeTileButton}
+ coverFile={collectionSummary.coverFile}
+ onClick={() => onCollectionClick(collectionSummary.id)}
+ isScrolling={isScrolling}
+ >
+ <LargeTileTextOverlay>
+ <Tooltip title={collectionSummary.name} arrow>
+ <Typography
+ sx={{
+ maxWidth: "130px",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {collectionSummary.name}
+ </Typography>
+ </Tooltip>
+ <Typography variant="small" sx={{ opacity: 0.7 }}>
+ {t("photos_count", { count: collectionSummary.fileCount })}
+ </Typography>
+ </LargeTileTextOverlay>
+ {(isFavorite || isPinned) && (
+ <Box
+ sx={{
+ position: "absolute",
+ bottom: 8,
+ right: 8,
+ display: "flex",
+ gap: 0.5,
+ }}
+ >
+ {isFavorite && (
+ <FavoriteIcon
+ sx={{ fontSize: 20, color: "white" }}
+ />
+ )}
+ {isPinned && (
+ <PushPinIcon sx={{ fontSize: 20, color: "white" }} />
+ )}
+ </Box>
+ )}
+ </ItemCard>
+ );
+};
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index b36089d0bd..092b3f1f3f 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -1,4 +1,6 @@
import CloseIcon from "@mui/icons-material/Close";
+import FavoriteIcon from "@mui/icons-material/Favorite";
+import PushPinIcon from "@mui/icons-material/PushPin";
import SearchIcon from "@mui/icons-material/Search";
import {
Box,
@@ -10,6 +12,7 @@ import {
Stack,
styled,
TextField,
+ Tooltip,
Typography,
useMediaQuery,
} from "@mui/material";
@@ -358,17 +361,53 @@ interface CollectionSummaryButtonProps {
const CollectionSummaryButton: React.FC<CollectionSummaryButtonProps> = ({
collectionSummary,
onClick,
-}) => (
- <ItemCard
- TileComponent={LargeTileButton}
- coverFile={collectionSummary.coverFile}
- onClick={() => onClick(collectionSummary.id)}
- >
- <LargeTileTextOverlay>
- <Typography>{collectionSummary.name}</Typography>
- </LargeTileTextOverlay>
- </ItemCard>
-);
+}) => {
+ const isFavorite = collectionSummary.type === "userFavorites";
+ const isPinned = collectionSummary.attributes.has("pinned");
+
+ return (
+ <ItemCard
+ TileComponent={LargeTileButton}
+ coverFile={collectionSummary.coverFile}
+ onClick={() => onClick(collectionSummary.id)}
+ >
+ <LargeTileTextOverlay>
+ <Tooltip title={collectionSummary.name} arrow>
+ <Typography
+ sx={{
+ maxWidth: "240px",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
+ {collectionSummary.name}
+ </Typography>
+ </Tooltip>
+ </LargeTileTextOverlay>
+ {(isFavorite || isPinned) && (
+ <Box
+ sx={{
+ position: "absolute",
+ bottom: 8,
+ right: 8,
+ display: "flex",
+ gap: 0.5,
+ }}
+ >
+ {isFavorite && (
+ <FavoriteIcon
+ sx={{ fontSize: 20, color: "white" }}
+ />
+ )}
+ {isPinned && (
+ <PushPinIcon sx={{ fontSize: 20, color: "white" }} />
+ )}
+ </Box>
+ )}
+ </ItemCard>
+ );
+};
interface SearchFieldProps {
value: string;