From b1a58336968bad5067cd32085425f17fb05d6e98 Mon Sep 17 00:00:00 2001 From: April Smith Date: Fri, 31 Jan 2025 14:30:19 +0000 Subject: [PATCH] fix!: Flyout for Meganav --- src/core/Flyout.tsx | 98 +++++++++++++++--------------- src/core/Flyout/Flyout.stories.tsx | 29 +++++---- tailwind.config.js | 8 +-- 3 files changed, 69 insertions(+), 66 deletions(-) diff --git a/src/core/Flyout.tsx b/src/core/Flyout.tsx index 687e39db..e7574e3a 100644 --- a/src/core/Flyout.tsx +++ b/src/core/Flyout.tsx @@ -10,10 +10,12 @@ import { } from "@radix-ui/react-navigation-menu"; import cn from "./utils/cn"; -const NavigationMenuDemo = ({ +const Flyout = ({ menuItems, - navMenuStyling, - flyOutStyling, + className, + flyOutClassName, + menuLinkClassName, + viewPortClassName, }: { menuItems: { label: string; @@ -21,64 +23,62 @@ const NavigationMenuDemo = ({ link?: string; panelStyling?: string; }[]; - navMenuStyling?: string; - flyOutStyling?: string; + className?: string; + flyOutClassName?: string; + menuLinkClassName?: string; + viewPortClassName?: string; }) => { - const menuLinkStyles = - "ui-text-menu3 text-neutral-1000 font-bold px-12 py-8 hover:bg-neutral-100 hover:text-neutral-1300 cursor-pointer flex items-center"; - const viewPortStyling = - "relative overflow-hidden w-full h-[var(--radix-navigation-menu-viewport-height)] origin-[top_center] transition-[width,_height] duration-300 data-[state=closed]:animate-scaleOut data-[state=open]:animate-scaleIn sm:w-[var(--radix-navigation-menu-viewport-width)]"; - const boxShadowViewport = - "shadow-[0_201px_56px_0_rgba(20,25,36,0),0_129px_51px_0_rgba(20,25,36,0.02),0_72px_43px_0_rgba(20,25,36,0.06),0_32px_32px_0_rgba(20,25,36,0.10),0_8px_18px_0_rgba(20,25,36,0.12)]"; + const DEFAULT_MENU_LINK_STYLING = + "ui-text-menu3 font-bold text-neutral-1000 dark:neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-1200 hover:text-neutral-1300 dark:hover:text-neutral-000 px-12 py-8 flex items-center justify-between"; + const DEFAULT_VIEWPORT_STYLING = + "relative overflow-hidden w-full h-[var(--radix-navigation-menu-viewport-height)] origin-[top_center] transition-[width,_height] duration-300 data-[state=closed]:animate-scale-out data-[state=open]:animate-scale-in sm:w-[var(--radix-navigation-menu-viewport-width)]"; return ( - + - {menuItems.map((menuItem) => ( - - {menuItem.content ? ( - <> - - {menuItem.label} - - - {menuItem.content} - - - ) : ( - - - {menuItem.label} - - - )} - - ))} + {menuItems.map(({ label, content, link, panelStyling }) => + content ? ( + + + {label} + + + {content} + + + ) : ( + + + {label} + + + ), + )}
); }; -export default NavigationMenuDemo; +export default Flyout; diff --git a/src/core/Flyout/Flyout.stories.tsx b/src/core/Flyout/Flyout.stories.tsx index c1abb36d..4864cc83 100644 --- a/src/core/Flyout/Flyout.stories.tsx +++ b/src/core/Flyout/Flyout.stories.tsx @@ -1,17 +1,20 @@ import React from "react"; -import { StoryFn } from "@storybook/react"; import Flyout from "../Flyout"; import ProductTile from "../ProductTile"; import FeaturedLink from "../FeaturedLink"; import { ProductName, products } from "../ProductTile/data"; +import { StoryFn } from "@storybook/react"; export default { title: "Components/Flyout", component: Flyout, tags: ["autodocs"], }; - -const Template: StoryFn = (args) =>
; +const Template: StoryFn = (args) => ( +
+ +
+); const platforms = [ "Infrastructure", @@ -28,7 +31,6 @@ const ProductsGrid = () => {
{Object.keys(products).map((product) => (
{panelLeft}
-

platform

+

platform

{platforms.map((item) => (
  • {item} @@ -65,12 +67,12 @@ const Panels = ({ ); const DefaultPanelLeft = ({ title, desc }: { title: string; desc: string }) => ( -
    -

    {title}

    -

    {desc}

    +
    +

    {title}

    +

    {desc}

    Learn more @@ -78,7 +80,7 @@ const DefaultPanelLeft = ({ title, desc }: { title: string; desc: string }) => (
    ); -const panelStyling = "w-full sm:w-[816px] bg-neutral-000"; +const panelStyling = "w-full sm:w-[816px] bg-neutral-000 dark:bg-neutral-1300"; export const Default = Template.bind({}); Default.args = { @@ -122,6 +124,7 @@ Default.args = { { label: "Pricing", content: null, link: "/pricing" }, { label: "Docs", content: null, link: "/docs" }, ], - navMenuStyling: "justify-center", - flyOutStyling: "justify-center", + className: "justify-center", + flyOutClassName: "justify-center", + viewPortClassName:"ui-shadow-lg-medium border border-neutral-000 dark:border-neutral-1300 rounded-2xl mt-8", }; diff --git a/tailwind.config.js b/tailwind.config.js index 506c1f5c..70662cb4 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -332,11 +332,11 @@ module.exports = { from: { opacity: 0 }, to: { opacity: 0.1 }, }, - scaleIn: { + "scale-in": { from: { opacity: "0", transform: "rotateX(-10deg) scale(0.9)" }, to: { opacity: "1", transform: "rotateX(0deg) scale(1)" }, }, - scaleOut: { + "scale-out": { from: { opacity: "1", transform: "rotateX(0deg) scale(1)" }, to: { opacity: "0", transform: "rotateX(-10deg) scale(0.95)" }, }, @@ -344,8 +344,8 @@ module.exports = { animation: { "accordion-down": "accordion-down 0.2s ease-out", "accordion-up": "accordion-up 0.2s ease-out", - scaleIn: "scaleIn 200ms ease", - scaleOut: "scaleOut 200ms ease", + "scale-in": "scale-in 200ms ease", + "scale-out": "scale-out 200ms ease", }, }, listStyleType: {