From 05ff87c596787fcb825d1d2e6b2ac84602a59890 Mon Sep 17 00:00:00 2001 From: Noel Quiles <3746694+EnMod@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:19:35 -0400 Subject: [PATCH] refactor: Add new dropdown to non-generic pages (#2568) * refactor: Add product panel to tutorials pages - Move `left` alignment of dropdowns exclusively into desktop dropdown pane - Add `NavBarListContainer` to tutorials dropdown wrapping to satisfy Radix * chore: More-reasonable wrapping setup * chore: Change menu on tutorials library * Revert "chore: Change menu on tutorials library" This reverts commit 393b6258f111dc842f020f92c52a39d307a04ed0. * fix: add left padding on product pages * Reapply "chore: Change menu on tutorials library" This reverts commit 46a6c5d9c26c481da2792079c437783462ce3739. * fix: Padding on mobile for sidebars * add mobile menu to profile page * add product panel to products pages main menu * fix: Sticky auth controls on sidebar-sidecar layout * fix padding * fix: Restore resources in product sidebars * fix padding and margin * fix desktop padding * chore(SidebarNavList): Use NativeDivElement type for props Co-authored-by: Heat Hamilton <55773810+heatlikeheatwave@users.noreply.github.com> * fix: Mobile menu cutoff * fix: Only apply that height change on mobile * chore: Use inline JSX.IntrinsicElements['div'] type over explicit className type --------- Co-authored-by: Leah Bush Co-authored-by: Heat Hamilton <55773810+heatlikeheatwave@users.noreply.github.com> --- .../mobile-menu-container.module.css | 1 + .../dropdown-menu/dropdown-menu.module.css | 1 - .../home-page-content.module.css | 4 +++ .../components/home-page-content/index.tsx | 1 + .../components/product-page-content/index.tsx | 23 ++++++++---- .../product-page-content.module.css | 5 --- .../sidebar-mobile-controls.module.css | 5 +++ .../components/sidebar-nav-list/index.tsx | 10 ++++-- src/components/sidebar/index.tsx | 34 ++++++++++++++++-- src/components/sidebar/sidebar.module.css | 4 +++ src/layouts/sidebar-sidecar/index.tsx | 21 +++++++++-- .../sidebar-sidecar-layout.module.css | 21 ++++++++--- src/pages/tutorials/library.tsx | 24 +++++++------ src/views/profile/sidebar/index.tsx | 36 ++++++++++--------- 14 files changed, 141 insertions(+), 49 deletions(-) diff --git a/src/components/mobile-menu-container/mobile-menu-container.module.css b/src/components/mobile-menu-container/mobile-menu-container.module.css index 4cce5ff3ca..cd1cda97b9 100644 --- a/src/components/mobile-menu-container/mobile-menu-container.module.css +++ b/src/components/mobile-menu-container/mobile-menu-container.module.css @@ -24,6 +24,7 @@ z-index: 2; @media (--dev-dot-show-mobile-menu) { top: auto; + height: calc(100% - var(--sticky-bars-height)); } @media (--dev-dot-hide-mobile-menu) { top: var(--sticky-bars-height); diff --git a/src/components/navigation-header/components/dropdown-menu/dropdown-menu.module.css b/src/components/navigation-header/components/dropdown-menu/dropdown-menu.module.css index 8d19ff49b8..2ad48faf30 100644 --- a/src/components/navigation-header/components/dropdown-menu/dropdown-menu.module.css +++ b/src/components/navigation-header/components/dropdown-menu/dropdown-menu.module.css @@ -65,7 +65,6 @@ box-shadow: var(--token-elevation-higher-box-shadow); min-width: max-content; position: absolute; - left: -216px; } .dropdownContainerInner { diff --git a/src/components/navigation-header/components/home-page-content/home-page-content.module.css b/src/components/navigation-header/components/home-page-content/home-page-content.module.css index e466e2ac21..421c42a14b 100644 --- a/src/components/navigation-header/components/home-page-content/home-page-content.module.css +++ b/src/components/navigation-header/components/home-page-content/home-page-content.module.css @@ -29,3 +29,7 @@ } } } + +.homepageDropdownPane { + left: -216px; +} diff --git a/src/components/navigation-header/components/home-page-content/index.tsx b/src/components/navigation-header/components/home-page-content/index.tsx index 3843c0844a..907806e793 100644 --- a/src/components/navigation-header/components/home-page-content/index.tsx +++ b/src/components/navigation-header/components/home-page-content/index.tsx @@ -25,6 +25,7 @@ const HomePageHeaderContent = () => {
  • { @@ -28,14 +30,21 @@ const ProductPageHeaderContent = () => { return ( <>
    - } - /> + + } + productPanelData={{ + navigationData, + navPromo, + sidePanelContent, + }} + /> +
    +
    {children} +type NativeDivElement = JSX.IntrinsicElements['div'] + +export default function SidebarNavList({ + className, + children, +}: NativeDivElement & { children: ReactNode }) { + return
      {children}
    } diff --git a/src/components/sidebar/index.tsx b/src/components/sidebar/index.tsx index 696aa4d1b0..5bb2ef3752 100644 --- a/src/components/sidebar/index.tsx +++ b/src/components/sidebar/index.tsx @@ -6,6 +6,8 @@ // Third-party imports import { ReactElement, useMemo, useState } from 'react' import classNames from 'classnames' +import * as NavigationMenu from '@radix-ui/react-navigation-menu' +import ProductPanel from '@hashicorp/react-components/src/components/nav-panel/product-panel' // Global imports import { SIDEBAR_LABEL_ID, SIDEBAR_NAV_ELEMENT_ID } from 'constants/element-ids' @@ -19,6 +21,7 @@ import { SidebarNavMenuItem, SidebarTitleHeading, } from 'components/sidebar/components' +import { mobileNavigationData, navPromo, sidePanelContent } from 'lib/products' // Local imports import { FilteredNavItem, MenuItem, SidebarProps } from './types' @@ -45,7 +48,8 @@ const Sidebar = ({ visuallyHideTitle = false, isInstallPage, showResourcesList = true, -}: SidebarProps): ReactElement => { + className, +}: SidebarProps & JSX.IntrinsicElements['div']) => { const currentProduct = useCurrentProduct() const { shouldRenderMobileControls } = useSidebarNavData() const currentPath = useCurrentPath({ excludeHash: true, excludeSearch: true }) @@ -54,6 +58,7 @@ const Sidebar = ({ () => addNavItemMetaData(currentPath, menuItems), [currentPath, menuItems] ) + const isProductPanel = shouldRenderMobileControls && title === 'Main Menu' let backToElement if (shouldRenderMobileControls && levelButtonProps) { @@ -131,6 +136,27 @@ const Sidebar = ({ showFilterInput={false} /> ) + } else if (isProductPanel) { + sidebarContent = ( + <> + + + + {showResourcesList && ( + + {navResourceItems.map((item, index) => ( + // eslint-disable-next-line react/no-array-index-key + + ))} + + )} + + ) + visuallyHideTitle = true } else { sidebarContent = ( <> @@ -145,7 +171,11 @@ const Sidebar = ({ ) } return ( -
    +
    {backToElement} {sidebarFilterInput}
  • - ) : ( - generateTopLevelSubNavItems().map((item, index) => ( - - )) - )} - - + + + + + + ) }