π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
import { Tick02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { GlobalStyles, keyframes, styled } from "@mui/material";
import { EnteLogo } from "ente-base/components/EnteLogo";
import type React from "react";
import {
authAboveMobileMediaQuery,
authDisplayFontFamily,
authMobileMediaQuery,
createAuthColorVariables,
type AuthPresentationConfig,
} from "./styles";
interface AuthBrandCopy {
headline: string;
subtitle: string;
bullets: readonly [string, string, string];
}
export interface AuthPageShellProps extends React.PropsWithChildren {
brand: AuthBrandCopy;
presentationConfig: AuthPresentationConfig;
contentWidth?: 400 | 420;
viewportHeight?: string;
}
export function AuthPageShell({
brand,
presentationConfig,
children,
contentWidth = 400,
viewportHeight = "100svh",
}: AuthPageShellProps): React.JSX.Element {
return (
<PageRoot $viewportHeight={viewportHeight}>
<GlobalStyles
styles={createAuthColorVariables(presentationConfig)}
/>
<FrameCurves />
<PageCard>
<DesktopBrandSlot>
<BrandPanel
brand={brand}
presentationConfig={presentationConfig}
size="desktop"
/>
</DesktopBrandSlot>
<TabletBrandSlot>
<BrandPanel
brand={brand}
presentationConfig={presentationConfig}
size="tablet"
/>
</TabletBrandSlot>
<MobileBrandSlot $height={presentationConfig.mobileBrandHeight}>
<BrandPanel
brand={brand}
presentationConfig={presentationConfig}
size="mobile"
/>
</MobileBrandSlot>
<ContentSheet>
<SheetHandle />
<ContentColumn contentWidth={contentWidth}>
{children}
</ContentColumn>
</ContentSheet>
</PageCard>
</PageRoot>
);
}
const shellReveal = keyframes({
from: { opacity: 0, transform: "translateY(18px)" },
to: { opacity: 1, transform: "translateY(0)" },
});
const brandCopyReveal = keyframes({
from: { opacity: 0, transform: "translateY(12px)" },
to: { opacity: 1, transform: "translateY(0)" },
});
const illustrationReveal = keyframes({
from: { opacity: 0, transform: "translateY(18px) scale(0.98)" },
to: { opacity: 1, transform: "translateY(0) scale(1)" },
});
const cameraSparkle = keyframes({
from: {
opacity: 0,
transform: "translate(-50%, -50%) scale(0) rotate(-20deg)",
},
"35%": {
opacity: 1,
transform: "translate(-50%, -50%) scale(1) rotate(0)",
},
"70%": {
opacity: 0.85,
transform: "translate(-50%, -50%) scale(0.72) rotate(24deg)",
},
to: {
opacity: 0,
transform: "translate(-50%, -50%) scale(1.3) rotate(45deg)",
},
});
const brandCurvesDrift = keyframes({
"0%, 100%": { backgroundPosition: "calc(50% - 6px) calc(50% + 4px)" },
"50%": { backgroundPosition: "calc(50% + 6px) calc(50% - 4px)" },
});
const brandCopyAnimation = {
animation: `${brandCopyReveal} 520ms cubic-bezier(0.22, 1, 0.36, 1) both`,
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
};
interface BrandPanelProps {
brand: AuthBrandCopy;
presentationConfig: AuthPresentationConfig;
size: "desktop" | "tablet" | "mobile";
}
function BrandPanel({
brand,
presentationConfig,
size,
}: BrandPanelProps): React.JSX.Element {
return (
<BrandPanelRoot
size={size}
$wideGamutPrimary={presentationConfig.wideGamutPrimary}
>
<Wordmark size={size}>
<EnteLogo />
</Wordmark>
<PanelCopy size={size}>
<PanelHeadline size={size}>{brand.headline}</PanelHeadline>
{size !== "mobile" && (
<PanelSubtitle size={size}>{brand.subtitle}</PanelSubtitle>
)}
{size === "desktop" && (
<BulletList>
{brand.bullets.map((bullet) => (
<Bullet key={bullet}>
<CheckCircle aria-hidden="true">
<HugeiconsIcon
icon={Tick02Icon}
size={12}
strokeWidth={3}
/>
</CheckCircle>
<span>{bullet}</span>
</Bullet>
))}
</BulletList>
)}
</PanelCopy>
<IllustrationClip
size={size}
$heights={presentationConfig.illustrationHeights}
>
<img src="/images/auth-ducky.svg" alt="" />
</IllustrationClip>
</BrandPanelRoot>
);
}
const PageRoot = styled("main", {
shouldForwardProp: (prop) => prop !== "$viewportHeight",
})<{ $viewportHeight: string }>(({ theme, $viewportHeight }) => ({
width: "100%",
height: $viewportHeight,
minHeight: $viewportHeight,
display: "flex",
position: "relative",
overflow: "hidden",
boxSizing: "border-box",
backgroundColor: "#f4f4f4",
...theme.applyStyles("dark", { backgroundColor: "#0a0a0a" }),
[authAboveMobileMediaQuery]: { padding: "40px" },
"@media (min-width: 1024px)": {
padding: 0,
alignItems: "center",
justifyContent: "center",
},
}));
const FrameCurves = styled("div")(({ theme }) => ({
display: "none",
opacity: 0.3,
...theme.applyStyles("dark", { opacity: 0.02 }),
[authAboveMobileMediaQuery]: {
display: "block",
position: "absolute",
inset: 0,
backgroundImage: 'url("/images/auth-frame-curves.svg")',
backgroundRepeat: "no-repeat",
backgroundSize: "cover",
backgroundPosition: "center",
pointerEvents: "none",
},
}));
const PageCard = styled("div")(({ theme }) => ({
width: "100%",
height: "100%",
minHeight: 0,
display: "flex",
flexDirection: "column",
position: "relative",
overflow: "hidden",
backgroundColor: "#fff",
animation: `${shellReveal} 620ms cubic-bezier(0.22, 1, 0.36, 1) both`,
...theme.applyStyles("dark", { backgroundColor: "#252525" }),
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
[authAboveMobileMediaQuery]: { borderRadius: "24px" },
"@media (min-width: 1024px)": {
width: "1032px",
height: "min(780px, 100%)",
flexDirection: "row",
},
"@media (min-width: 1600px)": {
width: "1240px",
height: "min(900px, 100%)",
},
}));
const DesktopBrandSlot = styled("div")({
display: "none",
"@media (min-width: 1024px)": {
display: "block",
flex: "0 0 440px",
height: "100%",
},
"@media (min-width: 1600px)": { flexBasis: "496px" },
});
const TabletBrandSlot = styled("div")({
display: "none",
[`${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.
flex: "0 0 auto",
position: "relative",
overflow: "hidden",
},
});
const MobileBrandSlot = styled("div", {
shouldForwardProp: (prop) => prop !== "$height",
})<{ $height: number }>(({ $height }) => ({
display: "block",
flex: `0 0 ${$height}px`,
minHeight: 0,
position: "relative",
overflow: "hidden",
[authAboveMobileMediaQuery]: { display: "none" },
}));
const ContentSheet = styled("section")(({ theme }) => ({
flex: 1,
minHeight: 0,
marginTop: "-28px",
padding: "40px 24px 24px",
display: "flex",
flexDirection: "column",
gap: "24px",
position: "relative",
zIndex: 1,
overflowY: "auto",
boxSizing: "border-box",
borderRadius: "24px 24px 0 0",
backgroundColor: "#fff",
...theme.applyStyles("dark", { backgroundColor: "#252525" }),
[authAboveMobileMediaQuery]: {
marginTop: "-32px",
padding: "16px 48px 48px",
},
"@media (min-width: 1024px)": {
width: "592px",
marginTop: 0,
padding: "48px 96px",
alignItems: "center",
justifyContent: "center",
borderRadius: 0,
},
"@media (min-width: 1600px)": { width: "744px", padding: "56px 172px" },
}));
const SheetHandle = styled("div")({
width: "36px",
height: "4px",
flexShrink: 0,
alignSelf: "center",
borderRadius: "999px",
backgroundColor: "var(--auth-ui-fill-active)",
[authMobileMediaQuery]: { display: "none" },
"@media (min-width: 1024px)": { display: "none" },
});
const ContentColumn = styled("div", {
shouldForwardProp: (prop) => prop !== "contentWidth",
})<{ contentWidth: 400 | 420 }>(({ contentWidth }) => ({
width: "100%",
minHeight: "min-content",
display: "flex",
flexDirection: "column",
gap: "24px",
[authMobileMediaQuery]: { flexGrow: 1 },
[authAboveMobileMediaQuery]: {
width: "440px",
maxWidth: "100%",
marginBlock: "auto",
alignSelf: "center",
},
"@media (min-width: 1024px)": { width: `${contentWidth}px` },
"@media (min-width: 1600px)": { gap: "28px" },
}));
const BrandPanelRoot = styled("div", {
shouldForwardProp: (prop) =>
prop !== "size" && prop !== "$wideGamutPrimary",
})<{ size: BrandPanelProps["size"]; $wideGamutPrimary?: string }>(
({ size, $wideGamutPrimary }) => ({
width: "100%",
height: size === "tablet" ? "auto" : "100%",
...(size === "tablet" && { minHeight: "268px", rowGap: "24px" }),
padding:
size === "desktop"
? "44px"
: size === "tablet"
? "40px 40px 60px"
: "18px 16px 40px",
display: "flex",
flexDirection: "column",
justifyContent: size === "desktop" ? "flex-start" : "space-between",
position: "relative",
overflow: "hidden",
boxSizing: "border-box",
color: "#fff",
backgroundColor: "var(--auth-ui-primary)",
backgroundImage: 'url("/images/auth-surface-noise.svg")',
backgroundRepeat: "repeat",
backgroundPosition: "0 0",
backgroundSize: "auto",
"&::before": {
content: '""',
position: "absolute",
inset: 0,
pointerEvents: "none",
backgroundImage: 'url("/images/auth-frame-curves.svg")',
backgroundRepeat: "no-repeat",
backgroundPosition: "center",
backgroundSize: "cover",
maskImage:
"linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.55) 42%, #000 100%)",
WebkitMaskImage:
"linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.55) 42%, #000 100%)",
animation: `${brandCurvesDrift} 20s ease-in-out infinite`,
},
"@media (prefers-reduced-motion: reduce)": {
"&::before": { animation: "none" },
},
...($wideGamutPrimary && {
"@supports (color: color(display-p3 1 1 1))": {
backgroundColor: $wideGamutPrimary,
},
}),
}),
);
const Wordmark = styled("div", {
shouldForwardProp: (prop) => prop !== "size",
})<{ size: BrandPanelProps["size"] }>(({ size }) => ({
width: size === "desktop" ? "83px" : size === "tablet" ? "77px" : "64px",
height: size === "desktop" ? "26px" : size === "tablet" ? "24px" : "20px",
flexShrink: 0,
margin: size === "mobile" ? "8px 0 0 8px" : 0,
lineHeight: 0,
position: "relative",
zIndex: 1,
"& > svg": { width: "100%", height: "100%" },
}));
const PanelCopy = styled("div", {
shouldForwardProp: (prop) => prop !== "size",
})<{ size: BrandPanelProps["size"] }>(({ size }) => ({
marginTop: size === "desktop" ? "32px" : 0,
marginLeft: size === "mobile" ? "8px" : 0,
// On the tablet band the ducky is anchored to the right edge, so keep
// the copy from running underneath it at narrow widths.
...(size === "tablet" && { maxWidth: "calc(100% - 245px)" }),
position: "relative",
zIndex: 1,
}));
const PanelHeadline = styled("h1", {
shouldForwardProp: (prop) => prop !== "size",
})<{ size: BrandPanelProps["size"] }>(({ size }) => ({
maxWidth:
size === "desktop" ? "300px" : size === "tablet" ? "380px" : "188px",
margin: 0,
fontFamily: authDisplayFontFamily,
fontSize: size === "desktop" ? "42px" : size === "tablet" ? "34px" : "26px",
fontWeight: 600,
lineHeight:
size === "desktop" ? "50px" : size === "tablet" ? "42px" : "34px",
letterSpacing: "-0.02em",
textWrap: "pretty",
...brandCopyAnimation,
animationDelay: "80ms",
}));
const PanelSubtitle = styled("p", {
shouldForwardProp: (prop) => prop !== "size",
})<{ size: BrandPanelProps["size"] }>(({ size }) => ({
margin: 0,
marginTop: size === "desktop" ? "16px" : "10px",
fontSize: size === "desktop" ? "20px" : "17px",
fontWeight: 500,
lineHeight: size === "desktop" ? "28px" : "24px",
color: "rgba(255, 255, 255, 0.88)",
...brandCopyAnimation,
animationDelay: "170ms",
}));
const BulletList = styled("ul")({
margin: "24px 0 0",
padding: 0,
display: "flex",
flexDirection: "column",
gap: "12px",
listStyle: "none",
});
const Bullet = styled("li")({
display: "flex",
alignItems: "center",
gap: "12px",
fontSize: "17px",
fontWeight: 500,
lineHeight: "24px",
...brandCopyAnimation,
"&:nth-of-type(1)": { animationDelay: "280ms" },
"&:nth-of-type(2)": { animationDelay: "350ms" },
"&:nth-of-type(3)": { animationDelay: "420ms" },
});
const CheckCircle = styled("span")({
width: "24px",
height: "24px",
flex: "0 0 24px",
display: "flex",
alignItems: "center",
justifyContent: "center",
borderRadius: "50%",
backgroundColor: "rgba(255, 255, 255, 0.14)",
});
const IllustrationClip = styled("div", {
shouldForwardProp: (prop) => prop !== "size" && prop !== "$heights",
})<{
size: BrandPanelProps["size"];
$heights: AuthPresentationConfig["illustrationHeights"];
}>(({ size, $heights }) => ({
width: size === "desktop" ? "313px" : size === "tablet" ? "237px" : "175px",
height:
size === "desktop"
? `${$heights.desktop}px`
: size === "tablet"
? `${$heights.tablet}px`
: `${$heights.mobile}px`,
flexShrink: 0,
position: "relative",
overflow: "hidden",
zIndex: 0,
...(size !== "tablet" && {
animation: `${illustrationReveal} 500ms cubic-bezier(0.22, 1, 0.36, 1) ${size === "desktop" ? "840ms" : "130ms"} both`,
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
}),
...(size === "desktop"
? {
marginTop: "auto",
alignSelf: "center",
"@media (min-width: 1600px)": {
width: "355px",
height: `${$heights.wide}px`,
},
}
: {
position: "absolute",
right: size === "tablet" ? "28px" : "-4px",
// Sit clear of the content sheet, which overlaps the band's
// bottom edge by 32px (tablet) / 28px (mobile).
bottom: size === "tablet" ? "44px" : "38px",
}),
"&::after": {
content: '""',
width:
size === "desktop" ? "34px" : size === "tablet" ? "26px" : "20px",
aspectRatio: "1",
position: "absolute",
left: "67%",
top: size === "desktop" ? "59%" : "57%",
zIndex: 1,
pointerEvents: "none",
backgroundColor: "#fff",
clipPath:
"polygon(50% 0%, 59% 39%, 100% 50%, 59% 61%, 50% 100%, 41% 61%, 0% 50%, 41% 39%)",
filter: "drop-shadow(0 0 7px rgba(255, 245, 168, 0.95))",
animation: `${cameraSparkle} 520ms ease-out ${size === "desktop" ? "1400ms" : size === "tablet" ? "740ms" : "690ms"} both`,
"@media (prefers-reduced-motion: reduce)": { display: "none" },
},
"& > img": {
display: "block",
width: "473.694px",
height: "370px",
transformOrigin: "top left",
transform:
size === "desktop"
? "scale(0.66)"
: size === "tablet"
? "scale(0.5)"
: "scale(0.37)",
...(size === "desktop" && {
"@media (min-width: 1600px)": { transform: "scale(0.75)" },
}),
},
}));