Skip to content

armgit / ente

Public Imported from GitHub
0

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

update(MapView):posistion-of-collection-viewer-updated

Aswin Asok6d587840161b
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
index eea5346ee5..86643a303d 100644
--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
@@ -1,6 +1,6 @@
import CloseIcon from "@mui/icons-material/Close";
-import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
-import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
+import KeyboardArrowLeftIcon from "@mui/icons-material/KeyboardArrowLeft";
+import KeyboardArrowRightIcon from "@mui/icons-material/KeyboardArrowRight";
import {
Box,
Dialog,
@@ -99,10 +99,6 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
return Array.from(groups.entries());
}, [mapPhotos]);
- const visiblePhotosByDate = useMemo(
- () => (expanded ? photosByDate : photosByDate.slice(0, 2)),
- [expanded, photosByDate],
- );
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const optimalZoom = calculateOptimalZoom();
@@ -301,41 +297,35 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
const { MapContainer, TileLayer, Marker } = mapComponents;
return (
- <Box sx={{ position: "relative", height: "100%", width: "100%" }}>
- <MapContainer
- center={mapCenter}
- zoom={optimalZoom}
- scrollWheelZoom
- style={{ width: "100%", height: "100%" }}
+ <Box sx={{ display: "flex", height: "100%", width: "100%" }}>
+ {/* Left sidebar */}
+ <Box
+ sx={{
+ width: expanded ? "50%" : "440px",
+ height: "100%",
+ bgcolor: (theme) => theme.vars.palette.background.paper,
+ boxShadow: (theme) => theme.shadows[6],
+ display: "flex",
+ flexDirection: "column",
+ overflowY: "auto",
+ padding: 2,
+ transition: "width 0.3s ease",
+ }}
>
- <TileLayer
- attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
- url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
- maxZoom={19}
- updateWhenZooming
- />
- {clusterMeta.map((cluster, index) => {
- const icon = createIcon(
- cluster.thumbnail ?? "",
- index === selectedClusterIndex ? 55 : 45,
- "#ffffff",
- cluster.count,
- index === selectedClusterIndex,
- );
- return (
- <Marker
- key={`${cluster.lat}-${cluster.lng}-${index}`}
- position={[cluster.lat, cluster.lng]}
- icon={icon ?? undefined}
- eventHandlers={{
- click: () => setSelectedClusterIndex(index),
- }}
- />
- );
- })}
- </MapContainer>
- <BottomPanel expanded={expanded}>
- <Stack spacing={1}>
+ {/* Sticky header section */}
+ <Box
+ sx={{
+ position: "sticky",
+ top: -16, // Stick to the very top
+ mx: -2, // Extend to edges
+ px: 2, // Add padding back
+ pt: 2, // Add padding for content spacing
+ bgcolor: (theme) =>
+ theme.vars.palette.background.paper,
+ zIndex: 1,
+ pb: 2,
+ }}
+ >
<Box
sx={{
display: "flex",
@@ -355,7 +345,7 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
<Typography
variant="body"
color="text.secondary"
- sx={{ mt: 0.25, mb: 1 }}
+ sx={{ mt: 0.25 }}
>
{mapPhotos.length}{" "}
{t("memories", {
@@ -376,9 +366,9 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
}}
>
{expanded ? (
- <KeyboardArrowDownIcon />
+ <KeyboardArrowLeftIcon />
) : (
- <KeyboardArrowUpIcon />
+ <KeyboardArrowRightIcon />
)}
</IconButton>
<IconButton
@@ -394,42 +384,92 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
</IconButton>
</Stack>
</Box>
- <Stack spacing={1.5}>
- {visiblePhotosByDate.map(([dateLabel, photos]) => (
- <Stack key={dateLabel} spacing={0.75}>
+ </Box>
+ {/* Scrollable photo content */}
+ <Stack spacing={1.5}>
+ {photosByDate.map(([dateLabel, photos]) => (
+ <Stack key={dateLabel} spacing={0.75}>
+ <Box
+ sx={{
+ position: "sticky",
+ top: 56,
+ bgcolor: (theme) =>
+ theme.vars.palette.background.paper,
+ zIndex: 0,
+ py: 0.5,
+ ml: -2,
+ mr: -2,
+ pr: 2,
+ }}
+ >
<Typography
variant="small"
color="text.secondary"
- sx={{ mb: 0.25 }}
>
{dateLabel}
</Typography>
- <ThumbRow>
- {photos.map((p, idx) => {
- const thumb = thumbByFileID.get(
- p.fileId,
- );
- if (!thumb) {
- return (
- <PlaceholderThumb
- key={p.fileId}
- />
- );
- }
+ </Box>
+ <ThumbRow>
+ {photos.map((p, idx) => {
+ const thumb = thumbByFileID.get(
+ p.fileId,
+ );
+ if (!thumb) {
return (
- <ThumbImage
- key={`${thumb}-${idx}`}
- src={thumb}
- alt={t("view_on_map")}
+ <PlaceholderThumb
+ key={p.fileId}
/>
);
- })}
- </ThumbRow>
- </Stack>
- ))}
- </Stack>
+ }
+ return (
+ <ThumbImage
+ key={`${thumb}-${idx}`}
+ src={thumb}
+ alt={t("view_on_map")}
+ />
+ );
+ })}
+ </ThumbRow>
+ </Stack>
+ ))}
</Stack>
- </BottomPanel>
+ </Box>
+ {/* Map container on the right */}
+ <Box sx={{ flex: 1, position: "relative" }}>
+ <MapContainer
+ center={mapCenter}
+ zoom={optimalZoom}
+ scrollWheelZoom
+ style={{ width: "100%", height: "100%" }}
+ >
+ <TileLayer
+ attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
+ url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
+ maxZoom={19}
+ updateWhenZooming
+ />
+ {clusterMeta.map((cluster, index) => {
+ const icon = createIcon(
+ cluster.thumbnail ?? "",
+ index === selectedClusterIndex ? 76 : 68,
+ "#f6f6f6",
+ cluster.count,
+ index === selectedClusterIndex,
+ );
+ return (
+ <Marker
+ key={`${cluster.lat}-${cluster.lng}-${index}`}
+ position={[cluster.lat, cluster.lng]}
+ icon={icon ?? undefined}
+ eventHandlers={{
+ click: () =>
+ setSelectedClusterIndex(index),
+ }}
+ />
+ );
+ })}
+ </MapContainer>
+ </Box>
</Box>
);
}, [
@@ -439,12 +479,14 @@ export const CollectionMapDialog: React.FC<CollectionMapDialogProps> = ({
mapCenter,
mapComponents,
optimalZoom,
- mapPhotos.length,
mapPhotos,
thumbByFileID,
photosByDate,
expanded,
- visiblePhotosByDate,
+ collectionSummary.name,
+ onClose,
+ photoClusters.length,
+ selectedClusterIndex,
]);
return (
@@ -483,30 +525,6 @@ const CenteredBox: React.FC<React.PropsWithChildren> = ({ children }) => (
</Box>
);
-const BottomPanel: React.FC<React.PropsWithChildren<{ expanded: boolean }>> = ({
- expanded,
- children,
-}) => (
- <Box
- sx={{
- position: "absolute",
- bottom: 0,
- left: 0,
- right: 0,
- zIndex: (theme) => theme.zIndex.modal,
- bgcolor: (theme) => theme.vars.palette.background.paper,
- boxShadow: (theme) => theme.shadows[6],
- p: 2,
- borderTopLeftRadius: 12,
- borderTopRightRadius: 12,
- maxHeight: expanded ? "75vh" : "45vh",
- overflowY: "auto",
- }}
- >
- {children}
- </Box>
-);
-
const ThumbRow: React.FC<React.PropsWithChildren> = ({ children }) => (
<Box sx={{ display: "flex", flexWrap: "wrap", gap: 0.25, pb: 1 }}>
{children}
diff --git a/web/apps/photos/src/components/TripLayout/mapHelpers.ts b/web/apps/photos/src/components/TripLayout/mapHelpers.ts
index 9ef10b15be..6db634bb25 100644
--- a/web/apps/photos/src/components/TripLayout/mapHelpers.ts
+++ b/web/apps/photos/src/components/TripLayout/mapHelpers.ts
@@ -99,9 +99,9 @@ export const calculateOptimalZoom = (): number => {
// Function to create icon with specific image and progress styling
export const createIcon = (
imageSrc: string,
- size = 40,
+ size = 70,
borderColor = "#ffffff",
- _clusterCount?: number,
+ clusterCount?: number,
isReached = false,
): import("leaflet").DivIcon | null => {
const leaflet = getLeaflet();
@@ -110,96 +110,112 @@ export const createIcon = (
return null;
}
- const pinSize = size + 16; // Make it square and bigger
- const triangleHeight = size <= 30 ? 7 : 10; // Smaller triangle for mobile
- const pinHeight = pinSize + triangleHeight + 2; // Add space for triangle
+ const pinSize = size;
+ const triangleHeight = 12;
+ const pinHeight = pinSize + triangleHeight;
const hasImage = imageSrc && imageSrc.trim() !== "";
- // Adjust border radius for smaller mobile markers
- const outerBorderRadius = size <= 30 ? 14 : 16;
- const innerBorderRadius = size <= 30 ? 10 : 12;
-
// Create cache key based on all parameters including border radius and triangle size
- const cacheKey = `icon_${imageSrc}_${size}_${borderColor}_${isReached}_${outerBorderRadius}_${innerBorderRadius}_${triangleHeight}`;
+ const cacheKey = `icon_${imageSrc}_${size}_${borderColor}_${isReached}_${triangleHeight}_${clusterCount}`;
const cachedIcon = iconCache.get(cacheKey);
if (cachedIcon) {
return cachedIcon;
}
+ const badgeLabel =
+ clusterCount && clusterCount > 1
+ ? clusterCount >= 2000
+ ? `${Math.floor((clusterCount - 1) / 1000)}K+`
+ : clusterCount >= 1000
+ ? "1K+"
+ : clusterCount > 999
+ ? `${Math.floor(clusterCount / 100)}00+`
+ : `${clusterCount}`
+ : null;
+ const backgroundColor = isReached ? "#22c55e" : "#f6f6f6";
+ const border = `2px solid ${borderColor}`;
const icon = leaflet.divIcon({
html: `
- <div class="photo-pin${isReached ? " reached" : ""}" style="
- width: ${pinSize}px;
- height: ${pinHeight}px;
- position: relative;
- cursor: pointer;
- transition: all 0.3s ease;
- ">
- <!-- Main rounded rectangle container -->
- <div style="
- width: ${pinSize}px;
- height: ${pinSize}px;
- border-radius: ${outerBorderRadius}px;
- background: ${isReached ? "#22c55e" : "white"};
- border: 2px solid ${isReached ? "#22c55e" : borderColor};
- padding: 4px;
- position: relative;
- overflow: hidden;
- transition: background-color 0.3s ease, border-color 0.3s ease;
- "
- onmouseover="this.style.background='#22c55e'; this.style.borderColor='#22c55e'; this.nextElementSibling.style.borderTopColor='#22c55e';"
- onmouseout="this.style.background='${isReached ? "#22c55e" : "white"}'; this.style.borderColor='${isReached ? "#22c55e" : "#ffffff"}'; this.nextElementSibling.style.borderTopColor='${isReached ? "#22c55e" : "white"}';"
- >
- ${
- hasImage
- ? `
- <!-- Image inside the rounded rectangle -->
- <img
- src="${imageSrc}"
- style="
- width: 100%;
- height: 100%;
- object-fit: cover;
- border-radius: ${innerBorderRadius}px;
- "
- alt="Location"
- />
- `
- : `
- <!-- Loading skeleton when no image -->
+ <div class="photo-pin${isReached ? " reached" : ""}" style="
+ width: ${pinSize}px;
+ height: ${pinHeight}px;
+ position: relative;
+ cursor: pointer;
+ filter: drop-shadow(0px 6px 16px rgba(0,0,0,0.2));
+ ">
<div style="
- width: 100%;
- height: 100%;
- border-radius: ${innerBorderRadius}px;
- animation: skeleton-pulse 1.5s ease-in-out infinite;
- "></div>
- <style>
- @keyframes skeleton-pulse {
- 0% { background-color: #ffffff; }
- 50% { background-color: #f0f0f0; }
- 100% { background-color: #ffffff; }
+ width: ${pinSize}px;
+ height: ${pinSize}px;
+ border-radius: 6px;
+ background: ${backgroundColor};
+ border: ${border};
+ overflow: hidden;
+ position: relative;
+ ">
+ ${
+ hasImage
+ ? `
+ <img
+ src="${imageSrc}"
+ style="
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ display: block;
+ "
+ alt="Location"
+ />
+ `
+ : `
+ <div style="
+ width: 100%;
+ height: 100%;
+ background: linear-gradient(90deg, #f8f8f8 25%, #f0f0f0 50%, #f8f8f8 75%);
+ background-size: 200% 100%;
+ animation: shimmer 1.4s ease infinite;
+ "></div>
+ <style>
+ @keyframes shimmer {
+ 0% { background-position: 200% 0; }
+ 100% { background-position: -200% 0; }
+ }
+ </style>
+ `
+ }
+ ${
+ badgeLabel
+ ? `<div style="
+ position: absolute;
+ top: 6px;
+ right: 6px;
+ background: #22c55e;
+ color: #ffffff;
+ border-radius: 4px;
+ padding: 4px 6px;
+ font-size: 11px;
+ font-weight: 700;
+ line-height: 1;
+ box-shadow: 0 2px 6px rgba(0,0,0,0.15);
+ ">
+ ${badgeLabel}
+ </div>`
+ : ""
}
- </style>
- `
- }
- </div>
-
- <!-- Triangle at the bottom -->
- <div style="
- position: absolute;
- bottom: 2px;
- left: 50%;
- transform: translateX(-50%);
- width: 0;
- height: 0;
- border-left: ${triangleHeight}px solid transparent;
- border-right: ${triangleHeight}px solid transparent;
- border-top: ${triangleHeight}px solid ${isReached ? "#22c55e" : "white"};
- transition: border-top-color 0.3s ease;
- "></div>
- </div>
- `,
+ </div>
+ <div style="
+ position: absolute;
+ bottom: 0;
+ left: 50%;
+ transform: translate(-50%, 0);
+ width: 0;
+ height: 0;
+ border-left: ${triangleHeight / 1.4}px solid transparent;
+ border-right: ${triangleHeight / 1.4}px solid transparent;
+ border-top: ${triangleHeight}px solid ${backgroundColor};
+ "></div>
+ </div>
+ `,
className: "custom-pin-marker",
iconSize: [pinSize, pinHeight],
iconAnchor: [pinSize / 2, pinHeight],