Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat(photos):add-new-auth-form-components

Aswin Asok7b8e1b83df2f
diff --git a/web/apps/photos/src/components/PhotosAuthShell.tsx b/web/apps/photos/src/components/PhotosAuthShell.tsx
index 91e6577771..d4f8c78410 100644
--- a/web/apps/photos/src/components/PhotosAuthShell.tsx
+++ b/web/apps/photos/src/components/PhotosAuthShell.tsx
@@ -1,9 +1,14 @@
import { Tick02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { styled } from "@mui/material";
+import { GlobalStyles, styled } from "@mui/material";
import { EnteLogo } from "ente-base/components/EnteLogo";
import { pt } from "ente-base/i18n";
import type React from "react";
+import {
+ authAboveMobileMediaQuery,
+ authColorVariables,
+ authDisplayFontFamily,
+} from "./auth/styles";
interface PhotosAuthShellProps extends React.PropsWithChildren {
contentWidth?: 400 | 420;
@@ -14,6 +19,7 @@ export const PhotosAuthShell: React.FC<PhotosAuthShellProps> = ({
contentWidth = 400,
}) => (
<PageRoot>
+ <GlobalStyles styles={authColorVariables} />
<FrameCurves />
<PageCard>
<DesktopBrandSlot>
@@ -91,7 +97,7 @@ const PageRoot = styled("main")(({ theme }) => ({
boxSizing: "border-box",
backgroundColor: "#f4f4f4",
...theme.applyStyles("dark", { backgroundColor: "#0a0a0a" }),
- "@media (min-width: 640px)": { padding: "40px" },
+ [authAboveMobileMediaQuery]: { padding: "40px" },
"@media (min-width: 1024px)": {
padding: 0,
alignItems: "center",
@@ -103,7 +109,7 @@ const FrameCurves = styled("div")(({ theme }) => ({
display: "none",
opacity: 0.3,
...theme.applyStyles("dark", { opacity: 0.02 }),
- "@media (min-width: 640px)": {
+ [authAboveMobileMediaQuery]: {
display: "block",
position: "absolute",
inset: 0,
@@ -125,7 +131,7 @@ const PageCard = styled("div")(({ theme }) => ({
overflow: "hidden",
backgroundColor: "#fff",
...theme.applyStyles("dark", { backgroundColor: "#252525" }),
- "@media (min-width: 640px)": { borderRadius: "24px" },
+ [authAboveMobileMediaQuery]: { borderRadius: "24px" },
"@media (min-width: 1024px)": {
width: "1032px",
height: "740px",
@@ -146,7 +152,7 @@ const DesktopBrandSlot = styled("div")({
const TabletBrandSlot = styled("div")({
display: "none",
- "@media (min-width: 640px) and (max-width: 1023px)": {
+ [`${authAboveMobileMediaQuery} and (max-width: 1023px)`]: {
display: "block",
// Grows with the copy when it wraps at narrow widths; the band's
// 268px design height is enforced as a minimum by BrandPanelRoot.
@@ -162,7 +168,7 @@ const MobileBrandSlot = styled("div")({
minHeight: 0,
position: "relative",
overflow: "hidden",
- "@media (min-width: 640px)": { display: "none" },
+ [authAboveMobileMediaQuery]: { display: "none" },
});
const ContentSheet = styled("section")(({ theme }) => ({
@@ -180,7 +186,7 @@ const ContentSheet = styled("section")(({ theme }) => ({
borderRadius: "24px 24px 0 0",
backgroundColor: "#fff",
...theme.applyStyles("dark", { backgroundColor: "#252525" }),
- "@media (min-width: 640px)": {
+ [authAboveMobileMediaQuery]: {
marginTop: "-32px",
padding: "16px 48px 48px",
},
@@ -195,16 +201,15 @@ const ContentSheet = styled("section")(({ theme }) => ({
"@media (min-width: 1600px)": { width: "744px", padding: "56px 172px" },
}));
-const SheetHandle = styled("div")(({ theme }) => ({
+const SheetHandle = styled("div")({
width: "36px",
height: "4px",
flexShrink: 0,
alignSelf: "center",
borderRadius: "999px",
- backgroundColor: "#d2d2d2",
- ...theme.applyStyles("dark", { backgroundColor: "#292929" }),
+ backgroundColor: "var(--photos-auth-fill-active)",
"@media (min-width: 1024px)": { display: "none" },
-}));
+});
const ContentColumn = styled("div", {
shouldForwardProp: (prop) => prop !== "contentWidth",
@@ -214,7 +219,7 @@ const ContentColumn = styled("div", {
display: "flex",
flexDirection: "column",
gap: "24px",
- "@media (min-width: 640px)": {
+ [authAboveMobileMediaQuery]: {
width: "440px",
maxWidth: "100%",
marginBlock: "auto",
@@ -243,7 +248,7 @@ const BrandPanelRoot = styled("div", {
overflow: "hidden",
boxSizing: "border-box",
color: "#fff",
- backgroundColor: "#08c225",
+ backgroundColor: "var(--photos-auth-primary)",
backgroundImage: `url("/images/auth-surface-noise.svg"), url("/images/auth-frame-curves.svg"), url("${greenTileP3}")`,
backgroundRepeat: "repeat, no-repeat, repeat",
backgroundSize: "auto, cover, auto",
@@ -285,7 +290,7 @@ const PanelHeadline = styled("h1", {
maxWidth:
size === "desktop" ? "300px" : size === "tablet" ? "380px" : "188px",
margin: 0,
- fontFamily: '"Outfit Variable", sans-serif',
+ fontFamily: authDisplayFontFamily,
fontSize: size === "desktop" ? "42px" : size === "tablet" ? "34px" : "26px",
fontWeight: 600,
lineHeight:
diff --git a/web/apps/photos/src/components/auth/Button.tsx b/web/apps/photos/src/components/auth/Button.tsx
new file mode 100644
index 0000000000..fb9cfbb889
--- /dev/null
+++ b/web/apps/photos/src/components/auth/Button.tsx
@@ -0,0 +1,101 @@
+import { CircularProgress, styled } from "@mui/material";
+import type React from "react";
+import {
+ authBodyTypography,
+ authFocusRing,
+ authTransientProps,
+} from "./styles";
+
+export type ButtonVariant = "primary" | "secondary";
+
+export interface ButtonProps extends Omit<
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
+ "color" | "children"
+> {
+ variant?: ButtonVariant;
+ fullWidth?: boolean;
+ loading?: boolean;
+ children: React.ReactNode;
+}
+
+export function Button({
+ variant = "primary",
+ fullWidth = false,
+ loading = false,
+ disabled,
+ type = "button",
+ children,
+ ...buttonProps
+}: ButtonProps): React.JSX.Element {
+ return (
+ <ButtonRoot
+ type={type}
+ disabled={disabled || loading}
+ aria-busy={loading || undefined}
+ $variant={variant}
+ $fullWidth={fullWidth}
+ $loading={loading}
+ {...buttonProps}
+ >
+ <ButtonLabel $loading={loading}>{children}</ButtonLabel>
+ {loading && <CircularProgress size={20} color="inherit" />}
+ </ButtonRoot>
+ );
+}
+
+interface ButtonRootProps {
+ $variant: ButtonVariant;
+ $fullWidth: boolean;
+ $loading: boolean;
+}
+
+const ButtonRoot = styled(
+ "button",
+ authTransientProps,
+)<ButtonRootProps>(({ $variant, $fullWidth, $loading }) => ({
+ ...authBodyTypography,
+ width: $fullWidth ? "100%" : "auto",
+ height: "52px",
+ padding: "14px 24px",
+ border: 0,
+ borderRadius: "20px",
+ display: "inline-flex",
+ alignItems: "center",
+ justifyContent: "center",
+ position: "relative",
+ boxSizing: "border-box",
+ fontFamily: "inherit",
+ color: $variant === "primary" ? "#fff" : "var(--photos-auth-text)",
+ backgroundColor:
+ $variant === "primary"
+ ? "var(--photos-auth-primary)"
+ : "var(--photos-auth-fill)",
+ cursor: $loading ? "default" : "pointer",
+ transition: "background-color 120ms ease",
+ "&:hover:not(:disabled)": {
+ backgroundColor:
+ $variant === "primary"
+ ? "var(--photos-auth-primary-hover)"
+ : "var(--photos-auth-fill-hover)",
+ },
+ "&:active:not(:disabled)": {
+ backgroundColor:
+ $variant === "primary"
+ ? "var(--photos-auth-primary-active)"
+ : "var(--photos-auth-fill-active)",
+ },
+ "&:focus-visible": authFocusRing,
+ "&:disabled": $loading
+ ? { cursor: "default" }
+ : {
+ color: "var(--photos-auth-text-disabled)",
+ backgroundColor: "var(--photos-auth-fill-hover)",
+ cursor: "not-allowed",
+ },
+ "& > .MuiCircularProgress-root": { position: "absolute" },
+}));
+
+const ButtonLabel = styled(
+ "span",
+ authTransientProps,
+)<{ $loading: boolean }>(({ $loading }) => ({ opacity: $loading ? 0 : 1 }));
diff --git a/web/apps/photos/src/components/auth/Checkbox.tsx b/web/apps/photos/src/components/auth/Checkbox.tsx
new file mode 100644
index 0000000000..bef25c69b9
--- /dev/null
+++ b/web/apps/photos/src/components/auth/Checkbox.tsx
@@ -0,0 +1,112 @@
+import { Tick02Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { styled } from "@mui/material";
+import type React from "react";
+import {
+ authBodyTypography,
+ authFocusRing,
+ authTransientProps,
+} from "./styles";
+
+export interface CheckboxProps extends Omit<
+ React.InputHTMLAttributes<HTMLInputElement>,
+ "checked" | "children" | "onChange" | "type"
+> {
+ checked: boolean;
+ onChange: (checked: boolean) => void;
+ /**
+ * Label rendered next to the box, inside the label element, giving the
+ * checkbox its accessible name (and making the text itself clickable).
+ *
+ * When omitted, pass an `aria-label` instead.
+ */
+ label?: React.ReactNode;
+}
+
+export function Checkbox({
+ checked,
+ onChange,
+ disabled,
+ label,
+ ...inputProps
+}: CheckboxProps): React.JSX.Element {
+ function handleChange(event: React.ChangeEvent<HTMLInputElement>) {
+ onChange(event.target.checked);
+ }
+
+ return (
+ <CheckboxRoot $disabled={Boolean(disabled)}>
+ <CheckboxInput
+ type="checkbox"
+ checked={checked}
+ onChange={handleChange}
+ disabled={disabled}
+ {...inputProps}
+ />
+ <CheckboxMark aria-hidden="true">
+ {checked && (
+ <HugeiconsIcon
+ icon={Tick02Icon}
+ size={11}
+ strokeWidth={3}
+ />
+ )}
+ </CheckboxMark>
+ {label && <CheckboxLabelText>{label}</CheckboxLabelText>}
+ </CheckboxRoot>
+ );
+}
+
+const CheckboxRoot = styled(
+ "label",
+ authTransientProps,
+)<{ $disabled: boolean }>(({ $disabled }) => ({
+ display: "inline-flex",
+ alignItems: "flex-start",
+ gap: "8px",
+ position: "relative",
+ cursor: $disabled ? "not-allowed" : "pointer",
+}));
+
+const CheckboxInput = styled("input")({
+ width: "1px",
+ height: "1px",
+ margin: 0,
+ padding: 0,
+ position: "absolute",
+ overflow: "hidden",
+ clip: "rect(0 0 0 0)",
+ clipPath: "inset(50%)",
+ whiteSpace: "nowrap",
+});
+
+const CheckboxMark = styled("span")({
+ width: "16px",
+ height: "16px",
+ flex: "0 0 16px",
+ // Center against the first line of a (possibly wrapping) label.
+ marginTop: "2px",
+ borderRadius: "4px",
+ display: "inline-flex",
+ alignItems: "center",
+ justifyContent: "center",
+ boxSizing: "border-box",
+ color: "#fff",
+ backgroundColor: "var(--photos-auth-primary)",
+ "input:disabled + &": {
+ backgroundColor: "var(--photos-auth-text-disabled)",
+ },
+ "input:not(:checked) + &": {
+ backgroundColor: "transparent",
+ boxShadow: "inset 0 0 0 1px var(--photos-auth-text-faint)",
+ },
+ "input:not(:checked):disabled + &": {
+ boxShadow: "inset 0 0 0 1px var(--photos-auth-text-disabled)",
+ },
+ "input:focus-visible + &": authFocusRing,
+});
+
+const CheckboxLabelText = styled("span")({
+ ...authBodyTypography,
+ color: "var(--photos-auth-text)",
+});
diff --git a/web/apps/photos/src/components/auth/Form.tsx b/web/apps/photos/src/components/auth/Form.tsx
new file mode 100644
index 0000000000..bf9395fefb
--- /dev/null
+++ b/web/apps/photos/src/components/auth/Form.tsx
@@ -0,0 +1,20 @@
+import { styled } from "@mui/material";
+import type React from "react";
+import { authMobileMediaQuery } from "./styles";
+
+export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
+ children: React.ReactNode;
+}
+
+export function Form({ children, ...formProps }: FormProps): React.JSX.Element {
+ return <FormRoot {...formProps}>{children}</FormRoot>;
+}
+
+const FormRoot = styled("form")({
+ width: "100%",
+ minHeight: "min-content",
+ display: "flex",
+ flexDirection: "column",
+ gap: "24px",
+ [authMobileMediaQuery]: { flex: 1 },
+});
diff --git a/web/apps/photos/src/components/auth/FormFields.tsx b/web/apps/photos/src/components/auth/FormFields.tsx
new file mode 100644
index 0000000000..bd1d915924
--- /dev/null
+++ b/web/apps/photos/src/components/auth/FormFields.tsx
@@ -0,0 +1,15 @@
+import { styled } from "@mui/material";
+import type React from "react";
+
+export function FormFields({
+ children,
+}: React.PropsWithChildren): React.JSX.Element {
+ return <FormFieldsRoot>{children}</FormFieldsRoot>;
+}
+
+const FormFieldsRoot = styled("div")({
+ width: "100%",
+ display: "flex",
+ flexDirection: "column",
+ gap: "16px",
+});
diff --git a/web/apps/photos/src/components/auth/FormFooter.tsx b/web/apps/photos/src/components/auth/FormFooter.tsx
new file mode 100644
index 0000000000..f59919ed4d
--- /dev/null
+++ b/web/apps/photos/src/components/auth/FormFooter.tsx
@@ -0,0 +1,17 @@
+import { styled } from "@mui/material";
+import type React from "react";
+import { authMobileMediaQuery } from "./styles";
+
+export function FormFooter({
+ children,
+}: React.PropsWithChildren): React.JSX.Element {
+ return <FormFooterRoot>{children}</FormFooterRoot>;
+}
+
+const FormFooterRoot = styled("div")({
+ width: "100%",
+ display: "flex",
+ flexDirection: "column",
+ gap: "16px",
+ [authMobileMediaQuery]: { marginTop: "auto" },
+});
diff --git a/web/apps/photos/src/components/auth/Message.tsx b/web/apps/photos/src/components/auth/Message.tsx
new file mode 100644
index 0000000000..aa5b03ec90
--- /dev/null
+++ b/web/apps/photos/src/components/auth/Message.tsx
@@ -0,0 +1,71 @@
+import {
+ Alert02Icon,
+ AlertCircleIcon,
+ InformationCircleIcon,
+ Tick02Icon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { styled } from "@mui/material";
+import type React from "react";
+import { authMiniTypography, authTransientProps } from "./styles";
+
+export type MessageKind = "error" | "warning" | "success" | "info";
+
+export interface MessageProps {
+ children: React.ReactNode;
+ kind?: MessageKind;
+ note?: boolean;
+ id?: string;
+}
+
+export function Message({
+ children,
+ kind = "info",
+ note = false,
+ id,
+}: MessageProps): React.JSX.Element {
+ const icon = messageIcons[kind];
+
+ return (
+ <MessageRoot
+ id={id}
+ role={kind === "error" ? "alert" : "status"}
+ $kind={kind}
+ $note={note}
+ >
+ <HugeiconsIcon
+ icon={icon}
+ size={14}
+ strokeWidth={2}
+ aria-hidden="true"
+ />
+ <span>{children}</span>
+ </MessageRoot>
+ );
+}
+
+const messageIcons = {
+ error: AlertCircleIcon,
+ warning: Alert02Icon,
+ success: Tick02Icon,
+ info: InformationCircleIcon,
+} as const;
+
+const MessageRoot = styled(
+ "span",
+ authTransientProps,
+)<{ $kind: MessageKind; $note: boolean }>(({ $kind, $note }) => ({
+ ...authMiniTypography,
+ display: "inline-flex",
+ alignItems: $note ? "flex-start" : "center",
+ gap: $note ? "8px" : "4px",
+ color:
+ $kind === "error"
+ ? "var(--photos-auth-warning)"
+ : $kind === "warning"
+ ? "var(--photos-auth-caution)"
+ : $kind === "success"
+ ? "var(--photos-auth-success)"
+ : "var(--photos-auth-text-muted)",
+ "& > svg": { flexShrink: 0 },
+}));
diff --git a/web/apps/photos/src/components/auth/OTPField.tsx b/web/apps/photos/src/components/auth/OTPField.tsx
new file mode 100644
index 0000000000..ebfb69cee2
--- /dev/null
+++ b/web/apps/photos/src/components/auth/OTPField.tsx
@@ -0,0 +1,224 @@
+import { styled } from "@mui/material";
+import { t } from "i18next";
+import type React from "react";
+import { useEffect, useRef } from "react";
+import { authDisplayFontFamily, authTransientProps } from "./styles";
+
+export interface OTPFieldProps {
+ id?: string;
+ name?: string;
+ value: string;
+ onChange: (value: string) => void;
+ length?: number;
+ error?: boolean;
+ disabled?: boolean;
+ autoFocus?: boolean;
+ ariaLabel?: string;
+ ariaDescribedBy?: string;
+}
+
+export function OTPField({
+ id,
+ name,
+ value,
+ onChange,
+ length = 6,
+ error = false,
+ disabled = false,
+ autoFocus,
+ ariaLabel,
+ ariaDescribedBy,
+}: OTPFieldProps): React.JSX.Element {
+ const inputRefs = useRef<(HTMLInputElement | null)[]>([]);
+
+ useEffect(() => {
+ if (autoFocus && value.length === 0) inputRefs.current[0]?.focus();
+ }, [autoFocus, value]);
+
+ function isInputValueValid(input: string) {
+ return !isNaN(Number(input)) && input.trim().length === 1;
+ }
+
+ function focusInput(index: number) {
+ const nextIndex = Math.max(Math.min(length - 1, index), 0);
+ const input = inputRefs.current[nextIndex];
+ if (input) {
+ input.focus();
+ input.select();
+ }
+ }
+
+ function updateDigit(index: number, digit: string) {
+ const otp = value.split("");
+ otp[index] = digit;
+ onChange(otp.join(""));
+ }
+
+ function handleChange(
+ index: number,
+ event: React.ChangeEvent<HTMLInputElement>,
+ ) {
+ const input = event.currentTarget.value;
+ if (isInputValueValid(input)) {
+ updateDigit(index, input);
+ focusInput(index + 1);
+ }
+ }
+
+ function handleInput(
+ index: number,
+ event: React.SyntheticEvent<HTMLInputElement, InputEvent>,
+ ) {
+ const nativeEvent = event.nativeEvent;
+ const input = event.currentTarget.value;
+ if (!isInputValueValid(input)) {
+ if (
+ input.length === length &&
+ !input.split("").some((digit) => !isInputValueValid(digit))
+ ) {
+ onChange(input);
+ focusInput(length - 1);
+ }
+
+ if (
+ nativeEvent.data === null &&
+ nativeEvent.inputType === "deleteContentBackward"
+ ) {
+ event.preventDefault();
+ updateDigit(index, "");
+ focusInput(index - 1);
+ }
+
+ event.currentTarget.value = "";
+ }
+ }
+
+ function handleKeyDown(
+ index: number,
+ event: React.KeyboardEvent<HTMLInputElement>,
+ ) {
+ const otp = value.split("");
+ if ([event.code, event.key].includes("Backspace")) {
+ event.preventDefault();
+ updateDigit(index, "");
+ focusInput(index - 1);
+ } else if (event.code === "Delete") {
+ event.preventDefault();
+ updateDigit(index, "");
+ } else if (event.code === "ArrowLeft") {
+ event.preventDefault();
+ focusInput(index - 1);
+ } else if (event.code === "ArrowRight") {
+ event.preventDefault();
+ focusInput(index + 1);
+ } else if (event.key === otp[index]) {
+ event.preventDefault();
+ focusInput(index + 1);
+ } else if (
+ event.code === "Spacebar" ||
+ event.code === "Space" ||
+ event.code === "ArrowUp" ||
+ event.code === "ArrowDown"
+ ) {
+ event.preventDefault();
+ }
+ }
+
+ function handlePaste(
+ index: number,
+ event: React.ClipboardEvent<HTMLInputElement>,
+ ) {
+ event.preventDefault();
+ const otp = value.split("");
+ const pastedData = event.clipboardData
+ .getData("text/plain")
+ .slice(0, length - index)
+ .split("");
+
+ if (pastedData.some((digit) => !isInputValueValid(digit))) return;
+
+ pastedData.forEach((digit, offset) => {
+ otp[index + offset] = digit;
+ });
+
+ focusInput(index + pastedData.length);
+ onChange(otp.join(""));
+ }
+
+ const inputAriaLabel = ariaLabel ?? t("verification_code");
+
+ return (
+ <OTPRoot $disabled={disabled}>
+ {Array.from({ length }, (_, index) => (
+ <OTPInput
+ key={index}
+ ref={(element) => {
+ inputRefs.current[index] = element;
+ }}
+ id={index === 0 ? id : undefined}
+ name={index === 0 ? name : undefined}
+ type="tel"
+ value={value[index] ?? ""}
+ onChange={(event) => handleChange(index, event)}
+ onFocus={(event) => event.currentTarget.select()}
+ onInput={(event) => handleInput(index, event)}
+ onKeyDown={(event) => handleKeyDown(index, event)}
+ onPaste={(event) => handlePaste(index, event)}
+ disabled={disabled}
+ autoFocus={autoFocus && index === 0}
+ inputMode="numeric"
+ pattern="[0-9]*"
+ autoComplete={index === 0 ? "one-time-code" : "off"}
+ aria-label={`${inputAriaLabel} ${index + 1}`}
+ aria-describedby={ariaDescribedBy}
+ aria-invalid={error || undefined}
+ $error={error}
+ />
+ ))}
+ </OTPRoot>
+ );
+}
+
+const OTPRoot = styled(
+ "div",
+ authTransientProps,
+)<{ $disabled: boolean }>(({ $disabled }) => ({
+ width: "100%",
+ display: "flex",
+ gap: "8px",
+ position: "relative",
+ containerType: "inline-size",
+ cursor: $disabled ? "not-allowed" : "text",
+}));
+
+const OTPInput = styled(
+ "input",
+ authTransientProps,
+)<{ $error: boolean }>(({ $error }) => ({
+ aspectRatio: "44 / 52",
+ minWidth: 0,
+ flex: "1 1 0",
+ padding: 0,
+ border: 0,
+ borderRadius: "16px",
+ boxSizing: "border-box",
+ fontFamily: authDisplayFontFamily,
+ fontSize: "clamp(20px, 6.6cqi, 30px)",
+ fontWeight: 600,
+ lineHeight: 1,
+ textAlign: "center",
+ color: "var(--photos-auth-text)",
+ backgroundColor: "var(--photos-auth-field)",
+ boxShadow: `inset 0 0 0 1px ${
+ $error ? "var(--photos-auth-warning)" : "var(--photos-auth-stroke)"
+ }`,
+ outline: 0,
+ cursor: "text",
+ transition: "box-shadow 0.2s ease",
+ "&:focus": {
+ boxShadow: `inset 0 0 0 1px ${
+ $error ? "var(--photos-auth-warning)" : "var(--photos-auth-primary)"
+ }`,
+ },
+ "&:disabled": { cursor: "not-allowed" },
+}));
diff --git a/web/apps/photos/src/components/auth/ScreenHeader.tsx b/web/apps/photos/src/components/auth/ScreenHeader.tsx
new file mode 100644
index 0000000000..42da197b7e
--- /dev/null
+++ b/web/apps/photos/src/components/auth/ScreenHeader.tsx
@@ -0,0 +1,48 @@
+import { styled } from "@mui/material";
+import type React from "react";
+import { authDisplayFontFamily, authMobileMediaQuery } from "./styles";
+
+export interface ScreenHeaderProps {
+ title: React.ReactNode;
+ subtitle?: React.ReactNode;
+}
+
+export function ScreenHeader({
+ title,
+ subtitle,
+}: ScreenHeaderProps): React.JSX.Element {
+ return (
+ <ScreenHeaderRoot>
+ <ScreenTitle>{title}</ScreenTitle>
+ {subtitle && <ScreenSubtitle>{subtitle}</ScreenSubtitle>}
+ </ScreenHeaderRoot>
+ );
+}
+
+const ScreenHeaderRoot = styled("div")({
+ display: "flex",
+ flexDirection: "column",
+ gap: "8px",
+});
+
+const ScreenTitle = styled("h1")({
+ margin: 0,
+ fontFamily: authDisplayFontFamily,
+ fontSize: "30px",
+ fontWeight: 600,
+ lineHeight: "38px",
+ textWrap: "pretty",
+ color: "var(--photos-auth-text)",
+ [authMobileMediaQuery]: { fontSize: "26px", lineHeight: "34px" },
+ "@media (min-width: 1600px)": { fontSize: "32px", lineHeight: "40px" },
+});
+
+const ScreenSubtitle = styled("p")({
+ margin: 0,
+ fontSize: "16px",
+ fontWeight: 500,
+ lineHeight: "24px",
+ textWrap: "pretty",
+ color: "var(--photos-auth-text-muted)",
+ [authMobileMediaQuery]: { fontSize: "13px", lineHeight: "20px" },
+});
diff --git a/web/apps/photos/src/components/auth/TextField.tsx b/web/apps/photos/src/components/auth/TextField.tsx
new file mode 100644
index 0000000000..1367bc0bfb
--- /dev/null
+++ b/web/apps/photos/src/components/auth/TextField.tsx
@@ -0,0 +1,257 @@
+import { ViewIcon, ViewOffSlashIcon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { styled } from "@mui/material";
+import { t } from "i18next";
+import type React from "react";
+import { useId, useState } from "react";
+import { Message } from "./Message";
+import {
+ authBodyTypography,
+ authFocusRing,
+ authMiniTypography,
+ authTransientProps,
+} from "./styles";
+
+export interface TextFieldProps {
+ id?: string;
+ label?: React.ReactNode;
+ value: string;
+ onChange: (
+ event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
+ ) => void;
+ type?: React.HTMLInputTypeAttribute;
+ placeholder?: string;
+ required?: boolean;
+ disabled?: boolean;
+ error?: boolean;
+ helperText?: React.ReactNode;
+ autoFocus?: boolean;
+ autoComplete?: string;
+ name?: string;
+ showPasswordToggle?: boolean;
+ multiline?: boolean;
+ rows?: number;
+ inputMode?: React.HTMLAttributes<HTMLInputElement>["inputMode"];
+ ariaLabel?: string;
+}
+
+export function TextField({
+ id,
+ label,
+ value,
+ onChange,
+ type = "text",
+ placeholder,
+ required,
+ disabled,
+ error,
+ helperText,
+ autoFocus,
+ autoComplete,
+ name,
+ showPasswordToggle,
+ multiline,
+ rows = 5,
+ inputMode,
+ ariaLabel,
+}: TextFieldProps): React.JSX.Element {
+ const generatedID = useId();
+ const inputID = id ?? generatedID;
+ const helperID = helperText ? `${inputID}-helper` : undefined;
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
+ const inputType = showPasswordToggle
+ ? isPasswordVisible
+ ? "text"
+ : "password"
+ : type;
+
+ function handleInputChange(event: React.ChangeEvent<HTMLInputElement>) {
+ onChange(event);
+ }
+
+ function handleTextAreaChange(
+ event: React.ChangeEvent<HTMLTextAreaElement>,
+ ) {
+ onChange(event);
+ }
+
+ function handlePasswordToggle() {
+ setIsPasswordVisible((isVisible) => !isVisible);
+ }
+
+ function handlePasswordToggleMouseDown(
+ event: React.MouseEvent<HTMLButtonElement>,
+ ) {
+ event.preventDefault();
+ }
+
+ const sharedControlProps = {
+ id: inputID,
+ value,
+ placeholder,
+ required,
+ disabled,
+ autoFocus,
+ autoComplete,
+ name,
+ "aria-label": ariaLabel,
+ "aria-invalid": error || undefined,
+ "aria-describedby": helperID,
+ };
+
+ return (
+ <FieldRoot>
+ {label && (
+ <FieldLabel htmlFor={inputID}>
+ {label}
+ {required && (
+ <RequiredMark aria-hidden="true"> *</RequiredMark>
+ )}
+ </FieldLabel>
+ )}
+ <FieldBox
+ $error={Boolean(error)}
+ $disabled={Boolean(disabled)}
+ $multiline={Boolean(multiline)}
+ >
+ {multiline ? (
+ <TextAreaControl
+ {...sharedControlProps}
+ rows={rows}
+ onChange={handleTextAreaChange}
+ />
+ ) : (
+ <TextInputControl
+ {...sharedControlProps}
+ type={inputType}
+ inputMode={inputMode}
+ onChange={handleInputChange}
+ />
+ )}
+ {showPasswordToggle && !multiline && (
+ <PasswordToggle
+ type="button"
+ aria-label={t("show_or_hide_password")}
+ aria-controls={inputID}
+ aria-pressed={isPasswordVisible}
+ disabled={disabled}
+ onClick={handlePasswordToggle}
+ onMouseDown={handlePasswordToggleMouseDown}
+ >
+ <HugeiconsIcon
+ icon={
+ isPasswordVisible ? ViewOffSlashIcon : ViewIcon
+ }
+ size={20}
+ strokeWidth={2}
+ aria-hidden="true"
+ />
+ </PasswordToggle>
+ )}
+ </FieldBox>
+ {helperText && (
+ <Message id={helperID} kind={error ? "error" : "info"}>
+ {helperText}
+ </Message>
+ )}
+ </FieldRoot>
+ );
+}
+
+const FieldRoot = styled("div")({
+ width: "100%",
+ display: "flex",
+ flexDirection: "column",
+ gap: "9px",
+});
+
+const FieldLabel = styled("label")({
+ ...authMiniTypography,
+ color: "var(--photos-auth-text-muted)",
+});
+
+const RequiredMark = styled("span")({ color: "var(--photos-auth-warning)" });
+
+interface FieldBoxProps {
+ $error: boolean;
+ $disabled: boolean;
+ $multiline: boolean;
+}
+
+const FieldBox = styled(
+ "div",
+ authTransientProps,
+)<FieldBoxProps>(({ $error, $disabled, $multiline }) => ({
+ width: "100%",
+ height: $multiline ? "auto" : "52px",
+ minHeight: $multiline ? "112px" : undefined,
+ padding: $multiline ? "16px" : "0 16px",
+ borderRadius: "16px",
+ display: "flex",
+ alignItems: $multiline ? "flex-start" : "center",
+ gap: "8px",
+ boxSizing: "border-box",
+ backgroundColor: $disabled
+ ? "var(--photos-auth-fill)"
+ : "var(--photos-auth-field)",
+ boxShadow: $disabled
+ ? "none"
+ : `inset 0 0 0 1px ${
+ $error
+ ? "var(--photos-auth-warning)"
+ : "var(--photos-auth-stroke)"
+ }`,
+ "&:focus-within": $disabled
+ ? undefined
+ : {
+ boxShadow: `inset 0 0 0 1px ${
+ $error
+ ? "var(--photos-auth-warning)"
+ : "var(--photos-auth-primary)"
+ }`,
+ },
+}));
+
+const controlStyles = {
+ ...authBodyTypography,
+ width: "100%",
+ minWidth: 0,
+ flex: 1,
+ padding: 0,
+ border: 0,
+ outline: 0,
+ background: "transparent",
+ fontFamily: "inherit",
+ color: "var(--photos-auth-text)",
+ "&::placeholder": { color: "var(--photos-auth-text-faint)", opacity: 1 },
+ "&:disabled": {
+ color: "var(--photos-auth-text-disabled)",
+ WebkitTextFillColor: "var(--photos-auth-text-disabled)",
+ cursor: "not-allowed",
+ },
+};
+
+const TextInputControl = styled("input")({ ...controlStyles });
+
+const TextAreaControl = styled("textarea")({
+ ...controlStyles,
+ minHeight: "80px",
+ resize: "none",
+});
+
+const PasswordToggle = styled("button")({
+ width: "20px",
+ height: "20px",
+ flex: "0 0 20px",
+ padding: 0,
+ border: 0,
+ borderRadius: "4px",
+ display: "inline-flex",
+ alignItems: "center",
+ justifyContent: "center",
+ background: "transparent",
+ color: "var(--photos-auth-text-faint)",
+ cursor: "pointer",
+ "&:focus-visible": authFocusRing,
+ "&:disabled": { cursor: "not-allowed" },
+});
diff --git a/web/apps/photos/src/components/auth/TextLink.tsx b/web/apps/photos/src/components/auth/TextLink.tsx
new file mode 100644
index 0000000000..70f82ec42a
--- /dev/null
+++ b/web/apps/photos/src/components/auth/TextLink.tsx
@@ -0,0 +1,57 @@
+import { styled } from "@mui/material";
+import type React from "react";
+import {
+ authBodyTypography,
+ authFocusRing,
+ authTransientProps,
+} from "./styles";
+
+export interface TextLinkProps extends Omit<
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
+ "color" | "children"
+> {
+ regular?: boolean;
+ children: React.ReactNode;
+}
+
+/**
+ * A button that looks like an inline text link.
+ *
+ * Named TextLink (not LinkButton) to avoid colliding with the LinkButton
+ * exported by ente-base, which is used elsewhere in this app.
+ */
+export function TextLink({
+ regular = false,
+ type = "button",
+ children,
+ ...buttonProps
+}: TextLinkProps): React.JSX.Element {
+ return (
+ <TextLinkRoot type={type} $regular={regular} {...buttonProps}>
+ {children}
+ </TextLinkRoot>
+ );
+}
+
+const TextLinkRoot = styled(
+ "button",
+ authTransientProps,
+)<{ $regular: boolean }>(({ $regular }) => ({
+ ...authBodyTypography,
+ display: "inline-flex",
+ alignItems: "center",
+ gap: "4px",
+ padding: 0,
+ border: 0,
+ background: "transparent",
+ fontFamily: "inherit",
+ fontWeight: $regular ? 500 : 600,
+ color: "var(--photos-auth-primary)",
+ textDecoration: "none",
+ cursor: "pointer",
+ "&:focus-visible": { ...authFocusRing, borderRadius: "4px" },
+ "&:disabled": {
+ color: "var(--photos-auth-text-disabled)",
+ cursor: "not-allowed",
+ },
+}));
diff --git a/web/apps/photos/src/components/auth/styles.ts b/web/apps/photos/src/components/auth/styles.ts
new file mode 100644
index 0000000000..f872565694
--- /dev/null
+++ b/web/apps/photos/src/components/auth/styles.ts
@@ -0,0 +1,84 @@
+/**
+ * The auth palette, exposed as CSS variables.
+ *
+ * Declared globally by {@link PhotosAuthShell} (via MUI's GlobalStyles) while
+ * an auth screen is mounted, so the `var(--photos-auth-*)` consumers in this
+ * directory resolve anywhere in the document β€” including MUI portals
+ * (dialogs, menus, snackbars), which mount outside the shell's DOM subtree.
+ *
+ * Both selectors have zero specificity, so source order alone lets the dark
+ * block win whenever the color scheme class (`colorSchemeSelector: "class"`
+ * in the app theme) is present on an ancestor.
+ */
+export const authColorVariables = {
+ ":where(:root)": {
+ "--photos-auth-primary": "#08c225",
+ "--photos-auth-primary-hover": "#069d1e",
+ "--photos-auth-primary-active": "#057c18",
+ "--photos-auth-success": "#069d1e",
+ "--photos-auth-warning": "#f63a3a",
+ "--photos-auth-caution": "#f08a1e",
+ "--photos-auth-text": "#000",
+ "--photos-auth-text-muted": "#666",
+ "--photos-auth-text-faint": "#969696",
+ "--photos-auth-text-disabled": "#d6d6d6",
+ "--photos-auth-field": "#fff",
+ "--photos-auth-fill": "#eaeaea",
+ "--photos-auth-fill-hover": "#dedede",
+ "--photos-auth-fill-active": "#d2d2d2",
+ "--photos-auth-stroke": "#e0e0e0",
+ },
+ "*:where(.dark)": {
+ "--photos-auth-success": "#08c225",
+ "--photos-auth-text": "#fff",
+ "--photos-auth-text-muted": "#999",
+ "--photos-auth-text-disabled": "#4d4d4d",
+ "--photos-auth-field": "#1a1a1a",
+ "--photos-auth-fill": "#0a0a0a",
+ "--photos-auth-fill-hover": "#1a1a1a",
+ "--photos-auth-fill-active": "#292929",
+ "--photos-auth-stroke": "#3e3e3e",
+ },
+};
+
+/**
+ * The auth layout's mobile cutoff.
+ *
+ * Both queries derive from the same constant. The 0.05px epsilon (the same
+ * one MUI's breakpoint helpers use) keeps fractional viewport widths from
+ * falling between the two queries.
+ */
+const authMobileCutoffPx = 640;
+export const authMobileMediaQuery = `@media (max-width: ${authMobileCutoffPx - 0.05}px)`;
+export const authAboveMobileMediaQuery = `@media (min-width: ${authMobileCutoffPx}px)`;
+
+/**
+ * styled() options that keep `$`-prefixed transient props off the DOM.
+ *
+ * All transient props in this directory use the `$` prefix, so every
+ * styled() call with transient props can share this filter.
+ */
+export const authTransientProps = {
+ shouldForwardProp: (prop: string) => !prop.startsWith("$"),
+};
+
+/** The display font used for headlines and the OTP digits. */
+export const authDisplayFontFamily = '"Outfit Variable", sans-serif';
+
+/** The keyboard focus indicator shared by the interactive components. */
+export const authFocusRing = {
+ outline: "1px solid var(--photos-auth-primary)",
+ outlineOffset: "2px",
+};
+
+export const authBodyTypography = {
+ fontSize: "14px",
+ fontWeight: 500,
+ lineHeight: "20px",
+};
+
+export const authMiniTypography = {
+ fontSize: "12px",
+ fontWeight: 500,
+ lineHeight: "16px",
+};