update: open dialog from footer

This commit is contained in:
Daniel
2025-11-23 17:47:10 +01:00
committed by Nicolás Hatcher
parent 5288665f70
commit bab24a5207
3 changed files with 42 additions and 12 deletions

View File

@@ -1,11 +1,12 @@
import { styled, Tooltip } from "@mui/material"; import { styled, Tooltip } from "@mui/material";
import { Menu, Plus } from "lucide-react"; import { EllipsisVertical, Menu, Plus } from "lucide-react";
import { useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { IronCalcLogo } from "../../icons"; import { IronCalcLogo } from "../../icons";
import { theme } from "../../theme"; import { theme } from "../../theme";
import { NAVIGATION_HEIGHT } from "../constants"; import { NAVIGATION_HEIGHT } from "../constants";
import { StyledButton } from "../Toolbar/Toolbar"; import { StyledButton } from "../Toolbar/Toolbar";
import WorkbookSettingsDialog from "../WorkbookSettings/WorkbookSettingsDialog";
import type { WorkbookState } from "../workbookState"; import type { WorkbookState } from "../workbookState";
import SheetListMenu from "./SheetListMenu"; import SheetListMenu from "./SheetListMenu";
import SheetTab from "./SheetTab"; import SheetTab from "./SheetTab";
@@ -21,12 +22,14 @@ export interface SheetTabBarProps {
onSheetRenamed: (name: string) => void; onSheetRenamed: (name: string) => void;
onSheetDeleted: () => void; onSheetDeleted: () => void;
onHideSheet: () => void; onHideSheet: () => void;
onOpenWorkbookSettings: () => void;
} }
function SheetTabBar(props: SheetTabBarProps) { function SheetTabBar(props: SheetTabBarProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const { workbookState, onSheetSelected, sheets, selectedIndex } = props; const { workbookState, onSheetSelected, sheets, selectedIndex } = props;
const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null); const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
const [workbookSettingsOpen, setWorkbookSettingsOpen] = useState(false);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget); setAnchorEl(event.currentTarget);
@@ -95,6 +98,17 @@ function SheetTabBar(props: SheetTabBarProps) {
<IronCalcLogo /> <IronCalcLogo />
</LogoLink> </LogoLink>
</Tooltip> </Tooltip>
<Tooltip title={t("navigation.settings")}>
<StyledButton
$pressed={false}
onClick={() => {
setWorkbookSettingsOpen(true);
props.onOpenWorkbookSettings();
}}
>
<EllipsisVertical />
</StyledButton>
</Tooltip>
</RightContainer> </RightContainer>
<SheetListMenu <SheetListMenu
anchorEl={anchorEl} anchorEl={anchorEl}
@@ -107,6 +121,11 @@ function SheetTabBar(props: SheetTabBarProps) {
}} }}
selectedIndex={selectedIndex} selectedIndex={selectedIndex}
/> />
<WorkbookSettingsDialog
open={workbookSettingsOpen}
onClose={() => setWorkbookSettingsOpen(false)}
onExited={() => setWorkbookSettingsOpen(false)}
/>
</Container> </Container>
); );
} }
@@ -170,6 +189,7 @@ const RightContainer = styled("a")`
color: ${theme.palette.primary.main}; color: ${theme.palette.primary.main};
height: 100%; height: 100%;
padding: 0px 8px; padding: 0px 8px;
gap: 4px;
@media (max-width: 769px) { @media (max-width: 769px) {
display: none; display: none;
} }
@@ -178,14 +198,19 @@ const RightContainer = styled("a")`
const LogoLink = styled("div")` const LogoLink = styled("div")`
display: flex; display: flex;
align-items: center; align-items: center;
padding: 8px; padding: 0px 4px;
border-radius: 4px; border-radius: 4px;
max-height: 24px;
min-height: 24px;
cursor: pointer;
svg { svg {
height: 14px; height: 14px;
width: auto; width: auto;
} }
&:hover { &:hover {
background-color: ${theme.palette.grey["100"]}; background-color: ${theme.palette.grey["100"]};
transition: "all 0.2s";
outline: 1px solid ${theme.palette.grey["200"]};
} }
`; `;

View File

@@ -5,7 +5,6 @@ import { useTranslation } from "react-i18next";
import { theme } from "../../theme"; import { theme } from "../../theme";
type WorkbookSettingsDialogProps = { type WorkbookSettingsDialogProps = {
className?: string;
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
onExited: () => void; onExited: () => void;
@@ -19,13 +18,7 @@ const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
}; };
return ( return (
<Dialog <StyledDialog open={properties.open} onClose={properties.onClose}>
open={properties.open}
onClose={properties.onClose}
PaperProps={{
style: { minWidth: "280px" },
}}
>
<StyledDialogTitle> <StyledDialogTitle>
{t("workbook_settings.title")} {t("workbook_settings.title")}
<Cross <Cross
@@ -41,14 +34,22 @@ const WorkbookSettingsDialog = (properties: WorkbookSettingsDialogProps) => {
<X /> <X />
</Cross> </Cross>
</StyledDialogTitle> </StyledDialogTitle>
<StyledDialogContent> <StyledDialogContent>
{/* Settings content will go here */} {/* Settings content will go here */}
</StyledDialogContent> </StyledDialogContent>
</Dialog> </StyledDialog>
); );
}; };
const StyledDialog = styled(Dialog)`
& .MuiPaper-root {
max-width: 400px;
min-width: 280px;
border-radius: 8px;
padding: 0px;
}
`;
const StyledDialogTitle = styled("div")` const StyledDialogTitle = styled("div")`
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -167,5 +167,9 @@
"right_drawer": { "right_drawer": {
"close": "Close", "close": "Close",
"resize_drawer": "Resize drawer" "resize_drawer": "Resize drawer"
},
"workbook_settings": {
"title": "Workbook Settings",
"close": "Close dialog"
} }
} }