Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List item prop renderers #221

Merged
merged 1 commit into from
Apr 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

const _description = description || children

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

@levithomason levithomason Apr 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not add description div if there is no header, it breaks middle aligned content.

)

// 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