Skip to content

armgit / ente

Public Imported from GitHub
0

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

update(locker):update-create-items-ui{

Aswin Asok4ca38408bca8
diff --git a/web/apps/locker/src/components/CreateItemDialog.tsx b/web/apps/locker/src/components/CreateItemDialog.tsx
index 63524c7bde..925d6df76f 100644
--- a/web/apps/locker/src/components/CreateItemDialog.tsx
+++ b/web/apps/locker/src/components/CreateItemDialog.tsx
@@ -1,3 +1,8 @@
+import {
+ lockerHeaderIconButtonSx,
+ lockerPrimaryButtonSx,
+ lockerScrollAreaSx,
+} from "@/components/createItemDialog/create-item-dialog-styles";
import {
addCollectionName,
toggleCollectionName,
@@ -9,11 +14,8 @@ import {
CollectionSelector,
ItemFormFields,
} from "@/components/createItemDialog/ItemFormFields";
-import { lockerDialogPaperSx } from "@/components/locker-dialog-styles";
import {
- createDocumentIcon,
createDocumentIconConfig,
- lockerItemIcon,
lockerItemIconConfig,
} from "@/components/locker-item-icons";
import type { LockerUploadLimitState } from "@/services/locker-limits";
@@ -23,6 +25,12 @@ import type {
LockerItemType,
LockerUploadCandidate,
} from "@/types";
+import {
+ ArrowLeft01Icon,
+ Cancel01Icon,
+ CancelCircleIcon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
import ChevronRightRoundedIcon from "@mui/icons-material/ChevronRightRounded";
import {
Box,
@@ -30,14 +38,14 @@ import {
Dialog,
DialogContent,
DialogTitle,
+ IconButton,
Link,
Stack,
Typography,
} from "@mui/material";
-import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import { t } from "i18next";
-import React, { useRef } from "react";
+import React, { type ComponentProps, useRef } from "react";
import { Trans } from "react-i18next";
import {
type CreateItemDialogEditItem,
@@ -49,39 +57,31 @@ const CREATABLE_TYPES: {
type: CreateOption;
labelKey: string;
descriptionKey: string;
- icon: React.ReactNode;
- bgColor: string;
+ icon: ComponentProps<typeof HugeiconsIcon>["icon"];
}[] = [
{
type: "file",
labelKey: "saveDocumentTitle",
descriptionKey: "saveDocumentDescription",
- icon: createDocumentIcon(28, 1.9),
- bgColor: createDocumentIconConfig.backgroundColor,
+ icon: createDocumentIconConfig.icon,
},
{
type: "note",
labelKey: "personalNote",
descriptionKey: "personalNoteDescription",
- icon: lockerItemIcon("note", { size: 28, strokeWidth: 1.9 }),
- bgColor: lockerItemIconConfig("note").backgroundColor,
+ icon: lockerItemIconConfig("note").icon,
},
{
type: "physicalRecord",
labelKey: "thing",
descriptionKey: "physicalRecordsDescription",
- icon: lockerItemIcon("physicalRecord", { size: 28, strokeWidth: 1.9 }),
- bgColor: lockerItemIconConfig("physicalRecord").backgroundColor,
+ icon: lockerItemIconConfig("physicalRecord").icon,
},
{
type: "accountCredential",
labelKey: "secret",
descriptionKey: "accountCredentialsDescription",
- icon: lockerItemIcon("accountCredential", {
- size: 28,
- strokeWidth: 1.9,
- }),
- bgColor: lockerItemIconConfig("accountCredential").backgroundColor,
+ icon: lockerItemIconConfig("accountCredential").icon,
},
];
@@ -147,6 +147,7 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
handleFileSelect,
handleSave,
handleSelectOption,
+ handleStepBackToOptions,
handleUpload,
isEditMode,
isFileMode,
@@ -193,31 +194,80 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
onClose={handleDialogClose}
fullWidth
maxWidth="sm"
+ sx={(theme) => ({
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0 0 0 / 0.6)" },
+ "& .MuiDialogTitle-root": { padding: 0 },
+ "& .MuiDialogContent-root": {
+ padding: 0,
+ paddingTop: "16px",
+ paddingRight: isFileMode ? 0 : "14px",
+ marginRight: isFileMode ? 0 : "-14px",
+ },
+ [theme.breakpoints.down("sm")]: {
+ "& .MuiDialog-container": { alignItems: "flex-end" },
+ },
+ })}
slotProps={{
paper: {
- sx: {
- ...lockerDialogPaperSx,
+ sx: (theme) => ({
display: "flex",
flexDirection: "column",
maxHeight: "min(720px, 90vh)",
- width: "min(100%, 520px)",
- },
+ width: "min(100%, 440px)",
+ borderRadius: "24px",
+ backgroundColor: theme.vars.palette.background.default,
+ padding: "20px",
+ margin: "16px",
+ [theme.breakpoints.down("sm")]: {
+ width: "100%",
+ maxWidth: "100%",
+ margin: 0,
+ borderRadius: "20px 20px 0 0",
+ paddingBottom:
+ "max(34px, env(safe-area-inset-bottom))",
+ maxHeight: "90vh",
+ },
+ }),
},
}}
>
- <DialogTitle
+ <Box
sx={{
display: "flex",
alignItems: "center",
- justifyContent: "space-between",
- gap: 2,
- fontWeight: "bold",
- px: { xs: 4, sm: 5 },
- pt: { xs: 4, sm: 4.5 },
- pb: { xs: 2, sm: 2.5 },
+ gap: "12px",
+ minHeight: 38,
+ flexShrink: 0,
}}
>
- <Box sx={{ minWidth: 0 }}>
+ {!isEditMode &&
+ selectedOption !== null &&
+ !(isFileMode && selectedUploadItems.length > 0) && (
+ <IconButton
+ onClick={handleStepBackToOptions}
+ disabled={saving || uploading}
+ aria-label={t("go_back")}
+ sx={lockerHeaderIconButtonSx}
+ >
+ <HugeiconsIcon
+ icon={ArrowLeft01Icon}
+ size={18}
+ strokeWidth={1.5}
+ />
+ </IconButton>
+ )}
+ <DialogTitle
+ sx={{
+ flex: 1,
+ minWidth: 0,
+ fontSize: 18,
+ lineHeight: "24px",
+ fontWeight: 600,
+ whiteSpace: "nowrap",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ }}
+ >
{isEditMode
? t("editItem")
: isFileMode
@@ -227,27 +277,23 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
: selectedType
? typeDisplayName(selectedType)
: t("saveToLocker")}
- </Box>
- {showUploadCounter && (
- <Typography
- variant="small"
- sx={{
- flexShrink: 0,
- color: "text.muted",
- opacity: 0.8,
- fontWeight: 500,
- alignSelf: "center",
- }}
- >
- {savedUploadCount} / {totalUploadCount} {t("saved")}
- </Typography>
- )}
- </DialogTitle>
+ </DialogTitle>
+ <IconButton
+ onClick={handleClose}
+ disabled={saving || uploading}
+ aria-label={t("close")}
+ sx={lockerHeaderIconButtonSx}
+ >
+ <HugeiconsIcon
+ icon={Cancel01Icon}
+ size={18}
+ strokeWidth={1.5}
+ />
+ </IconButton>
+ </Box>
<DialogContent
- sx={{
- px: { xs: 4, sm: 5 },
- py: { xs: 2.5, sm: 3 },
+ sx={(theme) => ({
...(isFileMode
? {
display: "flex",
@@ -256,23 +302,40 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
minHeight: 0,
overflow: "hidden",
}
- : {}),
- }}
+ : lockerScrollAreaSx(theme)),
+ })}
>
{shouldShowDialogErrorCard && (
<Box
- sx={(theme) => ({
- mb: 2.5,
- px: 2,
- py: 1.5,
- borderRadius: "16px",
- border: `1px solid ${theme.vars.palette.critical.main}22`,
- backgroundColor: `${theme.vars.palette.critical.main}12`,
- })}
+ sx={{
+ display: "flex",
+ alignItems: "center",
+ gap: "16px",
+ minHeight: 66,
+ px: "16px",
+ py: "12px",
+ mb: "16px",
+ borderRadius: "20px",
+ backgroundColor: "background.paper",
+ flexShrink: 0,
+ }}
>
+ <Box
+ sx={{
+ color: "critical.main",
+ flexShrink: 0,
+ display: "flex",
+ }}
+ >
+ <HugeiconsIcon
+ icon={CancelCircleIcon}
+ size={24}
+ strokeWidth={1.5}
+ />
+ </Box>
<Typography
- variant="small"
- sx={{ color: "critical.main", fontWeight: 600 }}
+ variant="mini"
+ sx={{ color: "text.muted", minWidth: 0 }}
>
{upgradeCTAType === "fileCountLimit" ? (
<Trans
@@ -285,8 +348,8 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
rel="noopener"
underline="always"
sx={{
- color: "critical.main",
- fontWeight: 700,
+ color: "accent.main",
+ fontWeight: 600,
}}
/>
),
@@ -300,18 +363,20 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
)}
{!isEditMode && !selectedOption && (
- <Stack sx={{ gap: 2, pt: 0.5 }}>
- <Typography variant="body" sx={{ color: "text.muted" }}>
+ <Stack sx={{ gap: "24px" }}>
+ <Typography
+ variant="small"
+ sx={{ color: "text.muted" }}
+ >
{t("informationDescription")}
</Typography>
- <Stack sx={{ gap: 1 }}>
+ <Stack sx={{ gap: "16px" }}>
{CREATABLE_TYPES.map((option) => (
<TypeCard
key={option.type}
label={t(option.labelKey)}
description={t(option.descriptionKey)}
icon={option.icon}
- bgColor={option.bgColor}
onClick={() =>
handleSelectOption(option.type)
}
@@ -322,80 +387,99 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
)}
{isFileMode && !isEditMode && (
- <FileUploadSection
- fileInputRef={fileInputRef}
- selectedUploadItems={selectedUploadItems}
- collections={displayCollections}
- availableCollectionNames={customCollectionNames}
- selectedCollectionNamesByFileKey={
- selectedCollectionNamesByFileKey
- }
- completedFileKeys={completedFileKeys}
- failedFileKeys={failedFileKeys}
- uploadingFileKeys={uploadingFileKeys}
- uploadProgressByFileKey={uploadProgressByFileKey}
- uploadCapByFileKey={uploadCapByFileKey}
- uploading={uploading}
- canUpload={canUpload}
- onFileSelect={handleFileSelect}
- onToggleCollectionName={(fileKey, name) =>
- setSelectedCollectionNamesByFileKey((current) => ({
- ...current,
- [fileKey]: toggleCollectionName(
- current[fileKey] ?? [],
- name,
- ),
- }))
- }
- onAddCollectionName={(fileKey, name) => {
- setCustomCollectionNames((current) =>
- addCollectionName(current, name),
- );
- setSelectedCollectionNamesByFileKey((current) => ({
- ...current,
- [fileKey]: addCollectionName(
- current[fileKey] ?? [],
- name,
- ),
- }));
- }}
- onAddAvailableCollectionName={(name) =>
- setCustomCollectionNames((current) =>
- addCollectionName(current, name),
- )
- }
- onSetCollectionNamesForAllItems={(names) =>
- setSelectedCollectionNamesByFileKey(
- Object.fromEntries(
- selectedUploadItems.map((item) => [
- uploadQueueItemKey(item),
- names,
- ]),
- ),
- )
- }
- onRemoveItem={(fileKey) => {
- setSelectedUploadItems((current) =>
- current.filter(
- (item) =>
- uploadQueueItemKey(item) !== fileKey,
- ),
- );
- setSelectedCollectionNamesByFileKey((current) =>
- Object.fromEntries(
- Object.entries(current).filter(
- ([key]) => key !== fileKey,
+ <>
+ {showUploadCounter && (
+ <Typography
+ variant="small"
+ sx={{
+ color: "text.muted",
+ mb: "16px",
+ flexShrink: 0,
+ }}
+ >
+ {savedUploadCount} / {totalUploadCount}{" "}
+ {t("saved")}
+ </Typography>
+ )}
+ <FileUploadSection
+ fileInputRef={fileInputRef}
+ selectedUploadItems={selectedUploadItems}
+ collections={displayCollections}
+ availableCollectionNames={customCollectionNames}
+ selectedCollectionNamesByFileKey={
+ selectedCollectionNamesByFileKey
+ }
+ completedFileKeys={completedFileKeys}
+ failedFileKeys={failedFileKeys}
+ uploadingFileKeys={uploadingFileKeys}
+ uploadProgressByFileKey={uploadProgressByFileKey}
+ uploadCapByFileKey={uploadCapByFileKey}
+ uploading={uploading}
+ canUpload={canUpload}
+ onFileSelect={handleFileSelect}
+ onToggleCollectionName={(fileKey, name) =>
+ setSelectedCollectionNamesByFileKey(
+ (current) => ({
+ ...current,
+ [fileKey]: toggleCollectionName(
+ current[fileKey] ?? [],
+ name,
+ ),
+ }),
+ )
+ }
+ onAddCollectionName={(fileKey, name) => {
+ setCustomCollectionNames((current) =>
+ addCollectionName(current, name),
+ );
+ setSelectedCollectionNamesByFileKey(
+ (current) => ({
+ ...current,
+ [fileKey]: addCollectionName(
+ current[fileKey] ?? [],
+ name,
+ ),
+ }),
+ );
+ }}
+ onAddAvailableCollectionName={(name) =>
+ setCustomCollectionNames((current) =>
+ addCollectionName(current, name),
+ )
+ }
+ onSetCollectionNamesForAllItems={(names) =>
+ setSelectedCollectionNamesByFileKey(
+ Object.fromEntries(
+ selectedUploadItems.map((item) => [
+ uploadQueueItemKey(item),
+ names,
+ ]),
),
- ),
- );
- }}
- onClose={handleClose}
- onUpload={handleUpload}
- />
+ )
+ }
+ onRemoveItem={(fileKey) => {
+ setSelectedUploadItems((current) =>
+ current.filter(
+ (item) =>
+ uploadQueueItemKey(item) !==
+ fileKey,
+ ),
+ );
+ setSelectedCollectionNamesByFileKey((current) =>
+ Object.fromEntries(
+ Object.entries(current).filter(
+ ([key]) => key !== fileKey,
+ ),
+ ),
+ );
+ }}
+ onUpload={handleUpload}
+ />
+ </>
)}
{formType && (!isFileMode || isEditMode) && (
- <Stack sx={{ gap: 2.5, pt: 0.5 }}>
+ <Stack sx={{ gap: "24px" }}>
<ItemFormFields
type={formType}
data={formData}
@@ -436,25 +520,20 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
</Typography>
)}
- <Stack direction="row" sx={{ gap: 1, pt: 1 }}>
- <FocusVisibleButton
- fullWidth
- color="secondary"
- onClick={handleClose}
- disabled={saving}
- >
- {t("cancel")}
- </FocusVisibleButton>
- <LoadingButton
- fullWidth
- color="accent"
- loading={saving}
- disabled={!canSave}
- onClick={() => void handleSave()}
- >
- {t("saveRecord")}
- </LoadingButton>
- </Stack>
+ <LoadingButton
+ fullWidth
+ color="accent"
+ loading={saving}
+ disabled={!canSave}
+ onClick={() => void handleSave()}
+ sx={(theme) =>
+ lockerPrimaryButtonSx(theme, {
+ loading: saving,
+ })
+ }
+ >
+ {t("saveRecord")}
+ </LoadingButton>
</Stack>
)}
</DialogContent>
@@ -465,61 +544,65 @@ export const CreateItemDialog: React.FC<CreateItemDialogProps> = ({
const TypeCard: React.FC<{
label: string;
description: string;
- icon: React.ReactNode;
- bgColor: string;
+ icon: ComponentProps<typeof HugeiconsIcon>["icon"];
onClick: () => void;
-}> = ({ label, description, icon, bgColor, onClick }) => (
+}> = ({ label, description, icon, onClick }) => (
<ButtonBase
onClick={onClick}
sx={(theme) => ({
display: "flex",
alignItems: "center",
- justifyContent: "space-between",
width: "100%",
- gap: 2,
- px: 1,
- py: 1.25,
- borderRadius: "12px",
+ gap: "12px",
+ px: "12px",
+ py: "9px",
+ minHeight: 58,
+ borderRadius: "20px",
+ backgroundColor: theme.vars.palette.background.paper,
transition: "background-color 0.15s",
textAlign: "left",
"&:hover": { backgroundColor: theme.vars.palette.fill.faintHover },
})}
>
+ <Box
+ sx={(theme) => ({
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ width: 36,
+ height: 36,
+ flexShrink: 0,
+ color: theme.vars.palette.accent.main,
+ })}
+ >
+ <HugeiconsIcon
+ icon={icon}
+ size={20}
+ strokeWidth={1.5}
+ color="currentColor"
+ />
+ </Box>
+ <Box sx={{ flex: 1, minWidth: 0 }}>
+ <Typography variant="small" sx={{ fontWeight: 500 }}>
+ {label}
+ </Typography>
+ <Typography variant="mini" sx={{ color: "text.muted", mt: "4px" }}>
+ {description}
+ </Typography>
+ </Box>
<Box
sx={{
+ width: 36,
+ height: 36,
display: "flex",
alignItems: "center",
- gap: 2,
- minWidth: 0,
- flex: 1,
+ justifyContent: "center",
+ flexShrink: 0,
}}
>
- <Box
- sx={{
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- width: 48,
- height: 48,
- borderRadius: "50%",
- backgroundColor: bgColor,
- flexShrink: 0,
- }}
- >
- {icon}
- </Box>
- <Box sx={{ minWidth: 0, flex: 1 }}>
- <Typography variant="body" sx={{ fontWeight: "medium" }}>
- {label}
- </Typography>
- <Typography
- variant="small"
- sx={{ color: "text.muted", textWrap: "balance" }}
- >
- {description}
- </Typography>
- </Box>
+ <ChevronRightRoundedIcon
+ sx={{ fontSize: 24, color: "text.base" }}
+ />
</Box>
- <ChevronRightRoundedIcon sx={{ color: "text.faint", flexShrink: 0 }} />
</ButtonBase>
);
diff --git a/web/apps/locker/src/components/createItemDialog/CollectionChipRow.tsx b/web/apps/locker/src/components/createItemDialog/CollectionChipRow.tsx
index cdfacebf9c..7f171127bb 100644
--- a/web/apps/locker/src/components/createItemDialog/CollectionChipRow.tsx
+++ b/web/apps/locker/src/components/createItemDialog/CollectionChipRow.tsx
@@ -1,8 +1,8 @@
-import ChevronLeftRoundedIcon from "@mui/icons-material/ChevronLeftRounded";
-import ChevronRightRoundedIcon from "@mui/icons-material/ChevronRightRounded";
-import { Box, ButtonBase, Stack, Typography } from "@mui/material";
+import { Add01Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { Box, ButtonBase, Typography } from "@mui/material";
import { t } from "i18next";
-import React, { useEffect, useRef, useState } from "react";
+import React from "react";
interface CollectionChipRowItem {
key: string;
@@ -17,215 +17,104 @@ export const CollectionChipRow: React.FC<{
disabled?: boolean;
onCreateClick?: () => void;
}> = ({ items, createOpen, disabled, onCreateClick }) => {
- const scrollContainerRef = useRef<HTMLDivElement | null>(null);
- const [canScrollLeft, setCanScrollLeft] = useState(false);
- const [canScrollRight, setCanScrollRight] = useState(false);
-
- const scrollBy = (direction: number) => {
- const container = scrollContainerRef.current;
- if (!container) {
- return;
- }
-
- container.scrollBy({
- left: direction * Math.max(container.clientWidth * 0.6, 160),
- behavior: "smooth",
- });
- };
-
- useEffect(() => {
- const container = scrollContainerRef.current;
- if (!container) {
- return;
- }
-
- const updateScrollHints = () => {
- setCanScrollLeft(container.scrollLeft > 8);
- const remainingScroll =
- container.scrollWidth -
- container.clientWidth -
- container.scrollLeft;
- setCanScrollRight(remainingScroll > 8);
- };
-
- updateScrollHints();
- container.addEventListener("scroll", updateScrollHints, {
- passive: true,
- });
- window.addEventListener("resize", updateScrollHints);
-
- return () => {
- container.removeEventListener("scroll", updateScrollHints);
- window.removeEventListener("resize", updateScrollHints);
- };
- }, [createOpen, items.length]);
-
return (
<Box>
- <Stack
- direction="row"
+ <Typography
+ variant="small"
sx={{
- alignItems: "center",
- justifyContent: "space-between",
- gap: 1,
- mb: 1.25,
+ fontWeight: 600,
+ lineHeight: "20px",
+ mb: "8px",
+ display: "block",
}}
>
- <Typography
- variant="small"
- sx={{
- color: "text.faint",
- fontWeight: "bold",
- textTransform: "uppercase",
- letterSpacing: "0.08em",
- display: "block",
- }}
- >
- {t("collections")}
- </Typography>
- </Stack>
- <Box sx={{ position: "relative", minWidth: 0 }}>
- <Box
- sx={{
- position: "absolute",
- left: 0,
- top: 0,
- bottom: 0,
- zIndex: 1,
- display: "flex",
- alignItems: "center",
- }}
- >
- {canScrollLeft && (
- <ButtonBase
- onClick={() => scrollBy(-1)}
- disabled={disabled}
- sx={(theme) => ({
- width: 28,
- height: 28,
- color: "#4A4A4A",
- borderRadius: "999px",
+ {t("collections")}
+ </Typography>
+ <Box sx={{ display: "flex", flexWrap: "wrap", gap: "12px 8px" }}>
+ {onCreateClick && (
+ <ButtonBase
+ onClick={onCreateClick}
+ disabled={disabled}
+ sx={(theme) => ({
+ minHeight: 42,
+ maxWidth: "100%",
+ minWidth: 0,
+ px: "16px",
+ py: "8px",
+ gap: "6px",
+ borderRadius: "16px",
+ border: `1px dashed ${theme.vars.palette.stroke.muted}`,
+ color: theme.vars.palette.text.muted,
+ backgroundColor: createOpen
+ ? theme.vars.palette.background.paper
+ : "transparent",
+ "&:hover": {
backgroundColor:
- theme.vars.palette.background.paper,
- ...theme.applyStyles("dark", {
- color: "#FFFFFF",
- }),
- })}
- >
- <ChevronLeftRoundedIcon sx={{ fontSize: 28 }} />
- </ButtonBase>
- )}
- </Box>
- <Box sx={{ position: "relative", minWidth: 0 }}>
- <Stack
- ref={scrollContainerRef}
- direction="row"
- sx={{
- gap: 1,
- flexWrap: "nowrap",
- overflowX: "auto",
- overflowY: "hidden",
- px: 0.5,
- pb: 0.5,
- maskImage:
- canScrollLeft && canScrollRight
- ? "linear-gradient(90deg, rgba(0,0,0,0) 0%, #000 64px, #000 calc(100% - 64px), rgba(0,0,0,0) 100%)"
- : canScrollLeft
- ? "linear-gradient(90deg, rgba(0,0,0,0) 0%, #000 64px)"
- : canScrollRight
- ? "linear-gradient(90deg, #000 0%, #000 calc(100% - 64px), rgba(0,0,0,0) 100%)"
- : undefined,
- WebkitMaskImage:
- canScrollLeft && canScrollRight
- ? "linear-gradient(90deg, rgba(0,0,0,0) 0%, #000 64px, #000 calc(100% - 64px), rgba(0,0,0,0) 100%)"
- : canScrollLeft
- ? "linear-gradient(90deg, rgba(0,0,0,0) 0%, #000 64px)"
- : canScrollRight
- ? "linear-gradient(90deg, #000 0%, #000 calc(100% - 64px), rgba(0,0,0,0) 100%)"
- : undefined,
- scrollbarWidth: "none",
- "&::-webkit-scrollbar": { display: "none" },
- }}
+ theme.vars.palette.fill.faintHover,
+ },
+ "&.Mui-disabled": {
+ backgroundColor:
+ theme.vars.palette.fill.faintHover,
+ color: theme.vars.palette.text.faint,
+ },
+ })}
>
- {onCreateClick && (
- <ButtonBase
- onClick={onCreateClick}
- disabled={disabled}
- sx={(theme) => ({
- borderRadius: "999px",
- px: 1.5,
- py: 0.875,
- whiteSpace: "nowrap",
- flexShrink: 0,
- border: `1px dotted ${theme.vars.palette.stroke.muted}`,
- color: theme.vars.palette.text.muted,
- backgroundColor: createOpen
- ? theme.vars.palette.fill.faint
- : "transparent",
- })}
- >
- <Typography variant="small">
- + {t("collection")}
- </Typography>
- </ButtonBase>
- )}
- {items.map((item) => (
- <ButtonBase
- key={item.key}
- onClick={item.onClick}
- disabled={disabled}
- sx={(theme) => ({
- borderRadius: "999px",
- px: 1.5,
- py: 0.875,
- whiteSpace: "nowrap",
- flexShrink: 0,
- backgroundColor: item.selected
- ? "#1071FF"
- : theme.vars.palette.fill.faint,
- color: item.selected
- ? "#FFFFFF"
- : theme.vars.palette.text.base,
- })}
- >
- <Typography variant="small">
- {item.label}
- </Typography>
- </ButtonBase>
- ))}
- </Stack>
- </Box>
- <Box
- sx={{
- position: "absolute",
- right: 0,
- top: 0,
- bottom: 0,
- zIndex: 1,
- display: "flex",
- alignItems: "center",
- }}
- >
- {canScrollRight && (
- <ButtonBase
- onClick={() => scrollBy(1)}
- disabled={disabled}
- sx={(theme) => ({
- width: 28,
- height: 28,
- color: "#4A4A4A",
- borderRadius: "999px",
+ <Box sx={{ display: "flex", flexShrink: 0 }}>
+ <HugeiconsIcon
+ icon={Add01Icon}
+ size={18}
+ strokeWidth={1.5}
+ />
+ </Box>
+ <Typography
+ variant="small"
+ noWrap
+ sx={{ fontWeight: 500, lineHeight: "20px" }}
+ >
+ {t("collection")}
+ </Typography>
+ </ButtonBase>
+ )}
+ {items.map((item) => (
+ <ButtonBase
+ key={item.key}
+ onClick={item.onClick}
+ disabled={disabled}
+ sx={(theme) => ({
+ minHeight: 44,
+ maxWidth: "100%",
+ minWidth: 0,
+ px: "20px",
+ py: "12px",
+ borderRadius: "16px",
+ backgroundColor: item.selected
+ ? theme.vars.palette.accent.main
+ : theme.vars.palette.background.paper,
+ color: item.selected
+ ? theme.vars.palette.accent.contrastText
+ : theme.vars.palette.text.muted,
+ transition: "background-color 0.15s",
+ "&:hover": {
+ backgroundColor: item.selected
+ ? theme.vars.palette.accent.dark
+ : theme.vars.palette.fill.faintHover,
+ },
+ "&.Mui-disabled": {
backgroundColor:
- theme.vars.palette.background.paper,
- ...theme.applyStyles("dark", {
- color: "#FFFFFF",
- }),
- })}
+ theme.vars.palette.fill.faintHover,
+ color: theme.vars.palette.text.faint,
+ },
+ })}
+ >
+ <Typography
+ variant="small"
+ noWrap
+ sx={{ fontWeight: 500, lineHeight: "20px" }}
>
- <ChevronRightRoundedIcon sx={{ fontSize: 28 }} />
- </ButtonBase>
- )}
- </Box>
+ {item.label}
+ </Typography>
+ </ButtonBase>
+ ))}
</Box>
</Box>
);
diff --git a/web/apps/locker/src/components/createItemDialog/CreateCollectionRow.tsx b/web/apps/locker/src/components/createItemDialog/CreateCollectionRow.tsx
new file mode 100644
index 0000000000..5ef3c0afba
--- /dev/null
+++ b/web/apps/locker/src/components/createItemDialog/CreateCollectionRow.tsx
@@ -0,0 +1,66 @@
+import {
+ lockerFieldSx,
+ lockerPrimaryButtonSx,
+} from "@/components/createItemDialog/create-item-dialog-styles";
+import { Tick02Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { Stack, TextField } from "@mui/material";
+import { LoadingButton } from "ente-base/components/mui/LoadingButton";
+import { t } from "i18next";
+import React from "react";
+
+export const CreateCollectionRow: React.FC<{
+ value: string;
+ onChange: (value: string) => void;
+ onSubmit: () => void;
+ onCancel: () => void;
+ loading?: boolean;
+ disabled?: boolean;
+}> = ({ value, onChange, onSubmit, onCancel, loading = false, disabled }) => (
+ <Stack
+ direction="row"
+ sx={{ gap: "8px", alignItems: "center", mt: "12px" }}
+ >
+ <TextField
+ size="small"
+ fullWidth
+ autoFocus
+ placeholder={t("enterCollectionName")}
+ variant="outlined"
+ margin="none"
+ sx={(theme) => lockerFieldSx(theme, { activeBorder: true })}
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ disabled={disabled}
+ onKeyDown={(event) => {
+ if (event.key === "Escape") {
+ event.preventDefault();
+ event.stopPropagation();
+ onCancel();
+ return;
+ }
+ if (event.key === "Enter") {
+ event.preventDefault();
+ onSubmit();
+ }
+ }}
+ />
+ <LoadingButton
+ color="accent"
+ loading={loading}
+ disabled={!value.trim() || disabled}
+ aria-label={t("create")}
+ onClick={onSubmit}
+ sx={(theme) => ({
+ ...lockerPrimaryButtonSx(theme, { loading }),
+ minWidth: 0,
+ width: 52,
+ height: 52,
+ p: 0,
+ flexShrink: 0,
+ })}
+ >
+ <HugeiconsIcon icon={Tick02Icon} size={20} strokeWidth={1.5} />
+ </LoadingButton>
+ </Stack>
+);
diff --git a/web/apps/locker/src/components/createItemDialog/FileUploadSection.tsx b/web/apps/locker/src/components/createItemDialog/FileUploadSection.tsx
index cfbfb6ad31..13642fd2c1 100644
--- a/web/apps/locker/src/components/createItemDialog/FileUploadSection.tsx
+++ b/web/apps/locker/src/components/createItemDialog/FileUploadSection.tsx
@@ -1,25 +1,26 @@
import { CollectionChipRow } from "@/components/createItemDialog/CollectionChipRow";
import {
- lockerItemIcon,
- lockerItemIconConfig,
-} from "@/components/locker-item-icons";
+ lockerPrimaryButtonSx,
+ lockerScrollAreaSx,
+} from "@/components/createItemDialog/create-item-dialog-styles";
+import { CreateCollectionRow } from "@/components/createItemDialog/CreateCollectionRow";
+import { lockerItemIcon } from "@/components/locker-item-icons";
import type { LockerUploadProgress } from "@/services/remote";
import type { LockerCollection, LockerUploadCandidate } from "@/types";
+import { Cancel01Icon, FileUploadIcon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
import CheckRoundedIcon from "@mui/icons-material/CheckRounded";
-import CloudUploadOutlinedIcon from "@mui/icons-material/CloudUploadOutlined";
-import DeleteOutlineRoundedIcon from "@mui/icons-material/DeleteOutlineRounded";
import ErrorOutlineRoundedIcon from "@mui/icons-material/ErrorOutlineRounded";
import ScheduleRoundedIcon from "@mui/icons-material/ScheduleRounded";
import {
Box,
ButtonBase,
+ CircularProgress,
IconButton,
LinearProgress,
Stack,
- TextField,
Typography,
} from "@mui/material";
-import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import { t } from "i18next";
import React, {
@@ -61,7 +62,6 @@ interface FileUploadSectionProps {
onAddAvailableCollectionName: (name: string) => void;
onSetCollectionNamesForAllItems: (names: string[]) => void;
onRemoveItem: (fileKey: string) => void;
- onClose: () => void;
onUpload: () => Promise<void>;
}
@@ -84,7 +84,6 @@ export function FileUploadSection({
onAddAvailableCollectionName,
onSetCollectionNamesForAllItems,
onRemoveItem,
- onClose,
onUpload,
}: FileUploadSectionProps) {
const [settledCompletedFileKeys, setSettledCompletedFileKeys] = useState<
@@ -242,7 +241,7 @@ export function FileUploadSection({
}, [orderedUploadItems]);
return (
- <Stack sx={{ flex: 1, minHeight: 0, pt: 0.5 }}>
+ <Stack sx={{ flex: 1, minHeight: 0 }}>
<input
ref={fileInputRef}
type="file"
@@ -252,14 +251,13 @@ export function FileUploadSection({
/>
<Stack
- sx={{
+ sx={(theme) => ({
+ ...lockerScrollAreaSx(theme),
flex: 1,
minHeight: 0,
- overflowY: "auto",
- gap: 2.5,
- pr: 0.5,
- pb: 2,
- }}
+ gap: "16px",
+ pb: "8px",
+ })}
>
{selectedUploadItems.length === 0 ? (
<ButtonBase
@@ -268,11 +266,14 @@ export function FileUploadSection({
display: "flex",
flexDirection: "column",
alignItems: "center",
- gap: 1.5,
- p: 4,
- borderRadius: "16px",
- border: `2px dashed ${theme.vars.palette.divider}`,
- backgroundColor: theme.vars.palette.fill.faint,
+ gap: "4px",
+ px: "20px",
+ py: "28px",
+ borderRadius: "20px",
+ border: `1px dashed ${theme.vars.palette.stroke.muted}`,
+ backgroundColor:
+ theme.vars.palette.background.paper,
+ textAlign: "center",
transition: "background-color 0.15s",
"&:hover": {
backgroundColor:
@@ -280,21 +281,34 @@ export function FileUploadSection({
},
})}
>
- <CloudUploadOutlinedIcon
- sx={{ fontSize: 40, color: "text.faint" }}
- />
- <Typography variant="body" sx={{ fontWeight: 600 }}>
+ <Box
+ sx={{
+ width: 40,
+ height: 40,
+ borderRadius: "12px",
+ backgroundColor: "background.default",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ mb: "8px",
+ color: "accent.main",
+ }}
+ >
+ <HugeiconsIcon
+ icon={FileUploadIcon}
+ size={24}
+ strokeWidth={1.5}
+ />
+ </Box>
+ <Typography variant="small" sx={{ fontWeight: 600 }}>
{t("saveDocumentsTitle")}
</Typography>
- <Typography
- variant="small"
- sx={{ color: "text.muted" }}
- >
+ <Typography variant="mini" sx={{ color: "text.muted" }}>
{t("dropToSaveToLocker")}
</Typography>
</ButtonBase>
) : (
- <Stack sx={{ gap: 1.25 }}>
+ <Stack sx={{ gap: "8px" }}>
{orderedUploadItems.map((item) => {
const fileKey = uploadQueueItemKey(item);
const isSettledCompleted =
@@ -375,66 +389,51 @@ export function FileUploadSection({
})}
</Stack>
)}
- </Stack>
-
- <Stack
- sx={(theme) => ({
- gap: 1.5,
- pt: 2,
- borderTop: `1px solid ${theme.vars.palette.stroke.faint}`,
- backgroundColor: theme.vars.palette.background.paper,
- })}
- >
{!uploading &&
!shouldShowPerItemCollectionSelector &&
selectedUploadItems.length > 0 && (
- <CollectionNameSelector
- collections={collections}
- availableNames={availableCollectionNames}
- selectedNames={sharedSelectedCollectionNames}
- suggestedNames={sharedSuggestedCollectionNames}
- onToggleName={(name) =>
- onSetCollectionNamesForAllItems(
- toggleCollectionName(
- sharedSelectedCollectionNames,
- name,
- ),
- )
- }
- onAddCollectionName={(name) => {
- onAddAvailableCollectionName(name);
- onSetCollectionNamesForAllItems(
- addCollectionName(
- sharedSelectedCollectionNames,
- name,
- ),
- );
- }}
- disabled={uploading}
- />
+ <Box sx={{ pt: "8px" }}>
+ <CollectionNameSelector
+ collections={collections}
+ availableNames={availableCollectionNames}
+ selectedNames={sharedSelectedCollectionNames}
+ suggestedNames={sharedSuggestedCollectionNames}
+ onToggleName={(name) =>
+ onSetCollectionNamesForAllItems(
+ toggleCollectionName(
+ sharedSelectedCollectionNames,
+ name,
+ ),
+ )
+ }
+ onAddCollectionName={(name) => {
+ onAddAvailableCollectionName(name);
+ onSetCollectionNamesForAllItems(
+ addCollectionName(
+ sharedSelectedCollectionNames,
+ name,
+ ),
+ );
+ }}
+ disabled={uploading}
+ />
+ </Box>
)}
+ </Stack>
- <Stack direction="row" sx={{ gap: 1 }}>
- <FocusVisibleButton
- fullWidth
- color="secondary"
- onClick={onClose}
- disabled={uploading}
- sx={{ borderRadius: "16px", py: 1.25 }}
- >
- {t("cancel")}
- </FocusVisibleButton>
- <LoadingButton
- fullWidth
- color="accent"
- loading={uploading}
- disabled={!canUpload}
- sx={{ borderRadius: "16px", py: 1.25 }}
- onClick={() => void onUpload()}
- >
- {t("saveRecord")}
- </LoadingButton>
- </Stack>
+ <Stack sx={{ pt: "16px", flexShrink: 0 }}>
+ <LoadingButton
+ fullWidth
+ color="accent"
+ loading={uploading}
+ disabled={!canUpload}
+ sx={(theme) =>
+ lockerPrimaryButtonSx(theme, { loading: uploading })
+ }
+ onClick={() => void onUpload()}
+ >
+ {t("saveRecord")}
+ </LoadingButton>
</Stack>
</Stack>
);
@@ -481,115 +480,116 @@ const UploadItemCard = React.memo(function UploadItemCard({
}: UploadItemCardProps) {
return (
<Stack
- sx={{
- borderRadius: "12px",
- backgroundColor: (theme) => theme.vars.palette.fill.faint,
+ sx={(theme) => ({
+ position: "relative",
overflow: "hidden",
- display: "flex",
- flexDirection: "column",
- }}
+ borderRadius: "20px",
+ backgroundColor: theme.vars.palette.background.paper,
+ })}
>
<Stack
direction="row"
- sx={{
- alignItems: "center",
- gap: 1.5,
- p: 2,
- position: "relative",
- }}
+ sx={{ alignItems: "center", gap: "12px", p: "12px" }}
>
<Box
- sx={{
+ sx={(theme) => ({
display: "flex",
alignItems: "center",
justifyContent: "center",
- width: 48,
- height: 48,
+ width: 40,
+ height: 40,
borderRadius: "12px",
- backgroundColor: lockerItemIconConfig(
- "file",
- item.file.name,
- ).backgroundColor,
+ backgroundColor: theme.vars.palette.background.default,
flexShrink: 0,
- }}
+ })}
>
{lockerItemIcon("file", {
fileName: item.file.name,
size: 24,
- strokeWidth: 1.9,
+ strokeWidth: 1.5,
})}
</Box>
- <Box sx={{ flex: 1, minWidth: 0, pr: canRemove ? 5 : 0 }}>
- <Typography variant="body" noWrap>
+ <Box sx={{ flex: 1, minWidth: 0 }}>
+ <Typography variant="small" noWrap>
{item.file.name}
</Typography>
- <Typography variant="small" sx={{ color: "text.faint" }}>
+ <Typography variant="mini" sx={{ color: "text.muted" }}>
{formatFileSize(item.file.size)}
</Typography>
</Box>
- {isDone && (
- <Box
- sx={() => ({
- width: 24,
- height: 24,
- borderRadius: "50%",
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- backgroundColor: "#1071FF",
- color: "#FFFFFF",
- flexShrink: 0,
- })}
- >
- <CheckRoundedIcon sx={{ fontSize: 16 }} />
- </Box>
- )}
- {isFailed && (
- <ErrorOutlineRoundedIcon
- sx={{
- color: "critical.main",
- fontSize: 20,
- flexShrink: 0,
- }}
- />
- )}
- {isQueued && (
- <ScheduleRoundedIcon
- sx={{
- color: "text.muted",
- fontSize: 20,
- flexShrink: 0,
- }}
- />
- )}
- {canRemove && !isDone && !isFailed && (
- <IconButton
- aria-label={t("delete")}
- onClick={onRemove}
- size="small"
- sx={(theme) => ({
- position: "absolute",
- top: 12,
- right: 12,
- width: 30,
- height: 30,
- borderRadius: "10px",
- backgroundColor: "transparent",
- color: theme.vars.palette.text.muted,
- flexShrink: 0,
- "&:hover": {
+ <Box
+ sx={{
+ width: 28,
+ height: 28,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ flexShrink: 0,
+ }}
+ >
+ {isUploading && (
+ <CircularProgress
+ size={18}
+ thickness={4}
+ sx={{ color: "text.muted" }}
+ />
+ )}
+ {isDone && (
+ <Box
+ sx={(theme) => ({
+ width: 18,
+ height: 18,
+ borderRadius: "50%",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ backgroundColor: theme.vars.palette.accent.main,
+ color: theme.vars.palette.accent.contrastText,
+ })}
+ >
+ <CheckRoundedIcon sx={{ fontSize: 12 }} />
+ </Box>
+ )}
+ {isFailed && (
+ <ErrorOutlineRoundedIcon
+ sx={{ color: "critical.main", fontSize: 20 }}
+ />
+ )}
+ {isQueued && (
+ <ScheduleRoundedIcon
+ sx={{ color: "text.muted", fontSize: 20 }}
+ />
+ )}
+ {canRemove && !isDone && !isFailed && (
+ <IconButton
+ aria-label={t("delete")}
+ onClick={onRemove}
+ size="small"
+ sx={(theme) => ({
+ width: 28,
+ height: 28,
+ p: 0,
+ borderRadius: "50%",
backgroundColor:
theme.vars.palette.fill.faintHover,
color: theme.vars.palette.text.base,
- },
- })}
- >
- <DeleteOutlineRoundedIcon sx={{ fontSize: 16 }} />
- </IconButton>
- )}
+ "&:hover": {
+ backgroundColor:
+ theme.vars.palette.fill.faintHover,
+ },
+ })}
+ >
+ <HugeiconsIcon
+ icon={Cancel01Icon}
+ size={16}
+ strokeWidth={1.5}
+ />
+ </IconButton>
+ )}
+ </Box>
</Stack>
{showCollectionSelector && (
- <Box sx={{ px: 2, pt: 1.5, pb: 2, flexShrink: 0 }}>
+ <Box sx={{ px: "12px", pb: "12px" }}>
<CollectionNameSelector
collections={collections}
availableNames={availableCollectionNames}
@@ -601,32 +601,36 @@ const UploadItemCard = React.memo(function UploadItemCard({
/>
</Box>
)}
- <Box sx={{ mt: "auto", height: 4, flexShrink: 0 }}>
- <LinearProgress
- variant="determinate"
- value={
- isUploading
- ? uploadProgressValue(uploadProgress, uploadCap)
- : isDone
- ? 100
- : 0
- }
- sx={(theme) => ({
- height: 4,
- borderRadius: 0,
- opacity: isUploading || isDone ? 1 : 0,
- "& .MuiLinearProgress-bar": {
- transition:
- uploadProgress?.phase === "finalizing"
- ? theme.transitions.create("transform", {
- duration: 2200,
- easing: "ease-out",
- })
- : undefined,
- },
- })}
- />
- </Box>
+ <LinearProgress
+ variant="determinate"
+ value={
+ isUploading
+ ? uploadProgressValue(uploadProgress, uploadCap)
+ : isDone
+ ? 100
+ : 0
+ }
+ sx={(theme) => ({
+ position: "absolute",
+ left: 0,
+ right: 0,
+ bottom: 0,
+ height: 3,
+ borderRadius: 0,
+ opacity: isUploading || isDone ? 1 : 0,
+ backgroundColor: "rgba(16 113 255 / 0.12)",
+ "& .MuiLinearProgress-bar": {
+ backgroundColor: theme.vars.palette.accent.main,
+ transition:
+ uploadProgress?.phase === "finalizing"
+ ? theme.transitions.create("transform", {
+ duration: 2200,
+ easing: "ease-out",
+ })
+ : undefined,
+ },
+ })}
+ />
</Stack>
);
}, areUploadItemCardPropsEqual);
@@ -737,59 +741,13 @@ const CollectionNameSelector: React.FC<{
onCreateClick={() => setCreateOpen((open) => !open)}
/>
{createOpen && (
- <Stack sx={{ gap: 1, mt: 1.25 }}>
- <Stack
- direction="row"
- sx={{ gap: 1, alignItems: "center" }}
- >
- <TextField
- size="small"
- fullWidth
- autoFocus
- placeholder={t("enterCollectionName")}
- sx={{
- "& .MuiInputBase-root": {
- height: 44,
- borderRadius: "14px",
- },
- "& .MuiInputBase-input": { pt: 1, pb: 0.5 },
- }}
- value={createName}
- onChange={(event) =>
- setCreateName(event.target.value)
- }
- onKeyDown={(event) => {
- if (event.key === "Escape") {
- event.preventDefault();
- event.stopPropagation();
- setCreateOpen(false);
- return;
- }
- if (event.key === "Enter") {
- event.preventDefault();
- handleAddCollectionName();
- }
- }}
- disabled={disabled}
- />
- <LoadingButton
- color="accent"
- disabled={!createName.trim() || disabled}
- aria-label={t("create")}
- onClick={handleAddCollectionName}
- sx={{
- minWidth: 0,
- width: 44,
- height: 44,
- p: 0,
- borderRadius: "14px",
- flexShrink: 0,
- }}
- >
- <CheckRoundedIcon />
- </LoadingButton>
- </Stack>
- </Stack>
+ <CreateCollectionRow
+ value={createName}
+ onChange={setCreateName}
+ onSubmit={handleAddCollectionName}
+ onCancel={() => setCreateOpen(false)}
+ disabled={disabled}
+ />
)}
</Box>
);
diff --git a/web/apps/locker/src/components/createItemDialog/ItemFormFields.tsx b/web/apps/locker/src/components/createItemDialog/ItemFormFields.tsx
index 41a5577f93..decd13ed93 100644
--- a/web/apps/locker/src/components/createItemDialog/ItemFormFields.tsx
+++ b/web/apps/locker/src/components/createItemDialog/ItemFormFields.tsx
@@ -1,6 +1,7 @@
import { CollectionChipRow } from "@/components/createItemDialog/CollectionChipRow";
+import { lockerFieldSx } from "@/components/createItemDialog/create-item-dialog-styles";
+import { CreateCollectionRow } from "@/components/createItemDialog/CreateCollectionRow";
import type { LockerCollection, LockerItemType } from "@/types";
-import CheckRoundedIcon from "@mui/icons-material/CheckRounded";
import VisibilityIcon from "@mui/icons-material/Visibility";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
import {
@@ -10,10 +11,69 @@ import {
Stack,
TextField,
Typography,
+ type TextFieldProps,
} from "@mui/material";
-import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import { t } from "i18next";
-import React, { useCallback, useMemo, useState } from "react";
+import React, { useCallback, useId, useMemo, useState } from "react";
+
+type FormFieldProps = Omit<TextFieldProps, "label"> & {
+ label: string;
+ multilineMinHeight?: number;
+};
+
+function FormField({
+ label,
+ required,
+ multiline,
+ multilineMinHeight,
+ ...rest
+}: FormFieldProps) {
+ const id = useId();
+
+ return (
+ <Stack sx={{ gap: "8px" }}>
+ <Typography
+ variant="small"
+ component="label"
+ htmlFor={id}
+ sx={{
+ fontWeight: 500,
+ lineHeight: "20px",
+ display: "flex",
+ gap: "2px",
+ color: "text.base",
+ }}
+ >
+ {label}
+ {required && (
+ <Box
+ component="span"
+ aria-hidden
+ sx={{ color: "critical.main", fontWeight: 600 }}
+ >
+ *
+ </Box>
+ )}
+ </Typography>
+ <TextField
+ {...rest}
+ id={id}
+ required={required}
+ multiline={multiline}
+ hiddenLabel
+ fullWidth
+ variant="outlined"
+ margin="none"
+ sx={(theme) =>
+ lockerFieldSx(theme, {
+ multiline,
+ minHeight: multilineMinHeight,
+ })
+ }
+ />
+ </Stack>
+ );
+}
export const ItemFormFields: React.FC<{
type: LockerItemType;
@@ -25,26 +85,25 @@ export const ItemFormFields: React.FC<{
switch (type) {
case "note":
return (
- <Stack sx={{ gap: 2 }}>
- <TextField
+ <Stack sx={{ gap: "24px" }}>
+ <FormField
label={t("noteName")}
value={data.title ?? ""}
onChange={(event) =>
onChange("title", event.target.value)
}
- fullWidth
required
autoFocus
/>
- <TextField
+ <FormField
label={t("noteContent")}
value={data.content ?? ""}
onChange={(event) =>
onChange("content", event.target.value)
}
- fullWidth
required
multiline
+ multilineMinHeight={152}
minRows={4}
maxRows={10}
/>
@@ -52,33 +111,30 @@ export const ItemFormFields: React.FC<{
);
case "accountCredential":
return (
- <Stack sx={{ gap: 2 }}>
- <TextField
+ <Stack sx={{ gap: "24px" }}>
+ <FormField
label={t("credentialName")}
value={data.name ?? ""}
onChange={(event) =>
onChange("name", event.target.value)
}
- fullWidth
required
autoFocus
/>
- <TextField
+ <FormField
label={t("username")}
value={data.username ?? ""}
onChange={(event) =>
onChange("username", event.target.value)
}
- fullWidth
required
/>
- <TextField
+ <FormField
label={t("password")}
value={data.password ?? ""}
onChange={(event) =>
onChange("password", event.target.value)
}
- fullWidth
required
type={showPassword ? "text" : "password"}
slotProps={{
@@ -89,6 +145,7 @@ export const ItemFormFields: React.FC<{
onClick={onTogglePassword}
edge="end"
size="small"
+ sx={{ color: "text.faint", p: 0 }}
>
{showPassword ? (
<VisibilityOffIcon />
@@ -101,14 +158,14 @@ export const ItemFormFields: React.FC<{
},
}}
/>
- <TextField
+ <FormField
label={t("credentialNotes")}
value={data.notes ?? ""}
onChange={(event) =>
onChange("notes", event.target.value)
}
- fullWidth
multiline
+ multilineMinHeight={92}
minRows={2}
maxRows={5}
/>
@@ -116,34 +173,32 @@ export const ItemFormFields: React.FC<{
);
case "physicalRecord":
return (
- <Stack sx={{ gap: 2 }}>
- <TextField
+ <Stack sx={{ gap: "24px" }}>
+ <FormField
label={t("recordName")}
value={data.name ?? ""}
onChange={(event) =>
onChange("name", event.target.value)
}
- fullWidth
required
autoFocus
/>
- <TextField
+ <FormField
label={t("recordLocation")}
value={data.location ?? ""}
onChange={(event) =>
onChange("location", event.target.value)
}
- fullWidth
required
/>
- <TextField
+ <FormField
label={t("recordNotes")}
value={data.notes ?? ""}
onChange={(event) =>
onChange("notes", event.target.value)
}
- fullWidth
multiline
+ multilineMinHeight={92}
minRows={2}
maxRows={5}
/>
@@ -151,34 +206,32 @@ export const ItemFormFields: React.FC<{
);
case "emergencyContact":
return (
- <Stack sx={{ gap: 2 }}>
- <TextField
+ <Stack sx={{ gap: "24px" }}>
+ <FormField
label={t("contactName")}
value={data.name ?? ""}
onChange={(event) =>
onChange("name", event.target.value)
}
- fullWidth
required
autoFocus
/>
- <TextField
+ <FormField
label={t("contactDetails")}
value={data.contactDetails ?? ""}
onChange={(event) =>
onChange("contactDetails", event.target.value)
}
- fullWidth
required
/>
- <TextField
+ <FormField
label={t("contactNotes")}
value={data.notes ?? ""}
onChange={(event) =>
onChange("notes", event.target.value)
}
- fullWidth
multiline
+ multilineMinHeight={92}
minRows={2}
maxRows={5}
/>
@@ -186,14 +239,13 @@ export const ItemFormFields: React.FC<{
);
case "file":
return (
- <Stack sx={{ gap: 2 }}>
- <TextField
+ <Stack sx={{ gap: "24px" }}>
+ <FormField
label={t("fileTitle")}
value={data.name ?? ""}
onChange={(event) =>
onChange("name", event.target.value)
}
- fullWidth
required
autoFocus
/>
@@ -303,60 +355,20 @@ export const CollectionSelector: React.FC<{
/>
{createOpen && onCreateCollection && (
- <Stack sx={{ gap: 1, mt: 1.5 }}>
- <Stack
- direction="row"
- sx={{ gap: 1, alignItems: "center" }}
- >
- <TextField
- size="small"
- fullWidth
- autoFocus
- placeholder={t("enterCollectionName")}
- sx={{
- "& .MuiInputBase-root": {
- height: 48,
- borderRadius: "14px",
- },
- "& .MuiInputBase-input": { pt: 1, pb: 0.5 },
- }}
- value={createName}
- onChange={(event) => {
- setCreateName(event.target.value);
- setCreateError(null);
- }}
- onKeyDown={(event) => {
- if (event.key === "Escape") {
- event.preventDefault();
- event.stopPropagation();
- setCreateOpen(false);
- setCreateError(null);
- return;
- }
- if (event.key === "Enter") {
- event.preventDefault();
- void handleCreateCollection();
- }
- }}
- />
- <LoadingButton
- color="accent"
- loading={creating}
- disabled={!createName.trim()}
- aria-label={t("create")}
- onClick={() => void handleCreateCollection()}
- sx={{
- minWidth: 0,
- width: 48,
- height: 48,
- p: 0,
- borderRadius: "14px",
- flexShrink: 0,
- }}
- >
- <CheckRoundedIcon />
- </LoadingButton>
- </Stack>
+ <Stack sx={{ gap: "8px", mt: 0 }}>
+ <CreateCollectionRow
+ value={createName}
+ onChange={(v) => {
+ setCreateName(v);
+ setCreateError(null);
+ }}
+ onSubmit={() => void handleCreateCollection()}
+ onCancel={() => {
+ setCreateOpen(false);
+ setCreateError(null);
+ }}
+ loading={creating}
+ />
{createError && (
<Typography
variant="small"
diff --git a/web/apps/locker/src/components/createItemDialog/create-item-dialog-styles.ts b/web/apps/locker/src/components/createItemDialog/create-item-dialog-styles.ts
new file mode 100644
index 0000000000..f4a9ea19b3
--- /dev/null
+++ b/web/apps/locker/src/components/createItemDialog/create-item-dialog-styles.ts
@@ -0,0 +1,88 @@
+import type { Theme } from "@mui/material/styles";
+
+export const lockerScrollAreaSx = (theme: Theme) => ({
+ overflowY: "auto",
+ marginRight: "-14px",
+ paddingRight: "14px",
+ scrollbarWidth: "thin",
+ scrollbarColor: `${theme.vars.palette.fill.muted} transparent`,
+ "&::-webkit-scrollbar": { width: 6 },
+ "&::-webkit-scrollbar-track": { background: "transparent" },
+ "&::-webkit-scrollbar-thumb": {
+ borderRadius: "999px",
+ backgroundColor: theme.vars.palette.fill.muted,
+ },
+ "&::-webkit-scrollbar-thumb:hover": {
+ backgroundColor: theme.vars.palette.stroke.muted,
+ },
+});
+
+export const lockerFieldSx = (
+ theme: Theme,
+ {
+ multiline,
+ minHeight,
+ activeBorder,
+ }: { multiline?: boolean; minHeight?: number; activeBorder?: boolean },
+) => ({
+ "& .MuiOutlinedInput-root": {
+ backgroundColor: theme.vars.palette.background.paper,
+ color: theme.vars.palette.text.base,
+ borderRadius: "16px",
+ fontSize: 14,
+ lineHeight: "20px",
+ fontWeight: 500,
+ ...(multiline
+ ? { p: "16px", minHeight, alignItems: "flex-start" }
+ : { height: 52, px: "16px" }),
+ },
+ "& .MuiOutlinedInput-input": multiline
+ ? { p: 0 }
+ : { p: 0, height: "100%" },
+ "& .MuiOutlinedInput-notchedOutline": {
+ border: `1px solid ${activeBorder ? theme.vars.palette.stroke.muted : theme.vars.palette.stroke.fainter}`,
+ },
+ "& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline": {
+ borderColor: activeBorder
+ ? theme.vars.palette.stroke.muted
+ : theme.vars.palette.stroke.fainter,
+ },
+ "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": {
+ borderWidth: 1,
+ borderColor: theme.vars.palette.stroke.muted,
+ },
+ "& .MuiInputBase-input::placeholder": {
+ color: theme.vars.palette.text.faint,
+ opacity: 1,
+ },
+});
+
+export const lockerPrimaryButtonSx = (
+ theme: Theme,
+ { loading }: { loading: boolean },
+) => ({
+ minHeight: 52,
+ ...(loading
+ ? {}
+ : {
+ "&.Mui-disabled": {
+ backgroundColor: theme.vars.palette.fill.faintHover,
+ color: theme.vars.palette.text.faint,
+ },
+ }),
+});
+
+export const lockerHeaderIconButtonSx = (theme: Theme) => ({
+ width: 36,
+ height: 36,
+ p: 0,
+ borderRadius: "50%",
+ flexShrink: 0,
+ backgroundColor: theme.vars.palette.background.paper,
+ color: theme.vars.palette.text.base,
+ "&:hover": { backgroundColor: theme.vars.palette.fill.faintHover },
+ "&.Mui-disabled": {
+ backgroundColor: theme.vars.palette.fill.faintHover,
+ color: theme.vars.palette.text.faint,
+ },
+});
diff --git a/web/apps/locker/src/components/createItemDialog/use-create-item-dialog-state.ts b/web/apps/locker/src/components/createItemDialog/use-create-item-dialog-state.ts
index 613a6dbe3e..b31686a775 100644
--- a/web/apps/locker/src/components/createItemDialog/use-create-item-dialog-state.ts
+++ b/web/apps/locker/src/components/createItemDialog/use-create-item-dialog-state.ts
@@ -738,6 +738,7 @@ export const useCreateItemDialogState = ({
handleFileSelect,
handleSave,
handleSelectOption,
+ handleStepBackToOptions,
handleUpload,
isEditMode,
isFileMode,