From 2aaa23312b35e5f12228242c0af25eab1a601a36 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 27 Sep 2024 19:15:12 +0530 Subject: [PATCH] Both buttons --- .../Collections/GalleryBarAndListHeader.tsx | 2 + web/apps/photos/src/pages/gallery.tsx | 10 ++++- .../new/photos/components/Gallery/BarImpl.tsx | 44 +++++++++++++------ 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx index e34768d212..af963430c5 100644 --- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx +++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx @@ -86,6 +86,7 @@ type CollectionsProps = Omit< */ export const GalleryBarAndListHeader: React.FC = ({ shouldHide, + showPeopleSectionButton, mode, onChangeMode, collectionSummaries, @@ -199,6 +200,7 @@ export const GalleryBarAndListHeader: React.FC = ({ <> ; } + // `people` will be undefined only when ML is disabled, otherwise it'll be + // an empty array (even if people are loading). + const showPeopleSectionButton = people !== undefined; + return ( = ({ + showPeopleSectionButton, mode, onChangeMode, collectionSummaries, @@ -255,7 +260,9 @@ export const GalleryBarImpl: React.FC = ({ sx={people.length ? {} : { borderBlockEndColor: "transparent" }} > - + {controls1} @@ -312,33 +319,44 @@ export const Row2 = styled(Box)` `; const ModeIndicator: React.FC< - Pick -> = ({ mode, onChangeMode }) => { + Pick< + GalleryBarImplProps, + "showPeopleSectionButton" | "mode" | "onChangeMode" + > +> = ({ showPeopleSectionButton, mode, onChangeMode }) => { // Mode switcher is not shown in the hidden albums section. if (mode == "hidden-albums") { return {t("hidden_albums")}; } - // Show the static mode indicator with only the "Albums" title unless we - // come here with the people mode already set. This is because we don't - // currently have an empty state for the People mode when ML is not enabled. - if (mode == "albums") { + // Show the static mode indicator with only the "Albums" title if we have + // not been asked to show the people button (there are no other sections to + // switch to in such a case). + if (!showPeopleSectionButton) { return {t("albums")}; } return ( - onChangeMode("albums")}> + onChangeMode("albums")} + > {t("albums")} - - {t("people")} + + onChangeMode("people")} + > + {t("people")} + ); }; -const AlbumModeButton = styled(UnstyledButton)( - ({ theme }) => ` - p { color: ${theme.colors.text.muted} } +const ModeButton = styled(UnstyledButton)<{ $active: boolean }>( + ({ $active, theme }) => ` + p { color: ${$active ? theme.colors.text.base : theme.colors.text.muted} } p:hover { color: ${theme.colors.text.base} } `, );