From 6a38c2d0aafa6b9fc899d34d4464621a6a7a4518 Mon Sep 17 00:00:00 2001 From: coderwelsch Date: Mon, 5 Aug 2024 13:48:42 +0200 Subject: [PATCH] feat: added new popover-menu component --- .../popover-menu/popover-menu-button.tsx | 21 +++++++++ .../popover-menu/popover-menu-context.tsx | 25 ++++++++++ .../popover-menu/popover-menu-overlay.tsx | 6 +++ .../popover-menu/popover-menu-panel.tsx | 47 +++++++++++++++++++ .../popover-menu/popover-menu.stories.tsx | 35 ++++++++++++++ src/components/popover-menu/popover-menu.tsx | 42 +++++++++++++++++ 6 files changed, 176 insertions(+) create mode 100644 src/components/popover-menu/popover-menu-button.tsx create mode 100644 src/components/popover-menu/popover-menu-context.tsx create mode 100644 src/components/popover-menu/popover-menu-overlay.tsx create mode 100644 src/components/popover-menu/popover-menu-panel.tsx create mode 100644 src/components/popover-menu/popover-menu.stories.tsx create mode 100644 src/components/popover-menu/popover-menu.tsx diff --git a/src/components/popover-menu/popover-menu-button.tsx b/src/components/popover-menu/popover-menu-button.tsx new file mode 100644 index 00000000..c6a2d2dc --- /dev/null +++ b/src/components/popover-menu/popover-menu-button.tsx @@ -0,0 +1,21 @@ +import { PopoverButton as HeadlessUiPopoverButton } from "@headlessui/react"; +import React from "react"; +import { usePopoverMenuContext } from "./popover-menu-context"; +import { Button, ButtonProps } from "../button/button"; + +export interface NavigationPopoverButtonProps extends ButtonProps { + children: React.ReactNode; + onClick?: () => void; +} + +export const PopoverMenuButton = ({ onClick, ...restProps }: NavigationPopoverButtonProps) => { + const { + popoverButton: { setReferenceElement }, + } = usePopoverMenuContext(); + + return ( + el && setReferenceElement(el)} onClick={onClick}> +