From 8652538ba0abe1381bf47f3c586e751f4add4ecd Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Mon, 22 Jul 2024 08:59:25 +0200 Subject: [PATCH] fix: Menu alignment --- app/components/arrow-menu.tsx | 55 ++++++++++++++----------- app/components/chart-selection-tabs.tsx | 6 +-- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/app/components/arrow-menu.tsx b/app/components/arrow-menu.tsx index c4bfd78f0..6db8cc970 100644 --- a/app/components/arrow-menu.tsx +++ b/app/components/arrow-menu.tsx @@ -1,41 +1,48 @@ import { Menu, paperClasses, styled } from "@mui/material"; -export const ArrowMenuTopBottom = styled(Menu)(({ theme }) => ({ +const commonBeforeStyles: Partial = { + content: '" "', + display: "block", + background: "white", + width: "10px", + height: "10px", + transform: "rotate(45deg)", + position: "absolute", + margin: "auto", +}; + +export const ArrowMenuTopCenter = styled(Menu)({ + [`& .${paperClasses.root}`]: { + overflow: "visible", + "&:before": { + ...commonBeforeStyles, + top: -5, + left: "0%", + right: 0, + }, + }, +}); + +export const ArrowMenuTopBottom = styled(Menu)({ [`& .${paperClasses.root}`]: { - overflowY: "visible", - overflowX: "visible", + overflow: "visible", "&:before": { - content: '" "', - display: "block", - background: theme.palette.background.paper, - width: 10, - height: 10, - transform: "rotate(45deg)", - position: "absolute", - margin: "auto", + ...commonBeforeStyles, top: -5, left: "calc(100% - 40px)", right: 0, }, }, -})); +}); -export const ArrowMenuBottomTop = styled(Menu)(({ theme }) => ({ +export const ArrowMenuBottomTop = styled(Menu)({ [`& .${paperClasses.root}`]: { - overflowY: "visible", - overflowX: "visible", + overflow: "visible", "&:before": { - content: '" "', - display: "block", - background: theme.palette.background.paper, - width: 10, - height: 10, - transform: "rotate(45deg)", - position: "absolute", - margin: "auto", + ...commonBeforeStyles, bottom: -5, left: 0, right: "calc(100% - 40px)", }, }, -})); +}); diff --git a/app/components/chart-selection-tabs.tsx b/app/components/chart-selection-tabs.tsx index dea356136..c2013425d 100644 --- a/app/components/chart-selection-tabs.tsx +++ b/app/components/chart-selection-tabs.tsx @@ -25,7 +25,7 @@ import { useClient } from "urql"; import { useDebounce } from "use-debounce"; import { extractChartConfigComponentIris } from "@/charts/shared/chart-helpers"; -import { ArrowMenuTopBottom } from "@/components/arrow-menu"; +import { ArrowMenuTopCenter } from "@/components/arrow-menu"; import { DuplicateChartMenuActionItem } from "@/components/chart-shared"; import Flex from "@/components/flex"; import { MenuActionItem } from "@/components/menu-action-item"; @@ -276,7 +276,7 @@ const TabsEditable = (props: TabsEditableProps) => { ) : null} {tabsState.popoverType === "edit" ? ( - { }} /> )} - + ) : null} );