Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(photos):show-people-overview-from-navigation-rail

Aswin Asokba1f13e7645c
diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsx
index 2e5b40de2d..f79d6a4452 100644
--- a/web/apps/photos/src/components/gallery/BarImpl.tsx
+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx
@@ -868,11 +868,22 @@ const PersonCard: React.FC<PersonCardProps> = ({
coverFaceID={person.displayFaceID}
/>
</Box>
- {person.name && <CardText>{person.name}</CardText>}
+ <CardText>{person.name || t("unnamed_person")}</CardText>
{person.isPinned && (
<CollectionBarCardIcon_ aria-hidden>
<HugeiconsIcon icon={PinIcon} size={14} />
</CollectionBarCardIcon_>
)}
+ <Typography
+ component="span"
+ sx={{
+ flexShrink: 0,
+ fontSize: 12,
+ lineHeight: "20px",
+ color: "text.muted",
+ }}
+ >
+ {person.fileIDs.length.toLocaleString()}
+ </Typography>
</BarCard>
);
diff --git a/web/apps/photos/src/components/gallery/PeopleOverview.tsx b/web/apps/photos/src/components/gallery/PeopleOverview.tsx
new file mode 100644
index 0000000000..5fdbd07026
--- /dev/null
+++ b/web/apps/photos/src/components/gallery/PeopleOverview.tsx
@@ -0,0 +1,140 @@
+import { sortPeople } from "@/utils/people-sort";
+import { Box, Stack, Typography, styled } from "@mui/material";
+import { ItemCard } from "ente-new/photos/components/Tiles";
+import { UnstyledButton } from "ente-new/photos/components/UnstyledButton";
+import type { Person } from "ente-new/photos/services/ml/people";
+import { t } from "i18next";
+import { useMemo } from "react";
+import { PeopleEmptyState } from ".";
+
+export const PeopleOverview = ({
+ people,
+ onSelectPerson,
+}: {
+ people: Person[];
+ onSelectPerson: (id: string) => void;
+}) => {
+ const sortedPeople = useMemo(
+ () => sortPeople(people, "count-desc"),
+ [people],
+ );
+ return (
+ <Stack
+ sx={{
+ flex: 1,
+ minHeight: 0,
+ overflow: "auto",
+ p: { xs: "16px 14px", md: "36px" },
+ gap: "24px",
+ }}
+ >
+ <Stack
+ direction="row"
+ sx={{
+ alignItems: "center",
+ justifyContent: "space-between",
+ minHeight: 54,
+ gap: 2,
+ }}
+ >
+ <Stack sx={{ gap: "2px" }}>
+ <Typography
+ component="h1"
+ sx={{
+ fontFamily: '"Outfit Variable", Outfit, sans-serif',
+ fontSize: 24,
+ fontWeight: 600,
+ lineHeight: "32px",
+ }}
+ >
+ {t("people")}
+ </Typography>
+ <Typography
+ sx={{
+ color: "text.muted",
+ fontSize: 14,
+ fontWeight: 500,
+ lineHeight: "18px",
+ }}
+ >
+ {t("people_count", { count: people.length })}
+ </Typography>
+ </Stack>
+ </Stack>
+ {people.length ? (
+ <Box
+ sx={{
+ display: "grid",
+ "--people-tile-size": { xs: "96px", md: "140px" },
+ "--people-portrait-size": { xs: "80px", md: "120px" },
+ gridTemplateColumns:
+ "repeat(auto-fill, minmax(var(--people-tile-size), 1fr))",
+ justifyItems: "center",
+ gap: { xs: "24px 12px", md: "24px 22px" },
+ }}
+ >
+ {sortedPeople.map((person) => (
+ <PersonButton
+ key={person.id}
+ onClick={() => onSelectPerson(person.id)}
+ >
+ <ItemCard
+ TileComponent={Portrait}
+ coverFile={person.displayFaceFile}
+ coverFaceID={person.displayFaceID}
+ />
+ <Typography
+ component="span"
+ sx={{
+ fontSize: 14,
+ fontWeight: 500,
+ lineHeight: "20px",
+ overflowWrap: "anywhere",
+ }}
+ >
+ {person.name || t("unnamed_person")}
+ </Typography>
+ <Typography
+ component="span"
+ sx={{
+ mt: "-6px",
+ fontSize: 12,
+ fontWeight: 500,
+ lineHeight: "16px",
+ color: "text.muted",
+ }}
+ >
+ {t("people_photo_count", {
+ count: person.fileIDs.length,
+ })}
+ </Typography>
+ </PersonButton>
+ ))}
+ </Box>
+ ) : (
+ <PeopleEmptyState />
+ )}
+ </Stack>
+ );
+};
+
+const PersonButton = styled(UnstyledButton)({
+ width: "var(--people-tile-size)",
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ gap: 8,
+ color: "inherit",
+ borderRadius: 12,
+ "&:hover": { opacity: 0.86 },
+});
+
+const Portrait = styled("div")({
+ width: "var(--people-portrait-size)",
+ height: "var(--people-portrait-size)",
+ flexShrink: 0,
+ borderRadius: "50%",
+ overflow: "hidden",
+ position: "relative",
+ "& > img": { width: "100%", height: "100%", objectFit: "cover" },
+});
diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
index 9338f6dcdb..bce01dc91f 100644
--- a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
+++ b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
@@ -80,6 +80,11 @@ export const PhotosNavigationShell: React.FC<
if (!mobile) closeMobileNavigation();
}, [mobile, closeMobileNavigation]);
const handleChangeMode = (mode: GalleryBarMode) => {
+ if (mode == "people") {
+ closeMobileNavigation();
+ props.onChangeMode(mode);
+ return;
+ }
const reopeningSection =
mobile &&
mode == "albums" &&
@@ -208,7 +213,15 @@ export const PhotosNavigationShell: React.FC<
flex: 1,
minWidth: 0,
minHeight: 0,
- pt: showRail ? `${thumbnailGridPadding}px` : 0,
+ pt:
+ showRail &&
+ !(
+ props.mode == "people" &&
+ !props.isInSearchMode &&
+ !galleryBarProps?.activePerson
+ )
+ ? `${thumbnailGridPadding}px`
+ : 0,
...(showRail && {
"--mui-palette-background-default": "#FFFFFF",
bgcolor: "background.default",
diff --git a/web/apps/photos/src/components/gallery/reducer.ts b/web/apps/photos/src/components/gallery/reducer.ts
index 326f519c67..d73d247ead 100644
--- a/web/apps/photos/src/components/gallery/reducer.ts
+++ b/web/apps/photos/src/components/gallery/reducer.ts
@@ -806,8 +806,8 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
state.peopleState,
state.tempDeletedFileIDs,
state.tempHiddenFileIDs,
- state.selectedPersonID,
- state.extraVisiblePerson,
+ undefined,
+ undefined,
);
return stateByUpdatingFilteredFiles({
...state,
@@ -1552,8 +1552,6 @@ const derivePeopleView = (
activePerson = findByIDIn(people);
if (activePerson) {
extraVisiblePerson = activePerson;
- } else {
- activePerson = visiblePeople[0];
}
}
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 6943fe5ddb..9289fc0da7 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -30,12 +30,12 @@ import { Upload } from "@/components/Upload";
import { WhatsNew } from "@/components/WhatsNew";
import {
GalleryEmptyState,
- PeopleEmptyState,
SearchResultsHeader,
type RemotePullOpts,
} from "@/components/gallery";
import { DuplicatesView } from "@/components/gallery/DuplicatesView";
import { LargeFilesView } from "@/components/gallery/LargeFilesView";
+import { PeopleOverview } from "@/components/gallery/PeopleOverview";
import { PhotosNavigationShell } from "@/components/gallery/PhotosNavigationShell";
import { TrashFilesDialog } from "@/components/gallery/TrashFilesDialog";
import {
@@ -2102,7 +2102,10 @@ const Page: React.FC = () => {
!isFirstLoad &&
state.view?.type == "people" &&
!state.view.activePerson ? (
- <PeopleEmptyState />
+ <PeopleOverview
+ people={state.view.visiblePeople}
+ onSelectPerson={handleSelectPerson}
+ />
) : (
<FileListWithViewer
mode={barMode}
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index 32d03ec65b..fae3c176c2 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -514,6 +514,10 @@
"photos_count": "{{count, number}} memories",
"terms_and_conditions": "I agree to the <a>terms</a> and <b>privacy policy</b>",
"people": "People",
+ "people_count_one": "1 person",
+ "people_count_other": "{{count, number}} people",
+ "people_photo_count_one": "1 photo",
+ "people_photo_count_other": "{{count, number}} photos",
"show_less_faces": "Show fewer faces",
"show_more_faces": "Show more faces",
"indexing_scheduled": "Indexing is scheduled...",