diff --git a/packages/odyssey-react-mui/src/labs/NavAccordion.tsx b/packages/odyssey-react-mui/src/labs/NavAccordion.tsx index fe34b7e045..9f50368f8f 100644 --- a/packages/odyssey-react-mui/src/labs/NavAccordion.tsx +++ b/packages/odyssey-react-mui/src/labs/NavAccordion.tsx @@ -10,37 +10,37 @@ * See the License for the specific language governing permissions and limitations under the License. */ -import { ReactNode, memo } from "react"; -import type { HtmlProps } from "../HtmlProps"; +import styled from "@emotion/styled"; import { - Box, Accordion as MuiAccordion, AccordionDetails as MuiAccordionDetails, AccordionSummary as MuiAccordionSummary, AccordionProps as MuiAccordionProps, } from "@mui/material"; +import { ReactNode, memo } from "react"; + +import type { HtmlProps } from "../HtmlProps"; import { ChevronRightIcon } from "../icons.generated"; -import { Support } from "../Typography"; -import { useUniqueId } from "../useUniqueId"; import { DesignTokens, useOdysseyDesignTokens, } from "../OdysseyDesignTokensContext"; -import styled from "@emotion/styled"; +import { Support } from "../Typography"; +import { useUniqueId } from "../useUniqueId"; export type NavAccordionProps = { /** * The content of the Accordion itself */ children: ReactNode; - /** - * Defines IDs for the header and the content of the Accordion - */ - id?: string; /** * The label text for the AccordionSummary */ label: string; + /** + * Defines IDs for the header and the content of the Accordion + */ + id?: string; /** * Whether the item is expanded by default */ @@ -81,11 +81,10 @@ const AccordionLabelContainer = styled("span", { isIconVisible: boolean; }>(({ odysseyDesignTokens, isIconVisible }) => ({ width: "100%", - marginLeft: isIconVisible ? odysseyDesignTokens.Spacing3 : 0, + marginLeft: isIconVisible ? odysseyDesignTokens.Spacing2 : 0, fontSize: odysseyDesignTokens.TypographyScale0, fontWeight: odysseyDesignTokens.TypographyWeightHeading, color: odysseyDesignTokens.TypographyColorHeading, - alignSelf: "center", })); const NavAccordion = ({ @@ -109,46 +108,27 @@ const NavAccordion = ({ disabled={isDisabled} disableGutters expanded={isExpanded} - sx={{ - border: "0 !important", - width: "100%", - }} + className="nav-accordion" > } id={headerId} > - - {startIcon && startIcon} - - {label} - - + {label} + {children} diff --git a/packages/odyssey-react-mui/src/labs/SideNav.tsx b/packages/odyssey-react-mui/src/labs/SideNav.tsx index 93abba868b..7472a231e6 100644 --- a/packages/odyssey-react-mui/src/labs/SideNav.tsx +++ b/packages/odyssey-react-mui/src/labs/SideNav.tsx @@ -10,6 +10,7 @@ * See the License for the specific language governing permissions and limitations under the License. */ +import styled from "@emotion/styled"; import { memo, useMemo, @@ -17,40 +18,25 @@ import { MouseEvent, ReactElement, ReactNode, + useCallback, } from "react"; +import { Box } from "../Box"; +import { Button } from "../Button"; +import type { HtmlProps } from "../HtmlProps"; +import { CollapseLeftIcon, ExpandLeftIcon } from "../icons.generated"; +import { Link } from "../Link"; +import { NavAccordion } from "./NavAccordion"; import { DesignTokens, useOdysseyDesignTokens, } from "../OdysseyDesignTokensContext"; - -import { NavAccordion } from "./NavAccordion"; - import { Status, statusSeverityValues } from "../Status"; - -import { Box } from "../Box"; -import type { HtmlProps } from "../HtmlProps"; -import styled from "@emotion/styled"; import { Heading6 } from "../Typography"; -import { CollapseLeftIcon, ExpandLeftIcon } from "../icons.generated"; -import { Link } from "../Link"; export type SideNavItem = { id: string; label: string; - target?: string; - /** - * The icon element to display at the start of the Nav Item - */ - startIcon?: ReactElement; - /** - * The status element to display after the label - */ - severity?: (typeof statusSeverityValues)[number]; - /** - * The label to display inside the status - */ - statusLabel?: string; /** * The icon element to display at the end of the Nav Item */ @@ -75,6 +61,19 @@ export type SideNavItem = { * Event fired when the nav item is clicked */ onClick?(event: MouseEvent): void; + /** + * The status element to display after the label + */ + severity?: (typeof statusSeverityValues)[number]; + /** + * The icon element to display at the start of the Nav Item + */ + startIcon?: ReactElement; + /** + * The label to display inside the status + */ + statusLabel?: string; + target?: string; } & ( | { /** @@ -95,49 +94,55 @@ export type SideNavItem = { ); export type SideNavFooterItem = { + href: string; id: string; label: string; - href: string; }; const SideNavCollapsedContainer = styled("div", { shouldForwardProp: (prop) => - prop !== "odysseyDesignTokens" && prop !== "sideNavCollapsed", + prop !== "odysseyDesignTokens" && prop !== "isSideNavCollapsed", })( ({ odysseyDesignTokens, - sideNavCollapsed, + isSideNavCollapsed, }: { odysseyDesignTokens: DesignTokens; - sideNavCollapsed: boolean; + isSideNavCollapsed: boolean; }) => ({ backgroundColor: odysseyDesignTokens.HueNeutral300, paddingTop: odysseyDesignTokens.Spacing5, cursor: "pointer", - width: sideNavCollapsed ? "auto" : 0, - visibility: sideNavCollapsed ? "visible" : "hidden", + width: isSideNavCollapsed ? "auto" : 0, + opacity: isSideNavCollapsed ? 1 : 0, + visibility: isSideNavCollapsed ? "visible" : "hidden", + transitionProperty: "opacity, visibility, width", + transitionDuration: odysseyDesignTokens.TransitionDurationMain, + transitionTimingFunction: odysseyDesignTokens.TransitionTimingMain, }), ); const SideNavContainer = styled("div", { shouldForwardProp: (prop) => - prop !== "odysseyDesignTokens" && prop !== "sideNavCollapsed", + prop !== "odysseyDesignTokens" && prop !== "isSideNavCollapsed", })( ({ odysseyDesignTokens, - sideNavCollapsed, + isSideNavCollapsed, }: { odysseyDesignTokens: DesignTokens; - sideNavCollapsed: boolean; + isSideNavCollapsed: boolean; }) => ({ backgroundColor: odysseyDesignTokens.HueNeutralWhite, flexDirection: "column", display: "flex", - visibility: sideNavCollapsed ? "hidden" : "visible", - width: sideNavCollapsed ? "0" : "100%", - transitionProperty: "width, visibility", + opacity: isSideNavCollapsed ? 0 : 1, + visibility: isSideNavCollapsed ? "hidden" : "visible", + width: isSideNavCollapsed ? "0" : "100%", + transitionProperty: "opacity, visibility, width", transitionDuration: odysseyDesignTokens.TransitionDurationMain, transitionTimingFunction: odysseyDesignTokens.TransitionTimingMain, + transitionDelay: odysseyDesignTokens.TransitionDurationMain, }), ); @@ -156,43 +161,23 @@ const SideNavHeaderContainer = styled("div", { const CollapseIcon = ({ onClick }: { onClick?(): void }): ReactElement => { const odysseyDesignTokens = useOdysseyDesignTokens(); return ( -
{ - event.key === "Enter" && onClick && onClick(); + button": { + height: "32px", + width: "32px", + color: odysseyDesignTokens.HueNeutral400, + }, }} > - - - -
+