diff --git a/webapp/IronCalc/src/components/RightDrawer/NamedRanges/NamedRanges.tsx b/webapp/IronCalc/src/components/RightDrawer/NamedRanges/NamedRanges.tsx new file mode 100644 index 0000000..c9dfff7 --- /dev/null +++ b/webapp/IronCalc/src/components/RightDrawer/NamedRanges/NamedRanges.tsx @@ -0,0 +1,66 @@ +import React from 'react'; +import Button from "@mui/material/Button"; +import { styled } from "@mui/material/styles"; +import { theme } from "../../../theme"; + +interface NamedRangesProps { + title?: string; + // Add props as needed for your use case +} + +const NamedRanges: React.FC = ({ title = "Named Ranges" }) => { + return ( + + +

{title}

+

This is the Named Ranges component.

+

You can customize this content based on your specific needs.

+
+ +
+ + Save changes + +
+
+ ); +}; + +const Container = styled("div")({ + padding: "16px", + height: "100%", + display: "flex", + flexDirection: "column", +}); + +const Content = styled("div")({ + flex: 1, + color: theme.palette.grey[700], + lineHeight: "1.5", + + "& p": { + margin: "0 0 12px 0", + }, +}); + +const Divider = styled("div")({ + height: "1px", + width: "100%", + backgroundColor: theme.palette.grey[300], + margin: "0", +}); + +const Footer = styled("div")({ + height: "40px", + display: "flex", + alignItems: "center", + justifyContent: "flex-end", + padding: "0 8px", + flexShrink: 0, +}); + +const FooterButton = styled(Button)({ + width: "100%", +}); + +export default NamedRanges; diff --git a/webapp/IronCalc/src/components/RightDrawer/RightDrawer.tsx b/webapp/IronCalc/src/components/RightDrawer/RightDrawer.tsx new file mode 100644 index 0000000..f968706 --- /dev/null +++ b/webapp/IronCalc/src/components/RightDrawer/RightDrawer.tsx @@ -0,0 +1,157 @@ +import Breadcrumbs from "@mui/material/Breadcrumbs"; +import Button from "@mui/material/Button"; +import Link from "@mui/material/Link"; +import Tooltip from "@mui/material/Tooltip"; +import { styled } from "@mui/material/styles"; +import { t } from "i18next"; +import { X } from "lucide-react"; +import type { ReactNode } from "react"; +import { theme } from "../../theme"; +import { TOOLBAR_HEIGHT } from "../constants"; +import NamedRanges from "./NamedRanges/NamedRanges"; + +const DEFAULT_DRAWER_WIDTH = 300; + +interface RightDrawerProps { + isOpen: boolean; + onClose: () => void; + width?: number; + children?: ReactNode; + showCloseButton?: boolean; + backgroundColor?: string; + title?: string; +} + +const RightDrawer = ({ + isOpen, + onClose, + width = DEFAULT_DRAWER_WIDTH, + children, + showCloseButton = true, + title = "Right Drawer", +}: RightDrawerProps) => { + if (!isOpen) return null; + + return ( + + {showCloseButton && ( +
+ + + {title} + Catalog + + + + { + if (e.key === "Enter" || e.key === " ") { + onClose(); + } + }} + aria-label="Close drawer" + tabIndex={0} + > + + + +
+ )} + {children} + + + + +
+ ); +}; + +type DrawerContainerProps = { + $drawerWidth: number; +}; +const DrawerContainer = styled("div")( + ({ $drawerWidth }) => ({ + position: "absolute", + overflow: "hidden", + backgroundColor: theme.palette.common.white, + right: 0, + top: `${TOOLBAR_HEIGHT + 1}px`, + bottom: 0, + borderLeft: `1px solid ${theme.palette.grey[300]}`, + width: `${$drawerWidth}px`, + display: "flex", + flexDirection: "column", + }), +); + +const Header = styled("div")({ + height: "40px", + display: "flex", + alignItems: "center", + justifyContent: "flex-end", + padding: "0 8px", +}); + +const HeaderTitle = styled("div")({ + width: "100%", +}); + +const HeaderBreadcrumbs = styled(Breadcrumbs)({ + fontSize: "12px", + marginRight: "8px", + width: "100%", +}); + +const HeaderBreadcrumbLink = styled(Link)({ + color: theme.palette.grey[900], + textDecoration: "none", +}); + +const CloseButton = styled("div")` + &:hover { + background-color: ${theme.palette.grey["50"]}; + } + display: flex; + border-radius: 4px; + height: 24px; + width: 24px; + cursor: pointer; + align-items: center; + justify-content: center; + svg { + width: 16px; + height: 16px; + stroke-width: 1.5; + } + `; + +const Divider = styled("div")({ + height: "1px", + width: "100%", + backgroundColor: theme.palette.grey[300], + margin: "0", +}); + +const DrawerContent = styled("div")({ + flex: 1, + overflow: "auto", +}); + + +export default RightDrawer; +export { DEFAULT_DRAWER_WIDTH }; diff --git a/webapp/IronCalc/src/components/Workbook/Workbook.tsx b/webapp/IronCalc/src/components/Workbook/Workbook.tsx index 937c628..0d1c226 100644 --- a/webapp/IronCalc/src/components/Workbook/Workbook.tsx +++ b/webapp/IronCalc/src/components/Workbook/Workbook.tsx @@ -7,6 +7,7 @@ import type { import { styled } from "@mui/material/styles"; import { useCallback, useEffect, useRef, useState } from "react"; import FormulaBar from "../FormulaBar/FormulaBar"; +import RightDrawer, { DEFAULT_DRAWER_WIDTH } from "../RightDrawer/RightDrawer"; import SheetTabBar from "../SheetTabBar"; import Toolbar from "../Toolbar/Toolbar"; import Worksheet from "../Worksheet/Worksheet"; @@ -699,7 +700,7 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => { setDrawerOpen(true); }} /> - + { }} /> - - setDrawerOpen(false)} - onKeyDown={(e) => { - if (e.key === "Enter" || e.key === " ") { - setDrawerOpen(false); - } - }} - aria-label="Close drawer" - > - x - - + setDrawerOpen(false)} /> ); }; -const DRAWER_WIDTH = 300; - type WorksheetAreaLeftProps = { $drawerWidth: number }; const WorksheetAreaLeft = styled("div")( ({ $drawerWidth }) => ({ @@ -796,18 +783,6 @@ const WorksheetAreaLeft = styled("div")( }), ); -const WorksheetAreaRight = styled("div")( - ({ $drawerWidth }) => ({ - position: "absolute", - overflow: "hidden", - backgroundColor: "red", - right: 0, - top: `${TOOLBAR_HEIGHT + 1}px`, - bottom: 0, - width: `${$drawerWidth}px`, - }), -); - const Container = styled("div")` display: flex; flex-direction: column; diff --git a/webapp/IronCalc/src/locale/en_us.json b/webapp/IronCalc/src/locale/en_us.json index be66295..5e6f5cc 100644 --- a/webapp/IronCalc/src/locale/en_us.json +++ b/webapp/IronCalc/src/locale/en_us.json @@ -142,5 +142,8 @@ "default": "Default color", "no_fill": "No fill", "custom": "Custom" + }, + "right_drawer": { + "close": "Close" } }