Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web] Redesign uploader name dialog to match public album like modal

Anand Baburajan1cc27c0a79b6
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index e6c04a8f87..2a2938fab9 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -1,8 +1,7 @@
// TODO: Audit this file (too many null assertions + other issues)
/* eslint-disable @typescript-eslint/no-floating-promises */
-import { Download01Icon } from "@hugeicons/core-free-icons";
+import { Download01Icon, ImageAdd02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import AddPhotoAlternateOutlinedIcon from "@mui/icons-material/AddPhotoAlternateOutlined";
import CloseIcon from "@mui/icons-material/Close";
import { Box, Button, IconButton, Stack, styled, Tooltip } from "@mui/material";
@@ -702,16 +701,26 @@ const AddPhotosButton: React.FC<ButtonishProps> = ({ onClick }) => {
const disabled = uploadManager.isUploadInProgress();
const isSmallWidth = useIsSmallWidth();
- const icon = <AddPhotoAlternateOutlinedIcon />;
-
return (
<Box>
{isSmallWidth ? (
- <IconButton {...{ onClick, disabled }}>{icon}</IconButton>
+ <IconButton {...{ onClick, disabled }}>
+ <HugeiconsIcon
+ icon={ImageAdd02Icon}
+ size={22}
+ strokeWidth={1.8}
+ />
+ </IconButton>
) : (
<FocusVisibleButton
color="secondary"
- startIcon={icon}
+ startIcon={
+ <HugeiconsIcon
+ icon={ImageAdd02Icon}
+ size={20}
+ strokeWidth={1.8}
+ />
+ }
sx={{ borderRadius: "16px" }}
{...{ onClick, disabled }}
>
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index 3dd9b90874..b8520e0069 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -612,7 +612,7 @@
"today": "Today",
"yesterday": "Yesterday",
"enter_name": "Enter name",
- "uploader_name_hint": "Add a name so that your friends know who to thank for these great photos!",
+ "uploader_name_hint": "Let everyone know who's sharing these memories",
"name_placeholder": "Name...",
"more_details": "More details",
"ml_search": "Machine learning",
diff --git a/web/packages/new/albums/components/UploaderNameInput.tsx b/web/packages/new/albums/components/UploaderNameInput.tsx
index 8d951bd0c3..78cf0a94e2 100644
--- a/web/packages/new/albums/components/UploaderNameInput.tsx
+++ b/web/packages/new/albums/components/UploaderNameInput.tsx
@@ -1,23 +1,78 @@
-import AutoAwesomeOutlinedIcon from "@mui/icons-material/AutoAwesomeOutlined";
+import { User03Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import CloseIcon from "@mui/icons-material/Close";
import {
Box,
+ Button,
Dialog,
- DialogContent,
- DialogTitle,
- Stack,
+ IconButton,
+ styled,
TextField,
Typography,
- useMediaQuery,
} from "@mui/material";
-import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
-import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import type { ModalVisibilityProps } from "ente-base/components/utils/modal";
import log from "ente-base/log";
import { useFormik } from "formik";
import { t } from "i18next";
import React from "react";
-type UploaderNameInput = ModalVisibilityProps & {
+// =============================================================================
+// Sparkle Icons
+// =============================================================================
+
+const SparkleTopRight: React.FC = () => (
+ <svg
+ width="14"
+ height="16"
+ viewBox="0 0 20 22"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ style={{ position: "absolute", top: 0, right: 8 }}
+ >
+ <path
+ d="M19.728 9.21189C15.334 9.91374 11.912 12.6353 11.37 16.3181C11.912 12.6353 9.421 9.04853 5.4114 7.10627C9.806 6.40442 13.228 3.68284 13.77 7.55054e-05C13.228 3.68284 15.719 7.26962 19.728 9.21189Z"
+ fill="#08C225"
+ />
+ </svg>
+);
+
+const SparkleBottomRight: React.FC = () => (
+ <svg
+ width="22"
+ height="26"
+ viewBox="0 0 32 36"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ style={{ position: "absolute", bottom: 0, right: -8 }}
+ >
+ <path
+ d="M31.579 17.9746C23.591 18.7003 17.114 23.1692 15.689 29.722C17.114 23.1692 13.077 16.4145 6.1117 12.438C14.099 11.7122 20.576 7.2434 22.001 0.6902C20.576 7.2434 24.613 13.9981 31.579 17.9746Z"
+ fill="#08C225"
+ />
+ </svg>
+);
+
+const SparkleBottomLeft: React.FC = () => (
+ <svg
+ width="18"
+ height="16"
+ viewBox="0 0 26 22"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ style={{ position: "absolute", bottom: 8, left: -8 }}
+ >
+ <path
+ d="M25.9639 10.8477C19.9399 13.182 15.9104 18.0874 16.263 23.48C15.9104 18.0874 11.2832 13.7544 4.99991 12.2184C11.0238 9.884 15.0533 4.9787 14.7007 -0.4139C15.0533 4.9787 19.6805 9.3117 25.9639 10.8477Z"
+ fill="#08C225"
+ />
+ </svg>
+);
+
+// =============================================================================
+// Types
+// =============================================================================
+
+type UploaderNameInputProps = ModalVisibilityProps & {
/**
* The existing uploader name to prefill.
*/
@@ -36,43 +91,51 @@ type UploaderNameInput = ModalVisibilityProps & {
* A dialog asking the uploader to a public album to provide their name so that
* other folks can know who uploaded a given photo in the shared album.
*/
-export const UploaderNameInput: React.FC<UploaderNameInput> = ({
+export const UploaderNameInput: React.FC<UploaderNameInputProps> = ({
open,
onClose,
uploaderName,
uploadFileCount,
onSubmit,
}) => {
- // Make the dialog fullscreen if it starts to get too squished.
- const fullScreen = useMediaQuery("(width < 400px)");
-
return (
- <Dialog
- {...{ open, onClose, fullScreen }}
- slotProps={{
- paper: { sx: fullScreen ? {} : { maxWidth: "346px" } },
- }}
- fullWidth
- >
- <Box
- sx={(theme) => ({
- padding: "24px 16px 0px 16px",
- svg: { width: "44px", height: "44px" },
- color: theme.vars.palette.stroke.muted,
- })}
- >
- {<AutoAwesomeOutlinedIcon />}
- </Box>
- <DialogTitle>{t("enter_name")}</DialogTitle>
- <DialogContent>
- <Typography sx={{ color: "text.muted", pb: 1 }}>
- {t("uploader_name_hint")}
- </Typography>
- <UploaderNameInputForm
- {...{ onClose, uploaderName, uploadFileCount, onSubmit }}
- />
- </DialogContent>
- </Dialog>
+ <StyledDialog open={open} onClose={onClose}>
+ <DialogWrapper>
+ <CloseButton onClick={onClose}>
+ <CloseIcon sx={{ fontSize: 20 }} />
+ </CloseButton>
+
+ <ContentContainer>
+ <IllustrationContainer>
+ <SparkleTopRight />
+ <SparkleBottomRight />
+ <SparkleBottomLeft />
+ <IllustrationWrapper>
+ <HugeiconsIcon
+ icon={User03Icon}
+ size={28}
+ color="#fff"
+ strokeWidth={1.8}
+ />
+ </IllustrationWrapper>
+ </IllustrationContainer>
+
+ <TitleSection>
+ <Title>{t("enter_name")}</Title>
+ <Subtitle>{t("uploader_name_hint")}</Subtitle>
+ </TitleSection>
+
+ <UploaderNameInputForm
+ {...{
+ onClose,
+ uploaderName,
+ uploadFileCount,
+ onSubmit,
+ }}
+ />
+ </ContentContainer>
+ </DialogWrapper>
+ </StyledDialog>
);
};
@@ -83,7 +146,7 @@ export const UploaderNameInput: React.FC<UploaderNameInput> = ({
* (e.g. uploaderName changes).
*/
export const UploaderNameInputForm: React.FC<
- Omit<UploaderNameInput, "open">
+ Omit<UploaderNameInputProps, "open">
> = ({ onClose, uploaderName, uploadFileCount, onSubmit }) => {
const formik = useFormik({
initialValues: { value: uploaderName },
@@ -107,43 +170,212 @@ export const UploaderNameInputForm: React.FC<
});
return (
- <form onSubmit={formik.handleSubmit}>
- <TextField
+ <FormContainer onSubmit={formik.handleSubmit}>
+ <StyledTextField
name="value"
value={formik.values.value}
onChange={formik.handleChange}
- type={"text"}
+ type="text"
+ variant="standard"
fullWidth
autoFocus
- margin="normal"
hiddenLabel
aria-label={t("name")}
placeholder={t("name_placeholder")}
disabled={formik.isSubmitting}
error={!!formik.errors.value}
- // As an exception, we don't use an space character default here
- // since that skews dialog's look too much in the happy case.
- //
- // The downside is that there will be a layout shift on errors.
helperText={formik.errors.value}
/>
- <Stack sx={{ mt: 1.5, gap: 1 }}>
- <LoadingButton
- fullWidth
+ <ButtonsSection>
+ <SubmitButton
type="submit"
- loading={formik.isSubmitting}
- color="accent"
+ variant="contained"
+ disabled={
+ formik.isSubmitting || !formik.values.value.trim()
+ }
+ hasName={!!formik.values.value.trim()}
>
- {t("add_photos_count", { count: uploadFileCount })}
- </LoadingButton>
- <FocusVisibleButton
- fullWidth
- color="secondary"
- onClick={onClose}
- >
- {t("cancel")}
- </FocusVisibleButton>
- </Stack>
- </form>
+ {formik.isSubmitting
+ ? t("loading")
+ : t("add_photos_count", { count: uploadFileCount })}
+ </SubmitButton>
+ </ButtonsSection>
+ </FormContainer>
);
};
+
+// =============================================================================
+// Styled Components
+// =============================================================================
+
+const StyledDialog = styled(Dialog)(({ theme }) => ({
+ "& .MuiDialog-paper": {
+ width: 381,
+ maxWidth: "calc(100% - 32px)",
+ borderRadius: 28,
+ backgroundColor: "#fff",
+ padding: 0,
+ margin: 16,
+ overflow: "visible",
+ boxShadow: "none",
+ border: "1px solid #E0E0E0",
+ ...theme.applyStyles("dark", {
+ backgroundColor: "#1b1b1b",
+ border: "1px solid rgba(255, 255, 255, 0.18)",
+ }),
+ },
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
+}));
+
+const DialogWrapper = styled(Box)(() => ({
+ position: "relative",
+ padding: "48px 16px 16px 16px",
+}));
+
+const CloseButton = styled(IconButton)(({ theme }) => ({
+ position: "absolute",
+ top: 11,
+ right: 12,
+ backgroundColor: "#FAFAFA",
+ color: "#000",
+ padding: 10,
+ "&:hover": { backgroundColor: "#F0F0F0" },
+ ...theme.applyStyles("dark", {
+ backgroundColor: "rgba(255, 255, 255, 0.12)",
+ color: "#fff",
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },
+ }),
+}));
+
+const ContentContainer = styled(Box)(() => ({
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ gap: 16,
+}));
+
+const IllustrationContainer = styled(Box)(() => ({
+ position: "relative",
+ width: 100,
+ height: 70,
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ marginBottom: 8,
+}));
+
+const IllustrationWrapper = styled(Box)(() => ({
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ width: 52,
+ height: 52,
+ borderRadius: "50%",
+ backgroundColor: "#08C225",
+}));
+
+const TitleSection = styled(Box)(() => ({
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ gap: 9,
+ textAlign: "center",
+ marginBottom: 8,
+}));
+
+const Title = styled(Typography)(({ theme }) => ({
+ fontWeight: 600,
+ fontSize: 24,
+ lineHeight: "28px",
+ letterSpacing: "-0.48px",
+ color: "#000",
+ ...theme.applyStyles("dark", { color: "#fff" }),
+}));
+
+const Subtitle = styled(Typography)(({ theme }) => ({
+ fontWeight: 500,
+ fontSize: 14,
+ lineHeight: "20px",
+ color: "#666666",
+ maxWidth: "75%",
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
+}));
+
+const FormContainer = styled("form")(() => ({
+ width: "100%",
+ display: "flex",
+ flexDirection: "column",
+ gap: 16,
+}));
+
+const StyledTextField = styled(TextField)(({ theme }) => ({
+ "& .MuiInput-root": {
+ height: 54,
+ backgroundColor: "#FAFAFA",
+ borderRadius: 12,
+ "&::before": { borderBottom: "1px solid #E0E0E0" },
+ "&::after": { borderBottom: "2px solid #08C225" },
+ "&:hover:not(.Mui-disabled)::before": {
+ borderBottom: "1px solid #BDBDBD",
+ },
+ },
+ "& .MuiInputBase-input": {
+ padding: "0 16px",
+ height: "100%",
+ boxSizing: "border-box",
+ fontSize: 16,
+ color: "#000",
+ "&::placeholder": { color: "#999", opacity: 1 },
+ },
+ ...theme.applyStyles("dark", {
+ "& .MuiInput-root": {
+ backgroundColor: "rgba(255, 255, 255, 0.08)",
+ "&::before": { borderBottom: "1px solid rgba(255, 255, 255, 0.3)" },
+ "&:hover:not(.Mui-disabled)::before": {
+ borderBottom: "1px solid rgba(255, 255, 255, 0.5)",
+ },
+ },
+ "& .MuiInputBase-input": {
+ color: "#fff",
+ "&::placeholder": { color: "rgba(255, 255, 255, 0.5)" },
+ },
+ }),
+}));
+
+const ButtonsSection = styled(Box)(() => ({
+ width: "100%",
+ display: "flex",
+ flexDirection: "row",
+ gap: 12,
+}));
+
+const SubmitButton = styled(Button)<{ hasName: boolean }>(
+ ({ hasName, theme }) => ({
+ display: "flex",
+ padding: "16px",
+ justifyContent: "center",
+ alignItems: "center",
+ gap: 8,
+ flex: 1,
+ borderRadius: 20,
+ backgroundColor: hasName ? "#08C225" : "rgba(0, 0, 0, 0.04)",
+ fontSize: 16,
+ fontWeight: 500,
+ textTransform: "none",
+ color: hasName ? "#fff" : "#999",
+ boxShadow: "none",
+ "&:hover": {
+ backgroundColor: hasName ? "#07A820" : "rgba(0, 0, 0, 0.08)",
+ boxShadow: "none",
+ },
+ ...theme.applyStyles("dark", {
+ backgroundColor: hasName ? "#08C225" : "rgba(255, 255, 255, 0.08)",
+ color: hasName ? "#fff" : "rgba(255, 255, 255, 0.5)",
+ "&:hover": {
+ backgroundColor: hasName
+ ? "#07A820"
+ : "rgba(255, 255, 255, 0.12)",
+ },
+ }),
+ }),
+);