@@ -41,6 +41,24 @@ export class GuidePageChrome extends Component {
4141 } ) ;
4242 } ;
4343
44+ renderSideNavBadge = ( { isBeta, isNew } ) => {
45+ if ( isBeta ) {
46+ return (
47+ < EuiBadge color = "warning" className = "guideSideNav__itemBadge" >
48+ BETA
49+ </ EuiBadge >
50+ ) ;
51+ }
52+ if ( isNew ) {
53+ return (
54+ < EuiBadge color = "accent" className = "guideSideNav__itemBadge" >
55+ NEW
56+ </ EuiBadge >
57+ ) ;
58+ }
59+ return undefined ;
60+ } ;
61+
4462 scrollNavSectionIntoView = ( ) => {
4563 // wait a bit for react to blow away and re-create the DOM
4664 // then scroll the selected nav section into view
@@ -80,7 +98,7 @@ export class GuidePageChrome extends Component {
8098 return ;
8199 }
82100
83- return subSectionsWithTitles . map ( ( { title, sections } ) => {
101+ return subSectionsWithTitles . map ( ( { title, isBeta , isNew , sections } ) => {
84102 const id = slugify ( title ) ;
85103
86104 const subSectionHref = `${ href } /${ id } ` ;
@@ -115,6 +133,7 @@ export class GuidePageChrome extends Component {
115133 : '' ,
116134 items : subItems ,
117135 forceOpen : ! ! searchTerm || isCurrentlyOpenSubSection ,
136+ icon : this . renderSideNavBadge ( { isBeta, isNew } ) ,
118137 } ;
119138 } ) ;
120139 } ;
@@ -146,16 +165,6 @@ export class GuidePageChrome extends Component {
146165
147166 const href = `#/${ path } ` ;
148167
149- const badge = isBeta ? (
150- < EuiBadge color = "warning" className = "guideSideNav__itemBadge" >
151- BETA
152- </ EuiBadge >
153- ) : isNew ? (
154- < EuiBadge color = "accent" className = "guideSideNav__itemBadge" >
155- NEW
156- </ EuiBadge >
157- ) : undefined ;
158-
159168 let visibleName = name ;
160169 if ( searchTerm ) {
161170 visibleName = (
@@ -176,7 +185,7 @@ export class GuidePageChrome extends Component {
176185 isSelected : item . path === this . props . currentRoute . path ,
177186 forceOpen : ! ! ( searchTerm && hasMatchingSubItem ) ,
178187 className : 'guideSideNav__item' ,
179- icon : badge ,
188+ icon : this . renderSideNavBadge ( { isBeta , isNew } ) ,
180189 } ;
181190 } ) ;
182191
0 commit comments