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

Feature/add sd list item #73

Merged
merged 4 commits into from
Oct 21, 2015
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import Button from 'src/elements/Button/Button';
import Container from 'src/elements/Container/Container';
import Image from 'src/elements/Image/Image';
import Input from 'src/elements/Input/Input';
import List from 'src/elements/List/List';
import ListItem from 'src/elements/List/ListItem';
import Segment from 'src/elements/Segment/Segment';

// Modules
Expand Down Expand Up @@ -61,6 +63,8 @@ export default {
Container,
Image,
Input,
List,
ListItem,
Segment,

// Modules
Expand Down
15 changes: 15 additions & 0 deletions src/elements/List/List.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, {Component, PropTypes} from 'react';
import classNames from 'classnames';

export default class List extends Component {
static propTypes = {
className: PropTypes.string,
};

render() {
let classes = classNames('sd-list', 'ui', this.props.className, 'list');
return (
<div {...this.props} className={classes}></div>
);
}
}
44 changes: 44 additions & 0 deletions src/elements/List/ListItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import _ from 'lodash';
import React, {Component, PropTypes} from 'react';
import classNames from 'classnames';

export default class ListItem extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
description: PropTypes.node,
header: PropTypes.string,
icon: PropTypes.node,
image: PropTypes.node,
};

render() {
const children = _.clone(this.props.children);
const classes = classNames('sd-list-item', this.props.className, 'item');
const description = _.clone(this.props.description);
const hasHeader = !!this.props.header;
const header = <div className='header'>{this.props.header}</div>;
const icon = _.clone(this.props.icon);
const image = _.clone(this.props.image);

const props = _.clone(this.props);
delete props.children;
delete props.className;
delete props.description;
delete props.header;
delete props.icon;
delete props.image;

return (
<div {...props} className={classes}>
{image || icon}
<div className='content'>
{hasHeader && header}
<div className='description'>
{children || description}
</div>
</div>
</div>
);
}
}