Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(photos):move-albums-and-people-switch-to-rail

Aswin Asokbfb06fbd8800
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 5cda77490c..3b0c944f45 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -80,7 +80,6 @@ export const GalleryBarAndListHeader: React.FC<
> = ({
shouldHide,
mode,
- onChangeMode,
user,
barCollectionSummaries: toShowCollectionSummaries,
activeCollection,
@@ -251,7 +250,6 @@ export const GalleryBarAndListHeader: React.FC<
<GalleryBarImpl
{...{
mode,
- onChangeMode,
activeCollectionID,
people: sortedPeople,
activePerson,
diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsx
index 4f43778cff..ea245eaad0 100644
--- a/web/apps/photos/src/components/gallery/BarImpl.tsx
+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx
@@ -17,7 +17,6 @@ import {
ItemCard,
TileTextOverlay,
} from "ente-new/photos/components/Tiles";
-import { FocusVisibleUnstyledButton } from "ente-new/photos/components/UnstyledButton";
import {
thumbnailLayoutMinColumns,
thumbnailMaxWidth,
@@ -27,7 +26,6 @@ import type {
CollectionSummaryAttribute,
CollectionsSortBy,
} from "ente-new/photos/services/collection-summary";
-import { isMLSupported } from "ente-new/photos/services/ml";
import type { Person } from "ente-new/photos/services/ml/people";
import { t } from "i18next";
import React, {
@@ -48,7 +46,6 @@ import type { GalleryBarMode } from "./reducer";
export interface GalleryBarImplProps {
mode: GalleryBarMode;
- onChangeMode: (mode: GalleryBarMode) => void;
collectionSummaries: CollectionSummary[];
activeCollectionID: number | undefined;
onSelectCollectionID: (collectionID: number) => void;
@@ -65,7 +62,6 @@ export interface GalleryBarImplProps {
export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
mode,
- onChangeMode,
collectionSummaries,
activeCollectionID,
onSelectCollectionID,
@@ -234,10 +230,18 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
} as React.CSSProperties
}
>
- <Row1>
- <ModeIndicator {...{ mode, onChangeMode }} />
- {controls1}
- </Row1>
+ {(mode == "hidden-albums" ||
+ mode == "archive-albums" ||
+ isSmallWidth) && (
+ <Row1>
+ {mode == "hidden-albums" ? (
+ <Typography>{t("hidden_albums")}</Typography>
+ ) : mode == "archive-albums" ? (
+ <Typography>{t("section_archive")}</Typography>
+ ) : null}
+ {controls1}
+ </Row1>
+ )}
<Row2>
<ListWrapper>
{canScrollLeft && <ScrollButtonLeft onClick={scroll(-1)} />}
@@ -291,51 +295,6 @@ const Row2 = styled("div")`
border-block-end: 1px solid var(--et-bar-bottom-border-color);
`;
-const ModeIndicator: React.FC<
- Pick<GalleryBarImplProps, "mode" | "onChangeMode">
-> = ({ mode, onChangeMode }) => {
- if (mode == "hidden-albums") {
- return <Typography>{t("hidden_albums")}</Typography>;
- }
- if (mode == "archive-albums") {
- return <Typography>{t("section_archive")}</Typography>;
- }
-
- if (!isMLSupported) {
- return <Typography>{t("albums")}</Typography>;
- }
-
- return (
- <Stack direction="row" sx={{ gap: "10px" }}>
- <ModeButton
- active={mode == "albums"}
- onClick={() => onChangeMode("albums")}
- >
- <Typography>{t("albums")}</Typography>
- </ModeButton>
- <ModeButton
- active={mode == "people"}
- onClick={() => onChangeMode("people")}
- >
- <Typography>{t("people")}</Typography>
- </ModeButton>
- </Stack>
- );
-};
-
-const ModeButton = styled(FocusVisibleUnstyledButton, {
- shouldForwardProp: (propName) => propName != "active",
-})<{ active: boolean }>(
- ({ theme, active }) => `
-p {
- color: ${active ? theme.vars.palette.text.base : theme.vars.palette.text.muted}
-}
-p:hover {
- color: ${theme.vars.palette.text.base}
-}
-`,
-);
-
const ScrollButtonBase: React.FC<
React.ButtonHTMLAttributes<HTMLButtonElement>
> = (props) => (
diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
index 28311b7442..32d02ee73c 100644
--- a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
+++ b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx
@@ -1,9 +1,11 @@
import { SearchBar, type SearchBarProps } from "@/components/SearchBar";
import { uploadManager } from "@/services/upload-manager";
import {
+ Album02Icon,
Home01Icon,
Settings01Icon,
Upload01Icon,
+ UserGroupIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Stack, SvgIcon, Tooltip } from "@mui/material";
@@ -13,13 +15,18 @@ import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton"
import { NavbarBase } from "ente-base/components/Navbar";
import { useIsSmallWidth } from "ente-base/components/utils/hooks";
import { ut } from "ente-base/i18n";
+import { isMLSupported } from "ente-new/photos/services/ml";
import { t } from "i18next";
import { useState, type ReactNode } from "react";
+import type { GalleryBarMode } from "./reducer";
+
type PhotosNavigationShellProps = SearchBarProps & {
onSidebar: () => void;
onUpload: () => void;
onHome: () => void;
+ mode: GalleryBarMode;
+ onChangeMode: (mode: GalleryBarMode) => void;
};
export const PhotosNavigationShell: React.FC<
@@ -111,7 +118,7 @@ export const PhotosNavigationShell: React.FC<
flex: 1,
minWidth: 0,
minHeight: 0,
- pt: showRail ? { xs: 0, sm: "12px" } : 0,
+ pt: showRail ? { xs: 0, sm: "36px" } : 0,
...(showRail && {
"--mui-palette-background-default": "#FFFFFF",
bgcolor: "background.default",
@@ -194,10 +201,45 @@ const NormalHeaderContents: React.FC<
};
const NormalNavigationRail: React.FC<
- SearchBarProps & { onSidebar: () => void; onHome: () => void }
-> = ({ onSidebar, onHome, ...props }) => (
+ Omit<PhotosNavigationShellProps, "onUpload">
+> = ({ onSidebar, onHome, mode, onChangeMode, ...props }) => (
<>
<HomeButton onClick={onHome} />
+ {(["albums", "people"] as const).map((item) =>
+ item == "people" && !isMLSupported ? null : (
+ <Tooltip key={item} title={t(item)}>
+ <FocusVisibleButton
+ color="secondary"
+ aria-label={t(item)}
+ aria-pressed={!props.isInSearchMode && mode == item}
+ onClick={() => onChangeMode(item)}
+ sx={{
+ minWidth: 0,
+ width: 38,
+ height: 38,
+ flexShrink: 0,
+ p: 0,
+ borderRadius: "12px",
+ color:
+ !props.isInSearchMode && mode == item
+ ? "#FFFFFF"
+ : "text.muted",
+ '&[aria-pressed="true"]': {
+ bgcolor: "accent.main",
+ "&:hover": { bgcolor: "accent.main" },
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={
+ item == "albums" ? Album02Icon : UserGroupIcon
+ }
+ size={20}
+ />
+ </FocusVisibleButton>
+ </Tooltip>
+ ),
+ )}
<SearchBar {...props} />
<Box sx={{ flex: 1 }} />
<Tooltip title={t("settings")}>
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 6dac2e8f25..5dab326984 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -1982,6 +1982,8 @@ const Page: React.FC = () => {
showRail
showNormalNavigation={showNormalNavigation}
isInSearchMode={isInSearchMode}
+ mode={barMode}
+ onChangeMode={handleChangeBarMode}
onSidebar={showSidebar}
onUpload={openUploader}
onHome={() =>
@@ -2068,7 +2070,6 @@ const Page: React.FC = () => {
? state.view.people
: undefined) ?? []
}
- onChangeMode={handleChangeBarMode}
setBlockingLoad={setBlockingLoad}
setActiveCollectionID={
handleShowCollectionSummaryWithID