Skip to content

armgit / ente

Public Imported from GitHub
0

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

update(paste):fix-styles-issues

Aswin Asok12dac205da2a
diff --git a/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx b/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx
index 2a61e951b0..95db060e94 100644
--- a/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx
+++ b/web/apps/paste/src/features/paste/components/PasteCreatePanel.tsx
@@ -17,6 +17,7 @@ import {
Typography,
} from "@mui/material";
import useMediaQuery from "@mui/material/useMediaQuery";
+import { ShowHidePasswordInputAdornment } from "ente-base/components/mui/PasswordInputAdornment";
import { usePasteColorMode } from "features/paste/hooks/usePasteColorMode";
import { getPasteThemeTokens } from "features/paste/theme/pasteThemeTokens";
import type { FormEvent } from "react";
@@ -30,6 +31,7 @@ interface PasteCreatePanelProps {
creating: boolean;
createError: string | null;
createdLink: string | null;
+ createdLinkPasswordProtected: boolean;
onInputChange: (value: string) => void;
onCreate: (password?: string) => Promise<void>;
onCopyLink: (value: string) => Promise<void>;
@@ -41,6 +43,7 @@ export const PasteCreatePanel = ({
creating,
createError,
createdLink,
+ createdLinkPasswordProtected,
onInputChange,
onCreate,
onCopyLink,
@@ -53,6 +56,8 @@ export const PasteCreatePanel = ({
const [passwordDialogOpen, setPasswordDialogOpen] = useState(false);
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
+ const [showPassword, setShowPassword] = useState(false);
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
const [passwordError, setPasswordError] = useState<string | null>(null);
const isInputEmpty = inputText.trim().length === 0;
const nearLimitThreshold = Math.floor(MAX_PASTE_CHARS * 0.9);
@@ -61,6 +66,18 @@ export const PasteCreatePanel = ({
const passwordTooltip = passwordProtected
? "Password protection enabled"
: "Password protect";
+ const errorColor =
+ resolvedMode === "dark"
+ ? "rgba(255, 139, 160, 0.9)"
+ : "rgba(178, 42, 72, 0.9)";
+ const passwordDialogBg = resolvedMode === "dark" ? "#0d1016" : "#f8fbff";
+ const passwordFieldBg = resolvedMode === "dark" ? "#191c22" : "#ffffff";
+ const passwordFieldHoverBg =
+ resolvedMode === "dark" ? "#20232b" : "#f4f8ff";
+ const passwordDialogShadow =
+ resolvedMode === "dark"
+ ? "0 22px 56px rgba(0, 0, 0, 0.48)"
+ : "0 18px 44px rgba(17, 49, 114, 0.18)";
const privacyPills = [
"Private",
isMobile ? "E2EE" : "End-to-end encrypted",
@@ -68,21 +85,107 @@ export const PasteCreatePanel = ({
"Auto-deletes after 24 hours",
];
const passwordFieldSx = {
- "& .MuiInputLabel-root": { color: tokens.text.muted },
- "& .MuiOutlinedInput-root": {
+ ...pasteTextFieldSx(tokens, "14px"),
+ "& .MuiFilledInput-root": {
+ borderRadius: "12px",
+ bgcolor: resolvedMode === "dark" ? "transparent" : passwordFieldBg,
+ border: "1px solid",
+ borderColor: tokens.surface.inputBorder,
+ boxSizing: "border-box",
+ minHeight: 48,
+ alignItems: "center",
+ px: 1.45,
+ py: 0,
+ background:
+ resolvedMode === "dark" ? "transparent" : passwordFieldBg,
+ boxShadow: "none",
+ transition:
+ "background 180ms ease, border-color 180ms ease, box-shadow 180ms ease",
+ "&:before, &:after": {
+ display: "none",
+ borderBottom: "0 !important",
+ },
+ "&:hover:not(.Mui-disabled, .Mui-error):before": {
+ display: "none",
+ borderBottom: "0 !important",
+ },
+ "&:hover": {
+ bgcolor:
+ resolvedMode === "dark"
+ ? "rgba(255, 255, 255, 0.03)"
+ : passwordFieldHoverBg,
+ borderColor: tokens.surface.inputBorder,
+ background:
+ resolvedMode === "dark"
+ ? "rgba(255, 255, 255, 0.03)"
+ : passwordFieldHoverBg,
+ boxShadow: "none",
+ },
+ "&.Mui-focused": {
+ bgcolor:
+ resolvedMode === "dark"
+ ? "rgba(255, 255, 255, 0.035)"
+ : passwordFieldBg,
+ borderColor: tokens.button.primaryBg,
+ background:
+ resolvedMode === "dark"
+ ? "rgba(255, 255, 255, 0.035)"
+ : passwordFieldBg,
+ boxShadow: `0 0 0 2px ${tokens.accent.soft}`,
+ },
+ "&.Mui-error": { borderColor: errorColor },
+ },
+ "& .MuiInputBase-input": {
color: tokens.text.primary,
- "& fieldset": { borderColor: tokens.surface.dialogBorder },
- "&:hover fieldset": { borderColor: tokens.button.ghostHoverBorder },
- "&.Mui-focused fieldset": { borderColor: tokens.button.primaryBg },
+ fontSize: { xs: "0.92rem", sm: "0.95rem" },
+ lineHeight: 1.35,
+ padding: "0 !important",
+ borderBottom: "0 !important",
+ boxShadow: "none",
+ },
+ "& .MuiFilledInput-underline:before, & .MuiFilledInput-underline:after":
+ { display: "none", borderBottom: "0 !important" },
+ "& .MuiInputAdornment-root": { ml: 0.75, mr: 0.5 },
+ "& .MuiIconButton-root": {
+ p: 0.75,
+ color: tokens.text.placeholder,
+ "&:hover": {
+ color: tokens.text.primary,
+ bgcolor:
+ resolvedMode === "dark"
+ ? "rgba(255, 255, 255, 0.06)"
+ : "rgba(17, 49, 114, 0.06)",
+ },
+ },
+ "& .MuiIconButton-edgeEnd": { mr: 0 },
+ "& .MuiSvgIcon-root": { fontSize: 19 },
+ "& input::placeholder": { color: tokens.text.placeholder, opacity: 1 },
+ "& .MuiFormHelperText-root": {
+ mx: 0,
+ mt: 0.65,
+ color: tokens.text.subtle,
+ fontSize: "0.78rem",
+ lineHeight: 1.25,
},
+ "& .MuiFormHelperText-root.Mui-error": { color: errorColor },
};
const resetPasswordDialog = () => {
setPassword("");
setConfirmPassword("");
+ setShowPassword(false);
+ setShowConfirmPassword(false);
setPasswordError(null);
};
+ const togglePasswordVisibility = () => {
+ setShowPassword((visible) => !visible);
+ };
+
+ const toggleConfirmPasswordVisibility = () => {
+ setShowConfirmPassword((visible) => !visible);
+ };
+
const handlePasswordSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (!password) {
@@ -187,11 +290,15 @@ export const PasteCreatePanel = ({
}}
>
<Typography
+ component="span"
variant="mini"
sx={{
display: "flex",
alignItems: "center",
+ flexShrink: 0,
color: tokens.text.counter,
+ fontVariantNumeric: "tabular-nums",
+ fontFeatureSettings: '"tnum"',
fontWeight: 600,
lineHeight: 1,
letterSpacing: "0.01em",
@@ -392,6 +499,22 @@ export const PasteCreatePanel = ({
onCopy={onCopyLink}
onShare={onShareLink}
/>
+ {createdLinkPasswordProtected && (
+ <Typography
+ variant="mini"
+ sx={{
+ mt: 0.85,
+ color: tokens.text.muted,
+ fontSize: { xs: "0.68rem", sm: "0.72rem" },
+ fontWeight: 500,
+ lineHeight: 1.3,
+ letterSpacing: 0,
+ opacity: 0.58,
+ }}
+ >
+ This paste is password protected
+ </Typography>
+ )}
</Box>
)}
@@ -411,28 +534,81 @@ export const PasteCreatePanel = ({
component: "form",
onSubmit: handlePasswordSubmit,
sx: {
- borderRadius: "16px",
- border: `1px solid ${tokens.surface.dialogBorder}`,
- bgcolor: tokens.surface.dialogBg,
+ mx: { xs: 2.5, sm: 3 },
+ p: { xs: "24px 20px 26px", sm: "28px 26px 30px" },
+ borderRadius: "24px",
+ border: "1px solid",
+ borderColor: tokens.surface.dialogBorder,
+ boxSizing: "border-box",
+ bgcolor: passwordDialogBg,
+ background:
+ resolvedMode === "dark"
+ ? "rgba(13, 16, 22, 0.78)"
+ : "rgba(248, 251, 255, 0.82)",
+ backdropFilter: "blur(16px) saturate(118%)",
+ WebkitBackdropFilter: "blur(16px) saturate(118%)",
color: tokens.text.primary,
- boxShadow: tokens.surface.floatingCardShadow,
- backdropFilter: "blur(12px) saturate(112%)",
- WebkitBackdropFilter: "blur(12px) saturate(112%)",
+ boxShadow: passwordDialogShadow,
+ overflow: "hidden",
},
},
}}
>
- <DialogTitle sx={{ pb: 1, color: tokens.text.primary }}>
- Paste password
+ <DialogTitle
+ component="div"
+ sx={{
+ p: 0,
+ ml: { xs: -1.4, sm: -1.6 },
+ color: tokens.text.primary,
+ }}
+ >
+ <Typography
+ component="h2"
+ sx={{
+ m: 0,
+ color: tokens.text.primary,
+ fontSize: { xs: "1.24rem", sm: "1.38rem" },
+ fontWeight: 750,
+ lineHeight: 1.18,
+ }}
+ >
+ Paste password
+ </Typography>
+ <Typography
+ sx={{
+ mt: 0.5,
+ color: tokens.text.muted,
+ fontSize: { xs: "0.86rem", sm: "0.9rem" },
+ fontWeight: 500,
+ lineHeight: 1.45,
+ }}
+ >
+ This password will be required to unlock this paste.
+ </Typography>
</DialogTitle>
- <DialogContent>
- <Stack spacing={1.5} sx={{ pt: 1 }}>
+ <DialogContent sx={{ p: "0 !important", mt: 2.25 }}>
+ <Stack spacing={1.5}>
<TextField
autoFocus
- type="password"
- label="Password"
+ variant="filled"
+ hiddenLabel
+ fullWidth
+ type={showPassword ? "text" : "password"}
+ placeholder="Password"
value={password}
autoComplete="off"
+ slotProps={{
+ htmlInput: { "aria-label": "Password" },
+ input: {
+ disableUnderline: true,
+ endAdornment: (
+ <ShowHidePasswordInputAdornment
+ showPassword={showPassword}
+ onToggle={togglePasswordVisibility}
+ />
+ ),
+ },
+ }}
sx={passwordFieldSx}
onChange={(event) => {
setPassword(event.target.value);
@@ -440,20 +616,30 @@ export const PasteCreatePanel = ({
}}
/>
<TextField
- type="password"
- label="Confirm password"
+ variant="filled"
+ hiddenLabel
+ fullWidth
+ type={showConfirmPassword ? "text" : "password"}
+ placeholder="Confirm password"
value={confirmPassword}
autoComplete="off"
error={!!passwordError}
- helperText={passwordError ?? " "}
- sx={[
- passwordFieldSx,
- {
- "& .MuiFormHelperText-root": {
- minHeight: "1.25em",
- },
+ helperText={passwordError}
+ slotProps={{
+ htmlInput: { "aria-label": "Confirm password" },
+ input: {
+ disableUnderline: true,
+ endAdornment: (
+ <ShowHidePasswordInputAdornment
+ showPassword={showConfirmPassword}
+ onToggle={
+ toggleConfirmPasswordVisibility
+ }
+ />
+ ),
},
- ]}
+ }}
+ sx={passwordFieldSx}
onChange={(event) => {
setConfirmPassword(event.target.value);
setPasswordError(null);
@@ -461,10 +647,24 @@ export const PasteCreatePanel = ({
/>
</Stack>
</DialogContent>
- <DialogActions sx={{ px: 3, pb: 2.5 }}>
+ <DialogActions
+ sx={{
+ gap: 1.1,
+ p: "0 !important",
+ mt: { xs: 3, sm: 3.75 },
+ }}
+ >
<Button
variant="outlined"
sx={{
+ minHeight: 40,
+ minWidth: 96,
+ px: 1.8,
+ borderRadius: "999px",
+ textTransform: "none",
+ fontSize: "0.9rem",
+ fontWeight: 600,
+ letterSpacing: "0.01em",
borderColor: tokens.button.ghostBorder,
color: tokens.button.ghostText,
"&:hover": {
@@ -484,10 +684,21 @@ export const PasteCreatePanel = ({
variant="contained"
disableElevation
sx={{
+ minHeight: 40,
+ minWidth: 96,
+ px: 1.8,
+ borderRadius: "999px",
+ textTransform: "none",
+ fontSize: "0.9rem",
+ fontWeight: 600,
+ letterSpacing: "0.01em",
bgcolor: tokens.button.primaryBg,
color: tokens.button.primaryText,
+ boxShadow: "0 2px 8px rgba(47, 109, 247, 0.2)",
"&:hover": {
bgcolor: tokens.button.primaryHoverBg,
+ boxShadow:
+ "0 3px 10px rgba(47, 109, 247, 0.24)",
},
}}
>
diff --git a/web/apps/paste/src/features/paste/hooks/useCreatePaste.ts b/web/apps/paste/src/features/paste/hooks/useCreatePaste.ts
index 8a1dda290a..d7f473d315 100644
--- a/web/apps/paste/src/features/paste/hooks/useCreatePaste.ts
+++ b/web/apps/paste/src/features/paste/hooks/useCreatePaste.ts
@@ -11,6 +11,8 @@ export const useCreatePaste = () => {
const [creating, setCreating] = useState(false);
const [createError, setCreateError] = useState<string | null>(null);
const [createdLink, setCreatedLink] = useState<string | null>(null);
+ const [createdLinkPasswordProtected, setCreatedLinkPasswordProtected] =
+ useState(false);
const createSecureLink = async (password?: string) => {
setCreateError(null);
@@ -33,6 +35,7 @@ export const useCreatePaste = () => {
);
const response = await createPaste(payload);
setCreatedLink(buildPasteLink(response.accessToken, linkFragment));
+ setCreatedLinkPasswordProtected(!!password);
} catch (error) {
const message =
error instanceof Error
@@ -50,6 +53,7 @@ export const useCreatePaste = () => {
creating,
createError,
createdLink,
+ createdLinkPasswordProtected,
createSecureLink,
};
};
diff --git a/web/apps/paste/src/pages/index.tsx b/web/apps/paste/src/pages/index.tsx
index 66ccdc30bd..d4572fbd39 100644
--- a/web/apps/paste/src/pages/index.tsx
+++ b/web/apps/paste/src/pages/index.tsx
@@ -21,6 +21,7 @@ const Page = () => {
creating,
createError,
createdLink,
+ createdLinkPasswordProtected,
createSecureLink,
} = useCreatePaste();
@@ -65,6 +66,9 @@ const Page = () => {
creating={creating}
createError={createError}
createdLink={createdLink}
+ createdLinkPasswordProtected={
+ createdLinkPasswordProtected
+ }
onInputChange={setInputText}
onCreate={createSecureLink}
onCopyLink={copyTextToClipboard}