@@ -23,38 +23,54 @@ const MenuItem = ({
2323 match,
2424 wrapperClass,
2525 toolTipText,
26+ enforceA,
27+ openNewTab,
2628} ) => {
2729 const matchedPath = match && match . path
2830 const isChildActive = children && some ( children , c => c . to === matchedPath )
2931
32+ const linkContent = (
33+ < span styleName = "content" >
34+ < span styleName = "left" >
35+ { ! ! Icon && (
36+ < Icon className = { cn ( styles . icon , styles [ iconClassName ] ) } />
37+ ) }
38+ { label }
39+ </ span >
40+ < span styleName = "right" >
41+ { ! ! count && < NotificationBadge count = { count } text = { toolTipText } /> }
42+ </ span >
43+ </ span >
44+ )
45+
3046 return (
3147 < li className = {
3248 cn ( wrapperClass ,
3349 styles . menuItem ,
3450 { [ styles . open ] : isAccordionOpen , [ styles . withChildren ] : children } ) }
3551 >
36- { ! children && (
52+ { ! children && ! enforceA && (
3753 < NavLink
3854 to = { to }
3955 className = { styles . navItem }
4056 activeClassName = { styles . active }
4157 exact = { exact }
4258 isActive = { isActive }
4359 >
44- < span styleName = "content" >
45- < span styleName = "left" >
46- { ! ! Icon && (
47- < Icon className = { cn ( styles . icon , styles [ iconClassName ] ) } />
48- ) }
49- { label }
50- </ span >
51- < span styleName = "right" >
52- { ! ! count && < NotificationBadge count = { count } text = { toolTipText } /> }
53- </ span >
54- </ span >
60+ { linkContent }
5561 </ NavLink >
5662 ) }
5763
64+ { ! children && enforceA && (
65+ < a
66+ href = { to }
67+ className = { styles . navItem }
68+ target = { openNewTab ? '_blank' : '' }
69+ >
70+ { linkContent }
71+ </ a >
72+ ) }
73+
5874 { children && (
5975 < div >
6076 < div
@@ -91,7 +107,9 @@ const MenuItem = ({
91107}
92108
93109MenuItem . defaultProps = {
94- exact : true
110+ exact : true ,
111+ enforceA : false ,
112+ openNewTab : false ,
95113}
96114
97115MenuItem . propTypes = {
@@ -107,6 +125,15 @@ MenuItem.propTypes = {
107125 onAccordionToggle : PT . func ,
108126 wrapperClass : PT . string ,
109127 toolTipText : PT . string ,
128+ /**
129+ * Render as regular link `<a>` instead of React Router `<NavLink>`
130+ */
131+ enforceA : PT . bool ,
132+ /**
133+ * Open link in the new tab.
134+ * Only works if `enforceA` is `true`.
135+ */
136+ openNewTab : PT . bool ,
110137}
111138
112139export default withRouter ( MenuItem )
0 commit comments