Skip to content

Commit

Permalink
Merge pull request #221 from TechnologyAdvice/feature/listitem-prop-r…
Browse files Browse the repository at this point in the history
…enderers

List item prop renderers
  • Loading branch information
levithomason committed Apr 26, 2016
2 parents c1d6353 + 945b2bd commit cebdfdd
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/elements/List/ListItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { Component, PropTypes } from 'react'
import cx from 'classnames'

import META from '../../utils/Meta'
import { iconPropRenderer, imagePropRenderer } from '../../utils/propUtils'

export default class ListItem extends Component {
static propTypes = {
Expand All @@ -23,18 +25,23 @@ export default class ListItem extends Component {
const { children, className, description, header, icon, image, ...rest } = this.props
const classes = cx('sd-list-item', className, 'item')

const content = !header ? description : (
<div className='content'>
<div className='header'>{header}</div>
{description && <div className='description'>{description}</div>}
</div>
const media = iconPropRenderer(icon) || imagePropRenderer(image)
const _description = description || children

let content = header ? [
header && <div key='header' className='header'>{header}</div>,
_description && <div key='description' className='description'>{_description}</div>,
] : (
_description
)

// wrap content for icon/image layouts
if (media) content = <div className='content'>{content}</div>

return (
<div {...rest} className={classes}>
{image || icon}
{media}
{content}
{children}
</div>
)
}
Expand Down

0 comments on commit cebdfdd

Please sign in to comment.