@@ -39,6 +39,7 @@ import {
3939} from '@instructure/ui-icons'
4040import generateStyle from './styles'
4141import generateComponentTheme from './theme'
42+ import { Img } from '@instructure/ui-img'
4243
4344type AppProps = {
4445 navigate : ( path : string , options ?: { replace : boolean } ) => void
@@ -63,6 +64,8 @@ type Menu = {
6364 onClick ?: ( ) => void
6465 }
6566 title : string
67+ renderBeforeMobileMenuItems ?: JSX . Element
68+ renderAfterMobileMenuItems ?: JSX . Element
6669}
6770
6871type MenuCollection = {
@@ -75,7 +78,12 @@ class App extends Component<AppProps, AppState> {
7578 super ( props )
7679
7780 this . state = {
78- menuStack : [ 'default' ]
81+ menuStack : [
82+ 'default' ,
83+ ...( window . location . pathname . substring ( 1 )
84+ ? [ window . location . pathname . substring ( 1 ) ]
85+ : [ ] )
86+ ]
7987 }
8088 }
8189
@@ -142,9 +150,8 @@ class App extends Component<AppProps, AppState> {
142150 label : 'Dashboard' ,
143151 renderBeforeLabel : < IconDashboardLine /> ,
144152 onClick : ( ) => {
145- // Navigate and reload logic
146153 this . props . navigate ( '/dashboard' , { replace : true } )
147- window . location . reload ( ) // Forces a reload
154+ window . location . reload ( )
148155 }
149156 } ,
150157 {
@@ -153,12 +160,19 @@ class App extends Component<AppProps, AppState> {
153160 }
154161 ] ,
155162 backNavigation : {
156- href : '#' ,
157- label : 'Back'
163+ href : undefined ,
164+ label : '' ,
165+ onClick : undefined
158166 } ,
159- title : 'Main Menu '
167+ title : ''
160168 } ,
161169 account : {
170+ renderBeforeMobileMenuItems : (
171+ < div style = { { display : 'flex' , justifyContent : 'center' } } >
172+ < Img src = "https://sbcf.fr/wp-content/uploads/2018/03/sbcf-default-avatar.png" />
173+ </ div >
174+ ) ,
175+ renderAfterMobileMenuItems : < h3 > Additional account info</ h3 > ,
162176 items : [
163177 {
164178 label : 'AccountInfo1'
@@ -182,6 +196,18 @@ class App extends Component<AppProps, AppState> {
182196 }
183197 } ,
184198 title : 'Courses'
199+ } ,
200+ dashboard : {
201+ title : 'Dashboard' ,
202+ items : [ { label : 'Courses1' } , { label : 'Courses2' } ] ,
203+ backNavigation : {
204+ label : 'Back' ,
205+ onClick : ( ) => {
206+ this . popMenu ( )
207+ this . props . navigate ( '/' , { replace : true } )
208+ window . location . reload ( )
209+ }
210+ }
185211 }
186212 }
187213
@@ -219,15 +245,18 @@ class App extends Component<AppProps, AppState> {
219245 onClick : ( ) => alert ( 'Alerts clicked' )
220246 }
221247 ] }
222- mobileMenuBackNavigation = { menu [ this . getCurrentMenu ( ) ] . backNavigation }
248+ mobileMenuBackNavigation = { menu [ this . getCurrentMenu ( ) ] ? .backNavigation }
223249 mobileMenu = { menu [ this . getCurrentMenu ( ) ] . items }
224- beforeMobileMenuItems = { < div > Before Mobile Menu</ div > }
225- afterMobileMenuItems = { < div > After Mobile Menu</ div > }
250+ beforeMobileMenuItems = {
251+ menu [ this . getCurrentMenu ( ) ] ?. renderBeforeMobileMenuItems
252+ }
253+ afterMobileMenuItems = {
254+ menu [ this . getCurrentMenu ( ) ] ?. renderAfterMobileMenuItems
255+ }
226256 />
227257 < Routes >
228258 < Route path = "/" element = { < h1 > This is home</ h1 > } />
229259 < Route path = "/dashboard" element = { < h1 > This is dashboard</ h1 > } />
230- { /*<Route path="/profile" element={<Profile />} />*/ }
231260 </ Routes >
232261 </ div >
233262 )
0 commit comments