Skip to content

Commit

Permalink
fix!: Add overlay for Meganav
Browse files Browse the repository at this point in the history
  • Loading branch information
aralovelace committed Feb 12, 2025
1 parent b9f7c7c commit 809e7fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
19 changes: 11 additions & 8 deletions src/core/Flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
NavigationMenuLink,
} from "@radix-ui/react-navigation-menu";
import cn from "./utils/cn";
import { componentMaxHeight, HEADER_HEIGHT } from "./utils/heights";

/**
* Props for the Flyout component.
Expand Down Expand Up @@ -65,13 +66,15 @@ const DEFAULT_VIEWPORT_STYLING =
const PANEL_ANIMATION =
"data-[motion=from-end]:animate-enter-from-right data-[motion=from-start]:animate-enter-from-left data-[motion=to-end]:animate-exit-to-right data-[motion=to-start]:animate-exit-to-left";

export const FlyOverlay = ({ className }: { className: string }) => {
return (
<div
className={cn("absolute left-0 right-0 h-screen w-full", className)}
></div>
);
};
export const FlyOverlay = ({ className }: { className: string }) => (
<div
className={cn(
"absolute left-0 right-0 h-screen w-full opacity-0 animate-[fadeInTenPercent_200ms_ease]",
className,
)}
style={{ height: componentMaxHeight(HEADER_HEIGHT) }}
></div>
);

const Flyout = ({
menuItems,
Expand All @@ -85,7 +88,7 @@ const Flyout = ({
return (
<NavigationMenu
className={cn(className, "flex w-full")}
onValueChange={(val) => (val ? setIsOpen(true) : setIsOpen(false))}
onValueChange={(val) => setIsOpen(!!val)}
>
<NavigationMenuList className="flex list-none center">
{menuItems.map(({ label, content, link, panelStyling }) =>
Expand Down
21 changes: 9 additions & 12 deletions src/core/Flyout/Flyout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,18 @@ const menuItems = [
const FlyoutStory = () => {
const [isOpen, setIsOpen] = useState<boolean>(false);

const flyOutDefaultArgs = {
menuItems: menuItems,
className: "justify-center relative z-40 ui-standard-container",
flyOutClassName: "flex w-full justify-center",
viewPortClassName:
"ui-shadow-lg-medium border border-neutral-000 dark:border-neutral-1300 rounded-2xl mt-8",
hasAnimation: true,
setIsOpen: setIsOpen,
};

return (
<div>
<Flyout {...flyOutDefaultArgs} />
<Flyout
menuItems={menuItems}
className="justify-center relative z-40 ui-standard-container"
flyOutClassName="flex w-full justify-center"
viewPortClassName="ui-shadow-lg-medium border border-neutral-000 dark:border-neutral-1300 rounded-2xl mt-8"
hasAnimation={true}
setIsOpen={setIsOpen}
/>
{isOpen && (
<FlyOverlay className="top-[52px] bg-neutral-1300 opacity-10 z-20" />
<FlyOverlay className="bg-neutral-1300 opacity-10 z-20 h-screen" />
)}
</div>
);
Expand Down

0 comments on commit 809e7fa

Please sign in to comment.