diff --git a/packages/blade/src/components/TopNav/docs/code.ts b/packages/blade/src/components/TopNav/docs/code.ts index afe02c34914..d0e11a405f5 100644 --- a/packages/blade/src/components/TopNav/docs/code.ts +++ b/packages/blade/src/components/TopNav/docs/code.ts @@ -3,7 +3,7 @@ import dedent from 'dedent'; export const topNavFullExample = { 'App.tsx': dedent`import React from 'react'; import { BrowserRouter } from 'react-router-dom'; - import TopNavExample from './TopNavExample'; + import { TopNavExample } from './TopNavExample'; const App = () => { return ( @@ -15,10 +15,11 @@ export const topNavFullExample = { export default App; `, - 'TopNavExample.tsx': dedent`import React from 'react'; - import { Link, useLocation, useHistory } from 'react-router-dom'; - import { SideNavExample } from './SideNavExample'; - import { isItemActive, RazorpayLogo } from './utils'; + 'TopNavExample.tsx': dedent`import React from "react"; + import styled from "styled-components"; + import { Link, useLocation, useNavigate } from "react-router-dom"; + import { SideNavExample } from "./SideNavExample"; + import { isItemActive, RazorpayLogo } from "./utils"; import { Box, Text, @@ -29,6 +30,7 @@ export const topNavFullExample = { TopNavActions, TabNav, TabNavItem, + TabNavItems, Menu, MenuItem, MenuOverlay, @@ -42,24 +44,28 @@ export const topNavFullExample = { SearchInput, Avatar, Tooltip, - MenuIcon, ActivityIcon, AnnouncementIcon, ChevronDownIcon, ChevronRightIcon, RazorpayxPayrollIcon, - BulkPayoutsIcon, List, ListItem, - SIDE_NAV_EXPANDED_L1_WIDTH_DESKTOP, - SIDE_NAV_EXPANDED_L1_WIDTH_MOBILE, - } from '@razorpay/blade/components'; - import { makeSize } from '@razorpay/blade/utils'; - import type { TabNavItemProps, IconComponent } from '@razorpay/blade/components'; + AcceptPaymentsIcon, + MagicCheckoutIcon, + AwardIcon, + SIDE_NAV_EXPANDED_L1_WIDTH_BASE, + SIDE_NAV_EXPANDED_L1_WIDTH_XL, + } from "@razorpay/blade/components"; + import { makeSize } from "@razorpay/blade/utils"; + import type { + TabNavItemProps, + IconComponent, + } from "@razorpay/blade/components"; const TabNavItemLink = React.forwardRef< HTMLAnchorElement, - Omit & { + Omit & { activeOnLinks?: string[]; } >((props, ref) => { @@ -69,12 +75,14 @@ export const topNavFullExample = { ref={ref} {...props} as={Link} - isActive={isItemActive(location, { href: props.href, activeOnLinks: props.activeOnLinks })} + isActive={isItemActive(location, { + href: props.href, + activeOnLinks: props.activeOnLinks, + })} /> ); }); - const ExploreItem = ({ icon: Icon, title, @@ -107,17 +115,20 @@ export const topNavFullExample = { const DashboardBackground = styled.div(() => { return { - height: '100vh', - background: 'radial-gradient(94.74% 64.44% at 29.03% 15.17%, #FFFFFF 0%, #90A5BB 100%)', + height: "100vh", + background: + "radial-gradient(94.74% 64.44% at 29.03% 15.17%, #FFFFFF 0%, #90A5BB 100%)", }; }); - + const TopNavExample = (): React.ReactElement => { const { platform } = useTheme(); - const history = useHistory(); - const isMobile = platform === 'onMobile'; + const navigate = useNavigate(); + const isMobile = platform === "onMobile"; const [isSideBarOpen, setIsSideBarOpen] = React.useState(false); - const [selectedProduct, setSelectedProduct] = React.useState(null); + const [selectedProduct, setSelectedProduct] = React.useState( + null + ); const activeUrl = useLocation().pathname; React.useEffect(() => { @@ -126,7 +137,7 @@ export const topNavFullExample = { return ( - + {isMobile ? ( <> @@ -140,7 +151,12 @@ export const topNavFullExample = { - + @@ -168,37 +184,37 @@ export const topNavFullExample = { {({ items, overflowingItems }) => { const activeProduct = overflowingItems.find( - (item) => item.href === selectedProduct, + (item) => item.href === selectedProduct ); return ( <> @@ -217,7 +233,11 @@ export const topNavFullExample = { {overflowingItems.length ? ( } isActive={Boolean(activeProduct)} /> @@ -235,7 +255,7 @@ export const topNavFullExample = { { - history.push(item.href!); + navigate(item.href!); setSelectedProduct(item.href!); }} > @@ -248,7 +268,11 @@ export const topNavFullExample = { ); })} - + View all products @@ -267,14 +291,14 @@ export const topNavFullExample = { />