Skip to content

Commit 6dd49b0

Browse files
authored
feat:#1107 option to select productSwitchItem in Shellbar component (#1108)
* Added option to pre-select product switch Item in Shellbar component
1 parent ef6d673 commit 6dd49b0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Shellbar/Shellbar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class Shellbar extends Component {
416416
{productSwitchList.map((item, index) => {
417417
return (
418418
<li
419-
className='fd-product-switch__item'
419+
className={`fd-product-switch__item ${item.selected ? 'selected' : ''}`}
420420
key={index}
421421
onClick={item.callback}>
422422
<div className={`fd-product-switch__icon sap-icon--${item.glyph}`} />
@@ -487,14 +487,16 @@ Shellbar.propTypes = {
487487
label: PropTypes.string.isRequired
488488
}),
489489
/** Array of objects containing data about the products.
490-
* Callback, title, and glyph are required; subtitle is optional. */
490+
* Callback, title, and glyph are required; selected and subtitle are optional. */
491491
productSwitchList: PropTypes.arrayOf(
492492
PropTypes.shape({
493493
callback: PropTypes.func.isRequired,
494494
/** Localized text for the heading */
495495
title: PropTypes.string.isRequired,
496496
/** The icon to include. See the icon page for the list of icons */
497497
glyph: PropTypes.string.isRequired,
498+
/** For pre-selecting an item in the product switch list */
499+
selected: PropTypes.bool,
498500
subtitle: PropTypes.string
499501
})
500502
),

src/Shellbar/__stories__/Shellbar.stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export const coPilot = () => (
123123
title: 'Fiori Home',
124124
subtitle: 'Central Home',
125125
image: './assets/01.png',
126+
selected: true,
126127
glyph: 'home'
127128
},
128129
{

0 commit comments

Comments
 (0)