@@ -34,6 +34,16 @@ const Trigger = ({
34
34
</ Button >
35
35
) ;
36
36
37
+ const Menubar = ( { collection, value} ) => {
38
+ return (
39
+ < Nav aria-orientation = "vertical" nested role = "menubar" >
40
+ < VerticalNavContext . Provider value = { value } >
41
+ < Collection collection = { collection } />
42
+ </ VerticalNavContext . Provider >
43
+ </ Nav >
44
+ ) ;
45
+ } ;
46
+
37
47
type Props < T extends Record < string , any > | string > = {
38
48
/**
39
49
* Flag to define which item has the active state/current page.
@@ -54,6 +64,11 @@ type Props<T extends Record<string, any> | string> = {
54
64
*/
55
65
children ?: React . ReactNode | ChildrenFunction < T , null > ;
56
66
67
+ /**
68
+ * Determines the Vertical Nav variant to use.
69
+ */
70
+ displayType ?: null | 'primary' ;
71
+
57
72
/**
58
73
* Flag to activate the Decorator variation.
59
74
*/
@@ -137,6 +152,7 @@ function VerticalNav<T extends Record<string, any> | string>({
137
152
activation = 'manual' ,
138
153
children,
139
154
decorated,
155
+ displayType,
140
156
defaultExpandedKeys = new Set ( ) ,
141
157
expandedKeys : externalExpandedKeys ,
142
158
itemAriaCurrent : ariaCurrent = true ,
@@ -238,57 +254,65 @@ function VerticalNav<T extends Record<string, any> | string>({
238
254
return depthActive ( items as Array < Record < string , any > > ) ;
239
255
} , [ active , items ] ) ;
240
256
257
+ const menubarValue = {
258
+ activeKey :
259
+ active && collection . hasItem ( active )
260
+ ? active
261
+ : hasDepthActive
262
+ ? null
263
+ : undefined ,
264
+ ariaCurrent : ariaCurrent ? 'page' : null ,
265
+ childrenRoot : childrenRootRef ,
266
+ close,
267
+ expandedKeys,
268
+ firstKey : collection . getFirstItem ( ) . key ,
269
+ open,
270
+ spritemap,
271
+ toggle,
272
+ } ;
273
+
241
274
return (
242
275
< nav
243
276
className = { classNames ( 'menubar menubar-transparent' , {
244
277
[ 'menubar-decorated' ] : decorated ,
278
+ [ 'menubar-primary' ] : displayType === 'primary' ,
245
279
[ 'menubar-vertical-expand-lg' ] : large ,
246
- [ 'menubar-vertical-expand-md' ] : ! large ,
280
+ [ 'menubar-vertical-expand-md' ] :
281
+ ! large && displayType !== 'primary' ,
247
282
} ) }
248
283
>
249
- < CustomTrigger onClick = { ( ) => setIsOpen ( ! isOpen ) } >
250
- < span className = "inline-item inline-item-before" >
251
- { triggerLabel }
252
- </ span >
253
-
254
- < Icon
255
- focusable = "false"
256
- role = "presentation"
257
- spritemap = { spritemap }
258
- symbol = "caret-bottom"
259
- />
260
- </ CustomTrigger >
261
-
262
- < div
263
- { ...navigationProps }
264
- className = { classNames ( 'collapse menubar-collapse' , {
265
- show : isOpen ,
266
- } ) }
267
- ref = { containerRef }
268
- >
269
- < Nav aria-orientation = "vertical" nested role = "menubar" >
270
- < VerticalNavContext . Provider
271
- value = { {
272
- activeKey :
273
- active && collection . hasItem ( active )
274
- ? active
275
- : hasDepthActive
276
- ? null
277
- : undefined ,
278
- ariaCurrent : ariaCurrent ? 'page' : null ,
279
- childrenRoot : childrenRootRef ,
280
- close,
281
- expandedKeys,
282
- firstKey : collection . getFirstItem ( ) . key ,
283
- open,
284
- spritemap,
285
- toggle,
286
- } }
284
+ { displayType !== 'primary' && (
285
+ < >
286
+ < CustomTrigger onClick = { ( ) => setIsOpen ( ! isOpen ) } >
287
+ < span className = "inline-item inline-item-before" >
288
+ { triggerLabel }
289
+ </ span >
290
+
291
+ < Icon
292
+ focusable = "false"
293
+ role = "presentation"
294
+ spritemap = { spritemap }
295
+ symbol = "caret-bottom"
296
+ />
297
+ </ CustomTrigger >
298
+
299
+ < div
300
+ { ...navigationProps }
301
+ className = { classNames ( 'collapse menubar-collapse' , {
302
+ show : isOpen ,
303
+ } ) }
304
+ ref = { containerRef }
287
305
>
288
- < Collection < T > collection = { collection } />
289
- </ VerticalNavContext . Provider >
290
- </ Nav >
291
- </ div >
306
+ < Menubar collection = { collection } value = { menubarValue } />
307
+ </ div >
308
+ </ >
309
+ ) }
310
+
311
+ { displayType === 'primary' && (
312
+ < >
313
+ < Menubar collection = { collection } value = { menubarValue } />
314
+ </ >
315
+ ) }
292
316
</ nav >
293
317
) ;
294
318
}
0 commit comments