Skip to content

Commit

Permalink
Merge pull request #77 from abusix/pla-911-fix-popover-overlay-overla…
Browse files Browse the repository at this point in the history
…pping

fix(NavigationPopoverOverlay): Add portal to overlay to send it to th…
  • Loading branch information
pallendes authored Dec 18, 2023
2 parents 47bba88 + 20d5fe5 commit 055f77a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/components/navigation/navigation-popover-overlay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Popover } from "@headlessui/react";
import * as React from "react";

export const NavigationPopoverOverlay = () => (
<Popover.Overlay className="fixed inset-0 z-30 translate-x-[180px] bg-modal-background" />
);
14 changes: 5 additions & 9 deletions src/components/navigation/navigation-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import React, { useState } from "react";
import { usePopper } from "react-popper";
import { NavigationPopoverButton } from "./navigation-popover-button";
import { NavigationPopoverContextProvider } from "./navigation-popover-context";
import { NavigationPopoverOverlay } from "./navigation-popover-overlay";
import { NavigationPopoverPanel } from "./navigation-popover-panel";

export interface NavigationPopoverProps {
children: React.ReactNode;
showOverlay?: boolean;
}

const NavigationPopover = ({ children, showOverlay }: NavigationPopoverProps) => {
const NavigationPopover = ({ children }: NavigationPopoverProps) => {
const [referenceElement, setReferenceElement] = useState<HTMLButtonElement>();
const [popperElement, setPopperElement] = useState<HTMLDivElement>();
const { styles, attributes } = usePopper(referenceElement, popperElement, {
placement: "right-end",
placement: "top-start",
});

const context = {
Expand All @@ -30,17 +30,13 @@ const NavigationPopover = ({ children, showOverlay }: NavigationPopoverProps) =>

return (
<NavigationPopoverContextProvider value={context}>
<Popover>
{showOverlay && (
<Popover.Overlay className="fixed inset-0 z-30 translate-x-[180px] bg-modal-background" />
)}
{children}
</Popover>
<Popover>{children}</Popover>
</NavigationPopoverContextProvider>
);
};

NavigationPopover.Button = NavigationPopoverButton;
NavigationPopover.Panel = NavigationPopoverPanel;
NavigationPopover.Overlay = NavigationPopoverOverlay;

export { NavigationPopover };
1 change: 1 addition & 0 deletions src/components/navigation/navigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const Default: Story = {
<Navigation.Popover.Button LeftIcon={HelpIcon}>
Support
</Navigation.Popover.Button>
<Navigation.Popover.Overlay />
<Navigation.Popover.Panel>
<Navigation.Popover.Panel.Item>
Documentation
Expand Down

0 comments on commit 055f77a

Please sign in to comment.