From 62ebd728c60c0e7f2c5e7e39c8494dcad276844a Mon Sep 17 00:00:00 2001 From: Huw Wilkins Date: Wed, 15 May 2024 12:12:21 +1000 Subject: [PATCH] Use application layout from react-components. --- src/app/App.tsx | 35 ++++--- .../AppSideNavItems/AppSideNavItems.tsx | 6 +- .../AppSideNavigation/AppSideNavigation.tsx | 98 ++++++++++--------- .../components/AppSidePanel/AppSidePanel.tsx | 14 +-- .../components/PageContent/PageContent.tsx | 5 +- 5 files changed, 83 insertions(+), 75 deletions(-) diff --git a/src/app/App.tsx b/src/app/App.tsx index 315db92551..8a81dccee6 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -1,7 +1,13 @@ import type { ReactNode } from "react"; import { Suspense, useEffect } from "react"; -import { Notification } from "@canonical/react-components"; +import { + AppNavigationBar, + AppStatus, + Application, + Notification, + Panel, +} from "@canonical/react-components"; import { usePrevious } from "@canonical/react-components/dist/hooks"; import * as Sentry from "@sentry/browser"; import { useDispatch, useSelector } from "react-redux"; @@ -168,21 +174,20 @@ export const App = (): JSX.Element => { } return ( -
- + + {authLoaded && authenticated ? ( ) : ( -
-
-
- -
-
-
+ + } + /> + )} - { > {content} - -
-
+ + + ); }; diff --git a/src/app/base/components/AppSideNavigation/AppSideNavItems/AppSideNavItems.tsx b/src/app/base/components/AppSideNavigation/AppSideNavItems/AppSideNavItems.tsx index 7f83b65f37..c120c50457 100644 --- a/src/app/base/components/AppSideNavigation/AppSideNavItems/AppSideNavItems.tsx +++ b/src/app/base/components/AppSideNavigation/AppSideNavItems/AppSideNavItems.tsx @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { Navigation } from "@canonical/maas-react-components"; -import { Button, Icon } from "@canonical/react-components"; +import { Button, Icon, SideNavigation } from "@canonical/react-components"; import AppSideNavItem from "../AppSideNavItem"; import type { SideNavigationProps } from "../AppSideNavigation"; @@ -93,7 +93,7 @@ export const AppSideNavItems = ({ vaultIncomplete, }: Props): JSX.Element => { return ( - <> + {showLinks ? ( ) : null} - + ); }; diff --git a/src/app/base/components/AppSideNavigation/AppSideNavigation.tsx b/src/app/base/components/AppSideNavigation/AppSideNavigation.tsx index d1840c5a5d..1ca56c6d3e 100644 --- a/src/app/base/components/AppSideNavigation/AppSideNavigation.tsx +++ b/src/app/base/components/AppSideNavigation/AppSideNavigation.tsx @@ -1,6 +1,11 @@ import { useEffect, useMemo } from "react"; import { Navigation, NavigationBar } from "@canonical/maas-react-components"; +import { + AppNavigation, + AppNavigationBar, + Panel, +} from "@canonical/react-components"; import { useDispatch, useSelector } from "react-redux"; import { useNavigate, useLocation, useMatch } from "react-router-dom"; import { useStorageState } from "react-storage-hooks"; @@ -55,54 +60,51 @@ export const AppSideNavigation = ({ vaultIncomplete, }: SideNavigationProps) => ( <> - - - - - { - setIsCollapsed(!isCollapsed); - }} - > - Menu - - - - - - - - - - { - setIsCollapsed(!isCollapsed); - }} - > - Close menu - - - - - - - - - - + + } + toggle={{ + label: "Menu", + onClick: () => setIsCollapsed(!isCollapsed), + }} + /> + + + + { + setIsCollapsed(!isCollapsed); + }} + > + Close menu + + + + } + controlsClassName="u-no-margin--top" + dark + logo={} + stickyHeader + > + + + ); diff --git a/src/app/base/components/AppSidePanel/AppSidePanel.tsx b/src/app/base/components/AppSidePanel/AppSidePanel.tsx index 8c881c82c3..0a80c92379 100644 --- a/src/app/base/components/AppSidePanel/AppSidePanel.tsx +++ b/src/app/base/components/AppSidePanel/AppSidePanel.tsx @@ -1,7 +1,7 @@ import { useEffect, type ReactNode } from "react"; import { ContentSection } from "@canonical/maas-react-components"; -import { useOnEscapePressed } from "@canonical/react-components"; +import { AppAside, useOnEscapePressed } from "@canonical/react-components"; import classNames from "classnames"; import type { SidePanelSize } from "@/app/base/side-panel-context"; @@ -49,16 +49,16 @@ const AppSidePanelContent = ({ content, }: AppSidePanelProps): JSX.Element => { return ( - + ); }; diff --git a/src/app/base/components/PageContent/PageContent.tsx b/src/app/base/components/PageContent/PageContent.tsx index 853b9e388b..00c17b63c9 100644 --- a/src/app/base/components/PageContent/PageContent.tsx +++ b/src/app/base/components/PageContent/PageContent.tsx @@ -1,5 +1,6 @@ import type { HTMLProps, ReactNode } from "react"; +import { AppMain } from "@canonical/react-components"; import classNames from "classnames"; import { useSelector } from "react-redux"; import { matchPath, useLocation } from "react-router-dom"; @@ -44,7 +45,7 @@ const PageContent = ({ return ( <> -
+ {isSecondaryNavVisible ? (
{children}
-
+ );