Skip to content

armgit / ente

Public Imported from GitHub
0

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

Match person naming dialogs to People popup styling

vijayadithyanpj08a82f3148a2
diff --git a/web/apps/photos/src/components/Collections/AllPeople.tsx b/web/apps/photos/src/components/Collections/AllPeople.tsx
index 226296adb9..965228619a 100644
--- a/web/apps/photos/src/components/Collections/AllPeople.tsx
+++ b/web/apps/photos/src/components/Collections/AllPeople.tsx
@@ -34,7 +34,6 @@ import {
Box,
Button,
Dialog,
- DialogContent,
IconButton,
Stack,
Tooltip,
@@ -42,7 +41,6 @@ import {
styled,
useMediaQuery,
} from "@mui/material";
-import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconButton";
import {
OverflowMenu,
OverflowMenuOption,
@@ -50,12 +48,7 @@ import {
import { SingleInputDialog } from "ente-base/components/SingleInputDialog";
import { useBaseContext } from "ente-base/context";
import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
-import {
- ItemCard,
- LargeTileButton,
- LargeTileCreateNewButton,
- LargeTileTextOverlay,
-} from "ente-new/photos/components/Tiles";
+import { ItemCard } from "ente-new/photos/components/Tiles";
import {
addCGroup,
addClusterToCGroup,
@@ -888,7 +881,8 @@ const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
people,
cluster,
}) => {
- const isFullScreen = useMediaQuery("(max-width: 490px)");
+ const isFullScreen = useMediaQuery(collectionDialogFullScreenQuery);
+ const titleID = useId();
const [openNameInput, setOpenNameInput] = useState(false);
const cgroupPeople: CGroupPerson[] = people.filter(
@@ -931,18 +925,69 @@ const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
<Dialog
open={open && !openNameInput && cgroupPeople.length > 0}
onClose={onClose}
- fullWidth
fullScreen={isFullScreen}
- slotProps={{ paper: { sx: { maxWidth: "490px" } } }}
+ aria-labelledby={titleID}
+ maxWidth={false}
+ sx={{
+ "& .MuiDialog-paper": {
+ borderRadius: "32px",
+ [`@media ${collectionDialogFullScreenQuery}`]: {
+ borderRadius: 0,
+ },
+ },
+ }}
+ slots={{ transition: SlideUpTransition }}
+ slotProps={{ paper: { sx: collectionDialogPaperSx } }}
>
- <DialogTitle_>
- <Typography variant="h3">{t("add_name")}</Typography>
- <DialogCloseIconButton {...{ onClose }} />
- </DialogTitle_>
+ <Stack sx={collectionDialogHeaderSx}>
+ <Stack direction="row" sx={collectionDialogHeaderRowSx}>
+ <Typography id={titleID} sx={collectionDialogTitleSx}>
+ {t("add_name")}
+ </Typography>
+ <IconButton
+ aria-label={t("close")}
+ onClick={onClose}
+ sx={collectionDialogIconButtonSx}
+ >
+ <CloseIcon sx={{ fontSize: 20 }} />
+ </IconButton>
+ </Stack>
+ </Stack>
+ <Box sx={collectionDialogDividerSx} />
<DialogContent_>
- <LargeTileCreateNewButton onClick={handleAddPerson}>
- {t("new_person")}
- </LargeTileCreateNewButton>
+ <CollectionTileButton
+ onClick={handleAddPerson}
+ aria-label={t("new_person")}
+ sx={{
+ boxSizing: "border-box",
+ border: "1px dashed",
+ borderColor: "stroke.muted",
+ backgroundColor: "fill.faint",
+ "&:hover": { backgroundColor: "fill.faintHover" },
+ }}
+ >
+ <Typography
+ sx={{
+ position: "absolute",
+ top: 10,
+ left: 10,
+ right: 10,
+ fontSize: 14,
+ lineHeight: "20px",
+ fontWeight: 500,
+ }}
+ >
+ {t("new_person")}
+ </Typography>
+ <AddIcon
+ sx={{
+ position: "absolute",
+ top: "50%",
+ left: "50%",
+ transform: "translate(-50%, -50%)",
+ }}
+ />
+ </CollectionTileButton>
{cgroupPeople.map((person) => (
<PersonPickerCard
key={person.id}
@@ -955,6 +1000,8 @@ const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
<SingleInputDialog
open={openNameInput}
+ variant="v2"
+ sx={{ "& .MuiDialog-paper": { borderRadius: "32px" } }}
onClose={() => {
setOpenNameInput(false);
if (!cgroupPeople.length) {
@@ -973,19 +1020,23 @@ const AddPersonDialog: React.FC<AddPersonDialogProps> = ({
);
};
-const DialogTitle_ = styled(Box)({
- display: "flex",
- justifyContent: "space-between",
- alignItems: "center",
- padding: "10px 8px 6px 24px",
+const DialogContent_ = styled(Box)({
+ flex: 1,
+ minHeight: 0,
+ overflowY: "auto",
+ display: "grid",
+ gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
+ gridAutoRows: "max-content",
+ alignContent: "start",
+ alignItems: "start",
+ gap: `${GridGap}px`,
+ // Keep the scroll track clear of the dialog's rounded bottom corners.
+ marginBlock: "16px 32px",
+ marginInlineEnd: "8px",
+ paddingInline: `${GridPaddingInline}px ${GridPaddingInline - 8}px`,
+ scrollbarGutter: "stable",
});
-const DialogContent_ = styled(DialogContent)`
- display: flex;
- flex-wrap: wrap;
- gap: 4px;
-`;
-
interface PersonPickerCardProps {
person: Person;
onPersonClick: (personID: string) => void;
@@ -996,13 +1047,29 @@ const PersonPickerCard: React.FC<PersonPickerCardProps> = ({
onPersonClick,
}) => (
<ItemCard
- TileComponent={LargeTileButton}
+ TileComponent={CollectionTileButton}
coverFile={person.displayFaceFile}
coverFaceID={person.displayFaceID}
onClick={() => onPersonClick(person.id)}
>
- <LargeTileTextOverlay>
- <Typography>{person.name ?? ""}</Typography>
- </LargeTileTextOverlay>
+ <CollectionTileTextOverlay>
+ <Tooltip title={person.name ?? ""} arrow>
+ <Typography
+ sx={{
+ fontSize: 14,
+ lineHeight: "20px",
+ fontWeight: 500,
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ display: "-webkit-box",
+ WebkitLineClamp: 3,
+ WebkitBoxOrient: "vertical",
+ overflowWrap: "anywhere",
+ }}
+ >
+ {person.name ?? ""}
+ </Typography>
+ </Tooltip>
+ </CollectionTileTextOverlay>
</ItemCard>
);
diff --git a/web/packages/base/components/SingleInputDialog.tsx b/web/packages/base/components/SingleInputDialog.tsx
index 8031dd721d..606659c77f 100644
--- a/web/packages/base/components/SingleInputDialog.tsx
+++ b/web/packages/base/components/SingleInputDialog.tsx
@@ -11,20 +11,25 @@ import {
} from "@mui/material";
import type { ModalVisibilityProps } from "ente-base/components/utils/modal";
import { t } from "i18next";
-import React, { useCallback } from "react";
+import React, { useCallback, useId } from "react";
import { SingleInputForm, type SingleInputFormProps } from "./SingleInputForm";
type SingleInputDialogProps = ModalVisibilityProps &
- Omit<SingleInputFormProps, "onCancel"> & { title: string };
+ Omit<SingleInputFormProps, "onCancel"> & {
+ title: string;
+ sx?: SxProps<Theme>;
+ };
export const SingleInputDialog: React.FC<SingleInputDialogProps> = ({
open,
onClose,
onSubmit,
title,
+ sx,
variant = "default",
...rest
}) => {
+ const titleID = useId();
const handleSubmit: SingleInputFormProps["onSubmit"] = useCallback(
async (value, setFieldError) => {
await onSubmit(value, setFieldError);
@@ -39,11 +44,15 @@ export const SingleInputDialog: React.FC<SingleInputDialogProps> = ({
open={open}
onClose={onClose}
maxWidth={false}
+ aria-labelledby={titleID}
+ sx={sx}
slotProps={{ paper: { sx: v2PaperSx } }}
>
<Stack sx={{ p: "20px", gap: "20px" }}>
<Stack direction="row" sx={v2HeaderRowSx}>
- <Typography sx={v2TitleSx}>{title}</Typography>
+ <Typography id={titleID} sx={v2TitleSx}>
+ {title}
+ </Typography>
<IconButton
aria-label={t("close")}
onClick={onClose}
@@ -70,6 +79,7 @@ export const SingleInputDialog: React.FC<SingleInputDialogProps> = ({
onClose={onClose}
maxWidth="xs"
fullWidth
+ sx={sx}
slotProps={{ paper: { sx: { p: "8px 4px 4px 4px" } } }}
>
<DialogTitle>{title}</DialogTitle>
diff --git a/web/packages/base/components/SingleInputForm.tsx b/web/packages/base/components/SingleInputForm.tsx
index 9cdabec348..6c9ba22300 100644
--- a/web/packages/base/components/SingleInputForm.tsx
+++ b/web/packages/base/components/SingleInputForm.tsx
@@ -15,7 +15,7 @@ import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import log from "ente-base/log";
import { useFormik } from "formik";
import { t } from "i18next";
-import React, { useCallback, useState } from "react";
+import React, { useCallback, useId, useState } from "react";
import { ShowHidePasswordInputAdornment } from "./mui/PasswordInputAdornment";
export type SingleInputFormProps = Pick<
@@ -48,6 +48,8 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
onSubmit,
...rest
}) => {
+ const inputID = useId();
+ const helperID = useId();
const [showPassword, setShowPassword] = useState(false);
const handleToggleShowHidePassword = useCallback(
@@ -86,9 +88,17 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
>
<Stack sx={{ gap: "8px" }}>
{rest.label && (
- <Typography sx={v2LabelSx}>{rest.label}</Typography>
+ <Typography
+ component="label"
+ htmlFor={inputID}
+ sx={v2LabelSx}
+ >
+ {rest.label}
+ </Typography>
)}
<InputBase
+ id={inputID}
+ aria-describedby={error ? helperID : undefined}
name="value"
value={formik.values.value}
onChange={formik.handleChange}
@@ -100,7 +110,11 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({
error={!!error}
sx={v2InputSx}
/>
- <Typography sx={v2HelperSx(!!error)}>
+ <Typography
+ id={helperID}
+ aria-live="polite"
+ sx={v2HelperSx(!!error)}
+ >
{error ?? ""}
</Typography>
</Stack>
@@ -241,6 +255,11 @@ const v2BaseActionSx = {
lineHeight: "20px",
fontWeight: 500,
fontFamily: "inherit",
+ "&.Mui-focusVisible": {
+ outline: "1px solid",
+ outlineColor: "stroke.base",
+ outlineOffset: "2px",
+ },
"&.Mui-disabled": { opacity: 0.7 },
};
const v2CancelButtonSx = (theme: Theme) => ({