From 163b1be93b7113d5330dab1d736d15e1c4c0a2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Wed, 11 Mar 2020 13:25:53 +0100 Subject: [PATCH] Introduce dedicated component for secondary navigation --- .../src/navigation/SecondaryNavigation.tsx | 45 +++++++++++++++++++ scm-ui/ui-components/src/navigation/index.ts | 1 + 2 files changed, 46 insertions(+) create mode 100644 scm-ui/ui-components/src/navigation/SecondaryNavigation.tsx diff --git a/scm-ui/ui-components/src/navigation/SecondaryNavigation.tsx b/scm-ui/ui-components/src/navigation/SecondaryNavigation.tsx new file mode 100644 index 0000000000..0ac9cfb9e1 --- /dev/null +++ b/scm-ui/ui-components/src/navigation/SecondaryNavigation.tsx @@ -0,0 +1,45 @@ +import React, { ReactElement, ReactNode } from "react"; +import { MenuContext } from "./MenuContext"; +import SubNavigation from "./SubNavigation"; +import NavLink from "./NavLink"; + +type Props = { + to: string; + icon: string; + label: string; + title: string; + activeWhenMatch?: (route: any) => boolean; + activeOnlyWhenExact?: boolean; + children?: ReactElement[]; +}; + +export default class SecondaryNavigation extends React.Component { + render() { + const { to, icon, label, title, activeWhenMatch, activeOnlyWhenExact, children } = this.props; + if (children) { + return ( + + {({ menuCollapsed }) => ( + + {children} + + )} + + ); + } else { + return ( + + {({ menuCollapsed }) => } + + ); + } + } +} diff --git a/scm-ui/ui-components/src/navigation/index.ts b/scm-ui/ui-components/src/navigation/index.ts index 30ca96bc51..88cd0ac353 100644 --- a/scm-ui/ui-components/src/navigation/index.ts +++ b/scm-ui/ui-components/src/navigation/index.ts @@ -8,3 +8,4 @@ export { default as PrimaryNavigation } from "./PrimaryNavigation"; export { default as PrimaryNavigationLink } from "./PrimaryNavigationLink"; export { default as Section } from "./Section"; export { MenuContext, storeMenuCollapsed, isMenuCollapsed } from "./MenuContext"; +export { default as SecondaryNavigation } from "./SecondaryNavigation";