diff --git a/packages/__docs__/src/App/index.tsx b/packages/__docs__/src/App/index.tsx index b952f74057..e98282ae0e 100644 --- a/packages/__docs__/src/App/index.tsx +++ b/packages/__docs__/src/App/index.tsx @@ -39,6 +39,7 @@ import { } from '@instructure/ui-icons' import generateStyle from './styles' import generateComponentTheme from './theme' +import { Img } from '@instructure/ui-img' type AppProps = { navigate: (path: string, options?: { replace: boolean }) => void @@ -63,6 +64,8 @@ type Menu = { onClick?: () => void } title: string + renderBeforeMobileMenuItems?: JSX.Element + renderAfterMobileMenuItems?: JSX.Element } type MenuCollection = { @@ -75,7 +78,12 @@ class App extends Component { super(props) this.state = { - menuStack: ['default'] + menuStack: [ + 'default', + ...(window.location.pathname.substring(1) + ? [window.location.pathname.substring(1)] + : []) + ] } } @@ -142,9 +150,8 @@ class App extends Component { label: 'Dashboard', renderBeforeLabel: , onClick: () => { - // Navigate and reload logic this.props.navigate('/dashboard', { replace: true }) - window.location.reload() // Forces a reload + window.location.reload() } }, { @@ -153,12 +160,19 @@ class App extends Component { } ], backNavigation: { - href: '#', - label: 'Back' + href: undefined, + label: '', + onClick: undefined }, - title: 'Main Menu' + title: '' }, account: { + renderBeforeMobileMenuItems: ( +
+ +
+ ), + renderAfterMobileMenuItems:

Additional account info

, items: [ { label: 'AccountInfo1' @@ -182,6 +196,18 @@ class App extends Component { } }, title: 'Courses' + }, + dashboard: { + title: 'Dashboard', + items: [{ label: 'Courses1' }, { label: 'Courses2' }], + backNavigation: { + label: 'Back', + onClick: () => { + this.popMenu() + this.props.navigate('/', { replace: true }) + window.location.reload() + } + } } } @@ -219,15 +245,18 @@ class App extends Component { onClick: () => alert('Alerts clicked') } ]} - mobileMenuBackNavigation={menu[this.getCurrentMenu()].backNavigation} + mobileMenuBackNavigation={menu[this.getCurrentMenu()]?.backNavigation} mobileMenu={menu[this.getCurrentMenu()].items} - beforeMobileMenuItems={
Before Mobile Menu
} - afterMobileMenuItems={
After Mobile Menu
} + beforeMobileMenuItems={ + menu[this.getCurrentMenu()]?.renderBeforeMobileMenuItems + } + afterMobileMenuItems={ + menu[this.getCurrentMenu()]?.renderAfterMobileMenuItems + } /> This is home} /> This is dashboard} /> - {/*} />*/} ) diff --git a/packages/ui-top-nav-bar/src/CanvasTopNav/index.tsx b/packages/ui-top-nav-bar/src/CanvasTopNav/index.tsx index 1277cc3d86..cca5908a26 100644 --- a/packages/ui-top-nav-bar/src/CanvasTopNav/index.tsx +++ b/packages/ui-top-nav-bar/src/CanvasTopNav/index.tsx @@ -88,26 +88,42 @@ const CanvasTopNav = ({ ))} -
- - + -
- - {mobileMenuBackNavigation.label} -
-
-
-
- {beforeMobileMenuItems && beforeMobileMenuItems} + + +
+ + {mobileMenuBackNavigation.label} +
+
+
+ + + )} + {beforeMobileMenuItems && ( +
+ {beforeMobileMenuItems} +
+ )} {mobileMenu.map((item: any, index: any) => ( ))} - {afterMobileMenuItems && afterMobileMenuItems} + {afterMobileMenuItems && ( +
+ {afterMobileMenuItems} +
+ )}
) : (