Skip to content

Commit fc2b804

Browse files
committed
allows custom classes on menu list items
1 parent 4bd8c4a commit fc2b804

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

components/menu-list/list-item.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const ListItem = React.createClass({
3939
displayName: LIST_ITEM,
4040

4141
propTypes: {
42+
className: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),
4243
checkmark: PropTypes.bool,
4344
data: PropTypes.object,
4445
divider: PropTypes.oneOf(['top', 'bottom']),
@@ -141,10 +142,13 @@ const ListItem = React.createClass({
141142
case 'header': {
142143
return (
143144
<li
144-
className={classNames('slds-dropdown__header', {
145-
'slds-has-divider--top-space': this.props.divider === 'top',
146-
'slds-has-divider--bottom-space': this.props.divider === 'bottom'
147-
}
145+
className={classNames(
146+
'slds-dropdown__header',
147+
{
148+
'slds-has-divider--top-space': this.props.divider === 'top',
149+
'slds-has-divider--bottom-space': this.props.divider === 'bottom'
150+
},
151+
this.props.className
148152
)}
149153
onMouseDown={this.handleMouseDown}
150154
role="separator"
@@ -155,7 +159,11 @@ const ListItem = React.createClass({
155159
}
156160
case 'divider': {
157161
return (
158-
<li className="slds-has-divider" onMouseDown={this.handleMouseDown} role="separator"></li>
162+
<li
163+
className={classNames('slds-has-divider', this.props.className)}
164+
onMouseDown={this.handleMouseDown}
165+
role="separator"
166+
></li>
159167
);
160168
}
161169
case 'link':
@@ -164,7 +172,7 @@ const ListItem = React.createClass({
164172
return (
165173
<li
166174
aria-selected={this.props.isSelected}
167-
className={classNames('slds-dropdown__item', { 'slds-is-selected': this.props.isSelected })}
175+
className={classNames('slds-dropdown__item', { 'slds-is-selected': this.props.isSelected }, this.props.className)}
168176
id={this.props.id}
169177
onMouseDown={this.handleMouseDown}
170178
role="presentation"

stories/dropdown/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import Button from '../../components/button';
1212
import Trigger from '../../components/menu-dropdown/button-trigger';
1313

1414
const options = [
15+
{ label: 'A Header', divider: 'bottom', className: 'custom-header-class', type: 'header' },
1516
{ label: 'An option that is Super Super Long', value: 'A0' },
17+
{ label: 'Custom Class', className: 'custom-item-class', value: 'classssss' },
1618
{ label: 'Another option', value: 'B0' },
1719
{ label: 'C Option', value: 'C0' },
1820
{ label: 'D Option', value: 'D0' },
1921
{ label: 'E Option', value: 'E0' },
22+
{ className: 'custom-divider-class', type: 'divider' },
2023
{ label: 'A1 Option', value: 'A1' },
2124
{ label: 'B2 Option', value: 'B1' },
2225
{ label: 'C2 Option', value: 'C1' },

0 commit comments

Comments
 (0)