update: styling and layout

This commit is contained in:
Daniel Gonzalez Albo
2025-11-07 03:06:07 +01:00
committed by Nicolás Hatcher Andrés
parent 4217c1455b
commit e44a2e8c3e
2 changed files with 105 additions and 62 deletions

View File

@@ -1,10 +1,11 @@
import type { WorksheetProperties } from "@ironcalc/wasm"; import type { WorksheetProperties } from "@ironcalc/wasm";
import { Box, IconButton, MenuItem, TextField, styled } from "@mui/material"; import { Box, MenuItem, TextField, styled } from "@mui/material";
import { t } from "i18next"; import { t } from "i18next";
import { Check, X } from "lucide-react"; import { Check, Tag } from "lucide-react";
import { useState } from "react"; import { useState } from "react";
import type React from "react"; import type React from "react";
import { theme } from "../../../theme"; import { theme } from "../../../theme";
import { Footer, NewButton } from "./NamedRanges";
interface EditNamedRangeProps { interface EditNamedRangeProps {
worksheets: WorksheetProperties[]; worksheets: WorksheetProperties[];
@@ -31,14 +32,22 @@ const EditNamedRange: React.FC<EditNamedRangeProps> = ({
return ( return (
<Container> <Container>
<ContentArea> <ContentArea>
<HeaderBox>
<HeaderIcon>
<Tag />
</HeaderIcon>
<HeaderBoxText>{name || "New Named Range"}</HeaderBoxText>
</HeaderBox>
<StyledBox> <StyledBox>
<FieldWrapper> <FieldWrapper>
<StyledLabel htmlFor="name">Range name</StyledLabel> <StyledLabel htmlFor="name">Range name</StyledLabel>
<StyledTextField <StyledTextField
autoFocus={true}
id="name" id="name"
variant="outlined" variant="outlined"
size="small" size="small"
margin="none" margin="none"
placeholder="Enter range name"
fullWidth fullWidth
error={formulaError} error={formulaError}
value={name} value={name}
@@ -74,6 +83,9 @@ const EditNamedRange: React.FC<EditNamedRangeProps> = ({
</MenuItem> </MenuItem>
))} ))}
</StyledTextField> </StyledTextField>
<StyledHelperText>
The scope of the named range determines where it is available.
</StyledHelperText>
</FieldWrapper> </FieldWrapper>
<FieldWrapper> <FieldWrapper>
<StyledLabel htmlFor="formula">Refers to</StyledLabel> <StyledLabel htmlFor="formula">Refers to</StyledLabel>
@@ -83,6 +95,8 @@ const EditNamedRange: React.FC<EditNamedRangeProps> = ({
size="small" size="small"
margin="none" margin="none"
fullWidth fullWidth
multiline
rows={3}
error={formulaError} error={formulaError}
value={formula} value={formula}
onChange={(event) => setFormula(event.target.value)} onChange={(event) => setFormula(event.target.value)}
@@ -92,28 +106,31 @@ const EditNamedRange: React.FC<EditNamedRangeProps> = ({
onClick={(event) => event.stopPropagation()} onClick={(event) => event.stopPropagation()}
/> />
</FieldWrapper> </FieldWrapper>
<FieldWrapper></FieldWrapper>
</StyledBox> </StyledBox>
</ContentArea> </ContentArea>
<Footer> <Footer>
<IconsWrapper> <NewButton
<StyledIconButton variant="contained"
onClick={() => { color="secondary"
const error = onSave(name, scope, formula); disableElevation
if (error) { onClick={onCancel}
setFormulaError(true); >
} Cancel
}} </NewButton>
title={t("name_manager_dialog.apply")} <NewButton
> variant="contained"
<StyledCheck size={16} /> disableElevation
</StyledIconButton> startIcon={<Check size={16} />}
<StyledIconButton onClick={() => {
onClick={onCancel} const error = onSave(name, scope, formula);
title={t("name_manager_dialog.discard")} if (error) {
> setFormulaError(true);
<X size={16} /> }
</StyledIconButton> }}
</IconsWrapper> >
{t("name_manager_dialog.apply")}
</NewButton>
</Footer> </Footer>
</Container> </Container>
); );
@@ -142,6 +159,43 @@ const MenuSpanGrey = styled("span")`
color: ${theme.palette.grey[400]}; color: ${theme.palette.grey[400]};
`; `;
const HeaderBox = styled(Box)`
font-size: 14px;
font-family: "Inter";
font-weight: 600;
width: auto;
gap: 8px;
padding: 24px 12px;
color: ${theme.palette.text.primary};
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
border-bottom: 1px solid ${theme.palette.grey["200"]};
`;
const HeaderBoxText = styled("span")`
max-width: 100%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
`;
const HeaderIcon = styled(Box)`
width: 28px;
height: 28px;
border-radius: 4px;
background-color: ${theme.palette.grey["100"]};
display: flex;
align-items: center;
justify-content: center;
svg {
width: 16px;
height: 16px;
color: ${theme.palette.grey["600"]};
}
`;
const StyledBox = styled(Box)` const StyledBox = styled(Box)`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -157,7 +211,6 @@ const StyledBox = styled(Box)`
const StyledTextField = styled(TextField)(() => ({ const StyledTextField = styled(TextField)(() => ({
"& .MuiInputBase-root": { "& .MuiInputBase-root": {
height: "36px",
width: "100%", width: "100%",
margin: 0, margin: 0,
fontFamily: "Inter", fontFamily: "Inter",
@@ -166,38 +219,11 @@ const StyledTextField = styled(TextField)(() => ({
"& .MuiInputBase-input": { "& .MuiInputBase-input": {
padding: "8px", padding: "8px",
}, },
})); "& .MuiInputBase-inputMultiline": {
padding: "0px",
const StyledIconButton = styled(IconButton)(({ theme }) => ({
color: theme.palette.error.main,
borderRadius: "8px",
"&:hover": {
backgroundColor: theme.palette.grey["50"],
},
"&.Mui-disabled": {
opacity: 0.6,
color: theme.palette.error.light,
}, },
})); }));
const StyledCheck = styled(Check)(({ theme }) => ({
color: theme.palette.success.main,
}));
const Footer = styled("div")`
padding: 8px;
display: flex;
align-items: center;
justify-content: flex-end;
font-size: 12px;
color: ${theme.palette.grey["600"]};
border-top: 1px solid ${theme.palette.grey["300"]};
`;
const IconsWrapper = styled(Box)({
display: "flex",
});
const FieldWrapper = styled(Box)` const FieldWrapper = styled(Box)`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -213,4 +239,12 @@ const StyledLabel = styled("label")`
display: block; display: block;
`; `;
const StyledHelperText = styled("p")`
font-size: 10px;
font-family: "Inter";
color: ${theme.palette.grey[400]};
margin: 0;
line-height: 1.25;
`;
export default EditNamedRange; export default EditNamedRange;

View File

@@ -1,7 +1,7 @@
import type { DefinedName, WorksheetProperties } from "@ironcalc/wasm"; import type { DefinedName, WorksheetProperties } from "@ironcalc/wasm";
import { Button, Tooltip, styled } from "@mui/material"; import { Button, Tooltip, styled } from "@mui/material";
import { t } from "i18next"; import { t } from "i18next";
import { BookOpen, ChevronRight, Plus } from "lucide-react"; import { BookOpen, Plus } from "lucide-react";
import { useState } from "react"; import { useState } from "react";
import { theme } from "../../../theme"; import { theme } from "../../../theme";
import EditNamedRange from "./EditNamedRange"; import EditNamedRange from "./EditNamedRange";
@@ -140,9 +140,9 @@ const NamedRanges: React.FC<NamedRangesProps> = ({
tabIndex={0} tabIndex={0}
> >
<ListItemText> <ListItemText>
<ScopeText>{scopeName}</ScopeText>
<ChevronRightStyled />
<NameText>{definedName.name}</NameText> <NameText>{definedName.name}</NameText>
<ScopeText>{scopeName}</ScopeText>
<FormulaText>{definedName.formula}</FormulaText>
</ListItemText> </ListItemText>
</ListItem> </ListItem>
); );
@@ -218,8 +218,9 @@ const ListItemText = styled("div")({
fontFamily: theme.typography.fontFamily, fontFamily: theme.typography.fontFamily,
flex: 1, flex: 1,
display: "flex", display: "flex",
alignItems: "center", flexDirection: "column",
gap: "4px", alignItems: "flex-start",
gap: "2px",
}); });
const ScopeText = styled("span")({ const ScopeText = styled("span")({
@@ -227,18 +228,18 @@ const ScopeText = styled("span")({
color: theme.palette.common.black, color: theme.palette.common.black,
}); });
const ChevronRightStyled = styled(ChevronRight)({ const FormulaText = styled("span")({
width: "12px", fontSize: "12px",
height: "12px", color: theme.palette.grey[600],
color: theme.palette.grey[500],
}); });
const NameText = styled("span")({ const NameText = styled("span")({
fontSize: "12px", fontSize: "12px",
color: theme.palette.common.black, color: theme.palette.common.black,
fontWeight: 600,
}); });
const Footer = styled("div")` export const Footer = styled("div")`
padding: 8px; padding: 8px;
display: flex; display: flex;
align-items: center; align-items: center;
@@ -246,6 +247,7 @@ const Footer = styled("div")`
font-size: 12px; font-size: 12px;
color: ${theme.palette.grey["600"]}; color: ${theme.palette.grey["600"]};
border-top: 1px solid ${theme.palette.grey["300"]}; border-top: 1px solid ${theme.palette.grey["300"]};
gap: 8px;
`; `;
const HelpLink = styled("a")` const HelpLink = styled("a")`
@@ -267,10 +269,17 @@ const HelpLink = styled("a")`
} }
`; `;
const NewButton = styled(Button)` export const NewButton = styled(Button)`
text-transform: none; text-transform: none;
min-width: fit-content; min-width: fit-content;
font-size: 12px; font-size: 12px;
&.MuiButton-colorSecondary {
background-color: ${theme.palette.grey[200]};
color: ${theme.palette.grey[700]};
&:hover {
background-color: ${theme.palette.grey[300]};
}
}
`; `;
export default NamedRanges; export default NamedRanges;