Merge pull request #186 from ironcalc/fix/dani-rename-sheet-dialog
FIX: Makes styling in Rename Sheet Dialog consistent with rest of dia…
This commit is contained in:
@@ -1,17 +1,10 @@
|
|||||||
import {
|
import { Dialog, TextField, styled } from "@mui/material";
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
DialogActions,
|
|
||||||
DialogContent,
|
|
||||||
DialogTitle,
|
|
||||||
TextField,
|
|
||||||
styled,
|
|
||||||
} from "@mui/material";
|
|
||||||
import Menu from "@mui/material/Menu";
|
import Menu from "@mui/material/Menu";
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import { Check } from "lucide-react";
|
import { Check } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { theme } from "../../theme";
|
||||||
import type { SheetOptions } from "./types";
|
import type { SheetOptions } from "./types";
|
||||||
|
|
||||||
function isWhiteColor(color: string): boolean {
|
function isWhiteColor(color: string): boolean {
|
||||||
@@ -28,16 +21,48 @@ interface SheetRenameDialogProps {
|
|||||||
export const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
export const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [name, setName] = useState(properties.defaultName);
|
const [name, setName] = useState(properties.defaultName);
|
||||||
|
const handleClose = () => {
|
||||||
|
properties.close();
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Dialog open={properties.isOpen} onClose={properties.close}>
|
<Dialog open={properties.isOpen} onClose={properties.close}>
|
||||||
<DialogTitle>{t("sheet_rename.title")}</DialogTitle>
|
<StyledDialogTitle>
|
||||||
<DialogContent dividers>
|
{t("sheet_rename.title")}
|
||||||
<TextField
|
<Cross onClick={handleClose} onKeyDown={() => {}}>
|
||||||
|
<svg
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<title>Close</title>
|
||||||
|
<path
|
||||||
|
d="M12 4.5L4 12.5"
|
||||||
|
stroke="#333333"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M4 4.5L12 12.5"
|
||||||
|
stroke="#333333"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</Cross>
|
||||||
|
</StyledDialogTitle>
|
||||||
|
<StyledDialogContent>
|
||||||
|
<StyledTextField
|
||||||
|
autoFocus
|
||||||
defaultValue={properties.defaultName}
|
defaultValue={properties.defaultName}
|
||||||
label={t("sheet_rename.label")}
|
|
||||||
onClick={(event) => event.stopPropagation()}
|
onClick={(event) => event.stopPropagation()}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
properties.onNameChanged(name);
|
||||||
|
properties.close();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
setName(event.target.value);
|
setName(event.target.value);
|
||||||
@@ -45,16 +70,16 @@ export const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
|||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
onPaste={(event) => event.stopPropagation()}
|
onPaste={(event) => event.stopPropagation()}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</StyledDialogContent>
|
||||||
<DialogActions>
|
<DialogFooter>
|
||||||
<Button
|
<StyledButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
properties.onNameChanged(name);
|
properties.onNameChanged(name);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("sheet_rename.rename")}
|
{t("sheet_rename.rename")}
|
||||||
</Button>
|
</StyledButton>
|
||||||
</DialogActions>
|
</DialogFooter>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -147,4 +172,78 @@ const ItemName = styled("div")`
|
|||||||
color: #333;
|
color: #333;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StyledDialogTitle = styled("div")`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 44px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: Inter;
|
||||||
|
padding: 0px 12px;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-bottom: 1px solid ${theme.palette.grey["300"]};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Cross = styled("div")`
|
||||||
|
&:hover {
|
||||||
|
background-color: ${theme.palette.grey["100"]};
|
||||||
|
}
|
||||||
|
display: flex;
|
||||||
|
border-radius: 4px;
|
||||||
|
height: 24px;
|
||||||
|
width: 24px;
|
||||||
|
cursor: pointer;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledDialogContent = styled("div")`
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 12px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledTextField = styled(TextField)`
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
& .MuiInputBase-input {
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid ${theme.palette.grey["300"]};
|
||||||
|
border-radius: 4px;
|
||||||
|
color: ${theme.palette.common.black};
|
||||||
|
background-color: ${theme.palette.common.white};
|
||||||
|
}
|
||||||
|
&:hover .MuiInputBase-input {
|
||||||
|
border: 1px solid ${theme.palette.grey["500"]};
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const DialogFooter = styled("div")`
|
||||||
|
color: #757575;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
border-top: 1px solid ${theme.palette.grey["300"]};
|
||||||
|
font-family: Inter;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding: 12px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledButton = styled("div")`
|
||||||
|
cursor: pointer;
|
||||||
|
color: #ffffff;
|
||||||
|
background: #f2994a;
|
||||||
|
padding: 0px 10px;
|
||||||
|
height: 36px;
|
||||||
|
line-height: 36px;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-family: "Inter";
|
||||||
|
font-size: 14px;
|
||||||
|
&:hover {
|
||||||
|
background: #d68742;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export default SheetListMenu;
|
export default SheetListMenu;
|
||||||
|
|||||||
Reference in New Issue
Block a user