Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Refresh map photo panel design

AswinAsoke69795392071
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsx
index d91dfd2e7a..91b2eedf43 100644
--- a/web/apps/photos/src/components/FileList.tsx
+++ b/web/apps/photos/src/components/FileList.tsx
@@ -102,6 +102,7 @@ export interface FileListProps {
height: number;
width: number;
listBorderRadius?: string;
+ gridLayout?: "map";
annotatedFiles: FileListAnnotatedFile[];
mode?: GalleryBarMode;
modePlus?: GalleryBarMode | "search";
@@ -137,6 +138,7 @@ export const FileList: React.FC<FileListProps> = ({
height,
width,
listBorderRadius,
+ gridLayout,
mode,
modePlus,
header,
@@ -186,10 +188,26 @@ export const FileList: React.FC<FileListProps> = ({
const listRef = useRef<VariableSizeList | null>(null);
const outerRef = useRef<HTMLDivElement | null>(null);
- const layoutParams = useMemo(
- () => computeThumbnailGridLayoutParams(width),
- [width],
- );
+ const layoutParams = useMemo(() => {
+ if (gridLayout !== "map")
+ return computeThumbnailGridLayoutParams(width);
+ const columns = 3;
+ const paddingInline = 20;
+ const itemWidth = Math.max(
+ 0,
+ (width - 2 * paddingInline - (columns - 1) * thumbnailGap) /
+ columns,
+ );
+ return {
+ containerWidth: width,
+ isSmallerLayout: true,
+ paddingInline,
+ columns,
+ itemWidth,
+ itemHeight: itemWidth,
+ gap: thumbnailGap,
+ };
+ }, [width, gridLayout]);
useEffect(() => {
// Defer resize-heavy list rebuilds so React can discard stale renders.
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index 4a550f957b..ab387f6d75 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -60,6 +60,7 @@ export type FileListWithViewerProps = {
| "favoriteFileIDs"
| "emailByUserID"
| "listBorderRadius"
+ | "gridLayout"
| "onContextMenuAction"
| "onContextMenuOpenChange"
| "showAddPersonAction"
@@ -106,6 +107,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
favoriteFileIDs,
emailByUserID,
listBorderRadius,
+ gridLayout,
onContextMenuAction,
onContextMenuOpenChange,
showAddPersonAction,
@@ -259,6 +261,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
favoriteFileIDs,
emailByUserID,
listBorderRadius,
+ gridLayout,
onScroll,
onVisibleDateChange,
collectionSummary: activeCollectionSummary,
diff --git a/web/apps/photos/src/components/collections/CollectionMap.tsx b/web/apps/photos/src/components/collections/CollectionMap.tsx
index 0ae2de6545..2d93439c29 100644
--- a/web/apps/photos/src/components/collections/CollectionMap.tsx
+++ b/web/apps/photos/src/components/collections/CollectionMap.tsx
@@ -9,10 +9,8 @@ import {
Stack,
styled,
Typography,
- useMediaQuery,
type IconButtonProps,
} from "@mui/material";
-import { useTheme } from "@mui/material/styles";
import { ensureLocalUser } from "ente-accounts/services/user";
import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";
import { isSxArray } from "ente-base/components/utils/sx";
@@ -1063,7 +1061,6 @@ export const CollectionMap: React.FC<CollectionMapProps> = ({
mapCenter,
mapIndex,
mapPoints,
- latestFileId,
filesByID,
thumbByFileID,
isLoading,
@@ -1146,8 +1143,6 @@ export const CollectionMap: React.FC<CollectionMapProps> = ({
collectionSummary={collectionSummary}
visibleFiles={visibleFiles}
isVisiblePhotosUpdating={isVisiblePhotosUpdating}
- latestFileId={latestFileId}
- thumbByFileID={thumbByFileID}
user={user}
favoriteFileIDs={favoriteFileIDs}
pendingFavoriteUpdates={pendingFavoriteUpdates}
@@ -1198,8 +1193,6 @@ interface CollectionSidebarProps {
collectionSummary: CollectionSummary;
visibleFiles: EnteFile[];
isVisiblePhotosUpdating: boolean;
- latestFileId: number | undefined;
- thumbByFileID: Map<number, string>;
user: ReturnType<typeof useCurrentUser>;
favoriteFileIDs: Set<number>;
pendingFavoriteUpdates: Set<number>;
@@ -1222,16 +1215,12 @@ interface CollectionSidebarProps {
emailByUserID: FileListWithViewerProps["emailByUserID"];
}
-const COVER_IMAGE_HEIGHT = 320;
const MOBILE_SIDEBAR_HEIGHT = "50%";
-const COVER_HEADER_HEIGHT = COVER_IMAGE_HEIGHT + 34;
function CollectionSidebar({
collectionSummary,
visibleFiles,
isVisiblePhotosUpdating,
- latestFileId,
- thumbByFileID,
user,
favoriteFileIDs,
pendingFavoriteUpdates,
@@ -1250,15 +1239,6 @@ function CollectionSidebar({
onSelectPerson,
emailByUserID,
}: CollectionSidebarProps) {
- const [currentDate, setCurrentDate] = useState<string | undefined>(
- undefined,
- );
- const [scrollOffset, setScrollOffset] = useState(0);
- const shouldShowCover = collectionSummary.type !== "all";
- const theme = useTheme();
- const isDarkMode = theme.palette.mode === "dark";
- const isMobile = useMediaQuery(theme.breakpoints.down("md"));
-
const emptySelected = useMemo<SelectedState>(
() => ({
ownCount: 0,
@@ -1270,74 +1250,37 @@ function CollectionSidebar({
);
const noOpSetSelected = useCallback(() => undefined, []);
- const coverImageUrl =
- (collectionSummary.coverFile &&
- thumbByFileID.get(collectionSummary.coverFile.id)) ||
- (latestFileId ? thumbByFileID.get(latestFileId) : undefined);
- const coverHeader = useMemo(
- () =>
- shouldShowCover
- ? {
- component: (
- <MapCover
- name={collectionSummary.name}
- coverImageUrl={coverImageUrl}
- totalCount={collectionSummary.fileCount}
- />
- ),
- height: COVER_HEADER_HEIGHT,
- extendToInlineEdges: true,
- }
- : undefined,
- [
- shouldShowCover,
- collectionSummary.name,
- collectionSummary.fileCount,
- coverImageUrl,
- ],
- );
-
- const showStickyHeader =
- !shouldShowCover ||
- (scrollOffset > COVER_HEADER_HEIGHT && !!currentDate);
- const visibleDate =
- currentDate && (scrollOffset > 0 || (shouldShowCover && !isMobile))
- ? currentDate
- : undefined;
-
return (
<SidebarWrapper>
<SidebarContainer>
- <StickyDateHeader
- visible={showStickyHeader}
- variant={shouldShowCover ? "overlay" : "static"}
- >
- <Box
+ <Stack sx={{ px: "20px", pt: "20px", pb: "20px", gap: "2px" }}>
+ <Typography
+ component="h2"
+ sx={{
+ fontFamily: '"Outfit Variable", sans-serif',
+ fontSize: "24px",
+ lineHeight: "32px",
+ fontWeight: 600,
+ overflowWrap: "anywhere",
+ }}
+ >
+ {collectionSummary.type === "all"
+ ? t("map")
+ : collectionSummary.name}
+ </Typography>
+ <Typography
sx={{
- display: "flex",
- justifyContent: "space-between",
- alignItems: "center",
+ color: "text.muted",
+ fontSize: "14px",
+ lineHeight: "20px",
+ fontWeight: 500,
}}
>
- <Box>
- <Typography
- variant="body"
- sx={{ fontWeight: 700, fontSize: "18px" }}
- >
- {collectionSummary.name}
- </Typography>
- <Typography
- variant="small"
- sx={{ color: "text.muted", fontSize: "14px" }}
- >
- {t("photos_count", {
- count: collectionSummary.fileCount,
- })}
- {visibleDate && ` Β· ${visibleDate}`}
- </Typography>
- </Box>
- </Box>
- </StickyDateHeader>
+ {t("photos_count", {
+ count: collectionSummary.fileCount,
+ })}
+ </Typography>
+ </Stack>
<FileListContainer>
{visibleFiles.length > 0 ? (
<FileListWithViewer
@@ -1364,20 +1307,11 @@ function CollectionSidebar({
activeCollectionID={collectionSummary.id}
selected={emptySelected}
setSelected={noOpSetSelected}
- listBorderRadius={isMobile ? "0" : "0 0 32px 32px"}
- header={coverHeader}
- onScroll={setScrollOffset}
- onVisibleDateChange={setCurrentDate}
+ listBorderRadius="0"
+ gridLayout="map"
/>
) : isVisiblePhotosUpdating ? null : (
<EmptyStateContainer>
- {shouldShowCover && (
- <MapCover
- name={collectionSummary.name}
- coverImageUrl={coverImageUrl}
- totalCount={collectionSummary.fileCount}
- />
- )}
<EmptyStateMessage>
<Typography
variant="body"
@@ -1396,7 +1330,6 @@ function CollectionSidebar({
)}
</FileListContainer>
</SidebarContainer>
- {isDarkMode && <SidebarGradient />}
</SidebarWrapper>
);
}
@@ -1802,45 +1735,6 @@ function CenteredBox({ children }: React.PropsWithChildren) {
return <CenteredBoxContainer>{children}</CenteredBoxContainer>;
}
-interface MapCoverProps {
- name: string;
- coverImageUrl: string | undefined;
- totalCount: number;
-}
-
-const MapCover = React.memo(function MapCover({
- name,
- coverImageUrl,
- totalCount,
-}: MapCoverProps) {
- return (
- <CoverContainer>
- <CoverImageContainer>
- <img
- src={coverImageUrl}
- alt="Cover"
- style={{
- position: "absolute",
- inset: 0,
- width: "100%",
- height: "100%",
- objectFit: "cover",
- objectPosition: "Center",
- }}
- />
- <CoverGradientOverlay />
-
- <CoverContentContainer>
- <CoverTitle>{name}</CoverTitle>
- <CoverSubtitle>
- {t("photos_count", { count: totalCount })}
- </CoverSubtitle>
- </CoverContentContainer>
- </CoverImageContainer>
- </CoverContainer>
- );
-});
-
const MapCanvasContainer = styled(Box)(({ theme }) => ({
width: "100%",
height: "100%",
@@ -1849,58 +1743,6 @@ const MapCanvasContainer = styled(Box)(({ theme }) => ({
},
}));
-const CoverContainer = styled(Box)(({ theme }) => ({
- width: "100%",
- flexShrink: 0,
- paddingTop: "16px",
- paddingBottom: "16px",
- [theme.breakpoints.down("md")]: {
- padding: "8px",
- paddingTop: "20px",
- paddingBottom: "12px",
- },
-}));
-
-const CoverImageContainer = styled(Box)(({ theme }) => ({
- height: `${COVER_IMAGE_HEIGHT}px`,
- position: "relative",
- overflow: "hidden",
- backgroundColor: "#333",
- borderRadius: "36px 36px 24px 24px",
- marginTop: "2px",
- [theme.breakpoints.down("md")]: { borderRadius: "20px" },
-}));
-
-const CoverGradientOverlay = styled(Box)({
- position: "absolute",
- inset: 0,
- background:
- "linear-gradient(to bottom, rgba(0,0,0,0.4), transparent 35%, transparent 60%, rgba(0,0,0,0.75))",
-});
-
-const CoverContentContainer = styled(Box)({
- position: "absolute",
- bottom: 0,
- left: 0,
- right: 0,
- padding: "24px",
- paddingLeft: "18px",
- color: "white",
-});
-
-const CoverTitle = styled(Typography)({
- fontSize: "22px",
- fontWeight: "bold",
- marginBottom: "6px",
- lineHeight: 1.2,
-});
-
-const CoverSubtitle = styled(Typography)({
- color: "rgba(255, 255, 255, 0.85)",
- fontSize: "14px",
- fontWeight: "500",
-});
-
const SidebarWrapper = styled(Box)(({ theme }) => ({
position: "absolute",
left: 0,
@@ -1916,9 +1758,7 @@ const SidebarWrapper = styled(Box)(({ theme }) => ({
bottom: 16,
right: "auto",
height: "auto",
- width: "30%",
- maxWidth: "600px",
- minWidth: "450px",
+ width: "460px",
},
}));
@@ -1926,68 +1766,28 @@ const SidebarContainer = styled(Box)(({ theme }) => ({
position: "relative",
width: "100%",
height: "100%",
- backgroundColor: theme.vars.palette.background.paper,
- boxShadow: theme.shadows[10],
+ backgroundColor: "#f4f4f4",
+ border: `1px solid ${theme.vars.palette.stroke.faint}`,
display: "flex",
flexDirection: "column",
overflow: "hidden",
- borderRadius: "24px 24px 0 0",
- [theme.breakpoints.up("md")]: { borderRadius: "48px" },
-}));
-
-const SidebarGradient = styled(Box)(({ theme }) => ({
- position: "absolute",
- bottom: 0,
- left: 0,
- right: 0,
- height: "80px",
- background:
- "linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0.65) 2%, rgba(0,0,0,0) 100%)",
- pointerEvents: "none",
- [theme.breakpoints.up("md")]: {
- height: "150px",
- borderRadius: "0 0 48px 48px",
- },
+ borderRadius: "20px 20px 0 0",
+ fontSize: "14px",
+ lineHeight: "20px",
+ fontWeight: 500,
+ [theme.breakpoints.up("md")]: { borderRadius: "20px" },
+ ...theme.applyStyles("dark", {
+ backgroundColor: theme.vars.palette.background.paper,
+ }),
}));
-const FileListContainer = styled(Box)(({ theme }) => ({
+const FileListContainer = styled(Box)({
flex: 1,
minHeight: 0,
position: "relative",
display: "flex",
flexDirection: "column",
- paddingLeft: "8px",
- paddingRight: "8px",
- paddingBottom: "calc(env(safe-area-inset-bottom, 0px) + 16px)",
- [theme.breakpoints.up("md")]: {
- paddingLeft: "16px",
- paddingRight: "16px",
- paddingBottom: "18px",
- },
-}));
-
-const StickyDateHeader = styled(Box)<{
- visible: boolean;
- variant: "overlay" | "static";
-}>(({ theme, visible, variant }) => {
- const isStatic = variant === "static";
- return {
- position: isStatic ? "relative" : "absolute",
- top: 0,
- left: 0,
- right: 0,
- zIndex: 10,
- backgroundColor: theme.vars.palette.background.paper,
- padding: "28px 24px 24px 24px",
- borderBottom: `1px solid ${theme.vars.palette.divider}`,
- opacity: isStatic || visible ? 1 : 0,
- transform: isStatic || visible ? "translateY(0)" : "translateY(-10px)",
- pointerEvents: isStatic || visible ? "auto" : "none",
- transition: isStatic
- ? "none"
- : "opacity 0.25s ease-out, transform 0.25s ease-out",
- [theme.breakpoints.down("md")]: { padding: "24px 20px 20px 20px" },
- };
+ paddingBottom: "calc(env(safe-area-inset-bottom, 0px) + 20px)",
});
const CenteredBoxContainer = styled(Box)({