Skip to content

armgit / ente

Public Imported from GitHub
0

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

Dup

Manav Rathiec115b3f8b17
diff --git a/web/apps/photos/src/components/Collections/AllCollections/content.tsx b/web/apps/photos/src/components/Collections/AllCollections/content.tsx
index 5b8be1e863..019c52065b 100644
--- a/web/apps/photos/src/components/Collections/AllCollections/content.tsx
+++ b/web/apps/photos/src/components/Collections/AllCollections/content.tsx
@@ -1,6 +1,6 @@
import {
- CollectionTileButton,
ItemCard,
+ LargeTileButton,
LargeTileTextOverlay,
} from "@/new/photos/components/Tiles";
import type { CollectionSummary } from "@/new/photos/services/collection/ui";
@@ -166,7 +166,7 @@ const CollectionButton: React.FC<AllCollectionCardProps> = ({
isScrolling,
}) => (
<ItemCard
- TileComponent={CollectionTileButton}
+ TileComponent={LargeTileButton}
coverFile={collectionSummary.coverFile}
onClick={() => onCollectionClick(collectionSummary.id)}
isScrolling={isScrolling}
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index 936e776a77..48bfd70b88 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -1,8 +1,8 @@
import type { Collection } from "@/media/collection";
import {
- CollectionTileButton,
ItemCard,
- ItemTileOverlay,
+ LargeTileButton,
+ LargeTilePlusOverlay,
LargeTileTextOverlay,
} from "@/new/photos/components/Tiles";
import {
@@ -23,7 +23,7 @@ import {
} from "@mui/material";
import { t } from "i18next";
import React, { useEffect, useState } from "react";
-import { SpaceBetweenFlex } from "./mui";
+import { SpaceBetweenFlex, type ButtonishProps } from "./mui";
import {
DialogCloseIconButton,
type DialogVisibilityProps,
@@ -221,7 +221,7 @@ const CollectionButton: React.FC<CollectionButtonProps> = ({
onCollectionClick,
}) => (
<ItemCard
- TileComponent={CollectionTileButton}
+ TileComponent={LargeTileButton}
coverFile={collectionSummary.coverFile}
onClick={() => onCollectionClick(collectionSummary.id)}
>
@@ -231,22 +231,9 @@ const CollectionButton: React.FC<CollectionButtonProps> = ({
</ItemCard>
);
-interface AddCollectionButtonProps {
- onClick: () => void;
-}
-
-const AddCollectionButton: React.FC<AddCollectionButtonProps> = ({
- onClick,
-}) => (
- <ItemCard TileComponent={CollectionTileButton} onClick={onClick}>
+const AddCollectionButton: React.FC<ButtonishProps> = ({ onClick }) => (
+ <ItemCard TileComponent={LargeTileButton} onClick={onClick}>
<LargeTileTextOverlay>{t("create_albums")}</LargeTileTextOverlay>
- <PlusOverlay>+</PlusOverlay>
+ <LargeTilePlusOverlay>+</LargeTilePlusOverlay>
</ItemCard>
);
-
-const PlusOverlay = styled(ItemTileOverlay)`
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 42px;
-`;
diff --git a/web/packages/new/photos/components/PeopleSelector.tsx b/web/packages/new/photos/components/PeopleSelector.tsx
index cff12f9359..5b98ce9868 100644
--- a/web/packages/new/photos/components/PeopleSelector.tsx
+++ b/web/packages/new/photos/components/PeopleSelector.tsx
@@ -1,7 +1,26 @@
-import { useIsMobileWidth } from "@/base/hooks";
-import { Dialog } from "@mui/material";
+import { pt } from "@/base/i18n";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ styled,
+ Typography,
+ useMediaQuery,
+} from "@mui/material";
+import { t } from "i18next";
import React from "react";
-import type { DialogVisibilityProps } from "./mui/Dialog";
+import type { CollectionSummary } from "../services/collection/ui";
+import { SpaceBetweenFlex, type ButtonishProps } from "./mui";
+import {
+ DialogCloseIconButton,
+ type DialogVisibilityProps,
+} from "./mui/Dialog";
+import {
+ ItemCard,
+ LargeTileButton,
+ LargeTilePlusOverlay,
+ LargeTileTextOverlay,
+} from "./Tiles";
type PeopleSelectorProps = DialogVisibilityProps;
@@ -9,16 +28,73 @@ export const PeopleSelector: React.FC<PeopleSelectorProps> = ({
open,
onClose,
}) => {
- const isFullScreen = useIsMobileWidth();
+ const isFullScreen = useMediaQuery("(max-width: 490px)");
+
+ const filteredCollections: CollectionSummary[] = [];
+ const handleAddPerson = () => {
+ console.log("handleAddPerson");
+ };
+ const handleSelectPerson = (id: string) => {
+ console.log("handleSelectPerson", id);
+ };
return (
<Dialog
{...{ open, onClose }}
fullWidth
fullScreen={isFullScreen}
- maxWidth={"sm"}
+ PaperProps={{ sx: { maxWidth: "490px" } }}
>
- Hello
+ <SpaceBetweenFlex sx={{ padding: "10px 8px 6px 0" }}>
+ <DialogTitle variant="h3" fontWeight={"bold"}>
+ {pt("Add name")}
+ </DialogTitle>
+ <DialogCloseIconButton {...{ onClose }} />
+ </SpaceBetweenFlex>
+
+ <DialogContent_>
+ <AddPerson onClick={handleAddPerson} />
+ {filteredCollections.map((person) => (
+ <PersonButton
+ key={person.id}
+ person={person}
+ onPersonClick={handleSelectPerson}
+ />
+ ))}
+ </DialogContent_>
</Dialog>
);
};
+
+const DialogContent_ = styled(DialogContent)`
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px;
+`;
+
+interface PersonButtonProps {
+ person: CollectionSummary;
+ onPersonClick: (personID: string) => void;
+}
+
+const PersonButton: React.FC<PersonButtonProps> = ({
+ person,
+ onPersonClick,
+}) => (
+ <ItemCard
+ TileComponent={LargeTileButton}
+ // coverFile={collectionSummary.coverFile}
+ onClick={() => onPersonClick(person.id.toString())}
+ >
+ <LargeTileTextOverlay>
+ <Typography>{person.name}</Typography>
+ </LargeTileTextOverlay>
+ </ItemCard>
+);
+
+const AddPerson: React.FC<ButtonishProps> = ({ onClick }) => (
+ <ItemCard TileComponent={LargeTileButton} onClick={onClick}>
+ <LargeTileTextOverlay>{t("New person")}</LargeTileTextOverlay>
+ <LargeTilePlusOverlay>+</LargeTilePlusOverlay>
+ </ItemCard>
+);
diff --git a/web/packages/new/photos/components/Tiles.tsx b/web/packages/new/photos/components/Tiles.tsx
index c687f26224..cb0a340d85 100644
--- a/web/packages/new/photos/components/Tiles.tsx
+++ b/web/packages/new/photos/components/Tiles.tsx
@@ -102,7 +102,7 @@ export const ItemCard: React.FC<React.PropsWithChildren<ItemCardProps>> = ({
* Use {@link ItemTileOverlay} (usually via one of its presets) to overlay
* content on top of the tile.
*/
-export const ItemTile = styled("div")`
+export const BaseTile = styled("div")`
display: flex;
/* Act as container for the absolutely positioned ItemTileOverlays. */
position: relative;
@@ -122,7 +122,7 @@ export const ItemTile = styled("div")`
* A 48x48 TileComponent used in search result dropdown's preview files and
* other places.
*/
-export const PreviewItemTile = styled(ItemTile)`
+export const PreviewItemTile = styled(BaseTile)`
width: 48px;
height: 48px;
`;
@@ -130,15 +130,15 @@ export const PreviewItemTile = styled(ItemTile)`
/**
* A rectangular, TV-ish tile used in the gallery bar.
*/
-export const BarItemTile = styled(ItemTile)`
+export const BarItemTile = styled(BaseTile)`
width: 90px;
height: 64px;
`;
/**
- * A variant of {@link ItemTile} meant for use when the tile is interactable.
+ * A variant of {@link BaseTile} meant for use when the tile is interactable.
*/
-export const ItemTileButton = styled(UnstyledButton)`
+export const BaseTileButton = styled(UnstyledButton)`
/* Buttons reset this to center */
text-align: inherit;
@@ -158,10 +158,10 @@ export const ItemTileButton = styled(UnstyledButton)`
`;
/**
- * A large 150x150 TileComponent used when showing the list of collections in
- * the all collections view and in the collection selector.
+ * A large 150x150 TileComponent used when, for example, when showing the list
+ * of collections in the all collections view and in the collection selector.
*/
-export const CollectionTileButton = styled(ItemTileButton)`
+export const LargeTileButton = styled(BaseTileButton)`
width: 150px;
height: 150px;
`;
@@ -169,7 +169,8 @@ export const CollectionTileButton = styled(ItemTileButton)`
/**
* An empty overlay on top of the nearest relative positioned ancestor.
*
- * This is meant to be used in tandem with {@link ItemTile}.
+ * This is meant to be used in tandem with a derivate of {@link BaseTile} or
+ * {@link BaseTileButton}.
*/
export const ItemTileOverlay = styled("div")`
position: absolute;
@@ -204,3 +205,14 @@ export const LargeTileTextOverlay = styled(ItemTileOverlay)`
rgba(0, 0, 0, 0.5) 86.46%
);
`;
+
+/**
+ * A container for "+", suitable for use with a {@link LargeTileTextOverlay}.
+ */
+export const LargeTilePlusOverlay = styled(ItemTileOverlay)`
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ font-size: 42px;
+ color: ${({ theme }) => theme.colors.stroke.muted};
+`;
diff --git a/web/packages/new/photos/components/mui/index.tsx b/web/packages/new/photos/components/mui/index.tsx
index bb88e71bb0..735de83bd4 100644
--- a/web/packages/new/photos/components/mui/index.tsx
+++ b/web/packages/new/photos/components/mui/index.tsx
@@ -1,5 +1,10 @@
import { Box, IconButton, styled } from "@mui/material";
+/** Convenience typed props for a component that acts like a push button. */
+export interface ButtonishProps {
+ onClick: () => void;
+}
+
/**
* A MUI {@link IconButton} filled in with at faint background.
*/