Skip to content

Commit

Permalink
docs(Menu): MenuItem icon and dropdown item example (#540)
Browse files Browse the repository at this point in the history
* fix(MenuItem): render missing shorthand icon

* fix(Attached): fix menu attached augmentation
  • Loading branch information
levithomason authored Sep 23, 2016
1 parent 7621a1b commit c624407
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/app/Examples/collections/Menu/Types/Attached.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Attached = () => {
return (
<div>
<Menu attached='top'>
<Menu.Item as={Dropdown} icon='wrench'>
<Dropdown as={Menu.Item} icon='wrench'>
<Dropdown.Menu>
<Dropdown.Item>
<Icon name='dropdown icon' />
Expand All @@ -25,7 +25,7 @@ const Attached = () => {
<Dropdown.Header>Export</Dropdown.Header>
<Dropdown.Item>Share</Dropdown.Item>
</Dropdown.Menu>
</Menu.Item>
</Dropdown>

<Menu.Menu position='right'>
<div className='ui right aligned category search item'>
Expand Down
12 changes: 11 additions & 1 deletion src/collections/Menu/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
useKeyOnly,
useKeyOrValueAndKey,
} from '../../lib'
import { createIcon } from '../../factories'

function MenuItem(props) {
const {
Expand All @@ -35,9 +36,18 @@ function MenuItem(props) {
}
const rest = getUnhandledProps(MenuItem, props)

if (children) {
return (
<ElementType {...rest} className={classes} onClick={handleClick}>
{children}
</ElementType>
)
}

return (
<ElementType {...rest} className={classes} onClick={handleClick}>
{children || content || _.startCase(name)}
{createIcon(icon)}
{content || _.startCase(name)}
</ElementType>
)
}
Expand Down
1 change: 1 addition & 0 deletions test/specs/collections/Menu/MenuItem-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { sandbox } from 'test/utils'

describe('MenuItem', () => {
common.isConformant(MenuItem)
common.implementsIconProp(MenuItem)
common.propKeyOnlyToClassName(MenuItem, 'active')
common.propValueOnlyToClassName(MenuItem, 'color')
common.propKeyOrValueToClassName(MenuItem, 'fitted')
Expand Down

0 comments on commit c624407

Please sign in to comment.