Skip to content

Commit

Permalink
refactor(Feed): use new component parts
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Aug 14, 2016
1 parent f76a355 commit 1421756
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 93 deletions.
2 changes: 1 addition & 1 deletion docs/app/Examples/views/Feed/Content/Date.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Date = () => {
<Feed.Event>
<Feed.Label image={imageSrc} />
<Feed.Content>
<Feed.Date date='3 days ago' />
<Feed.Date>3 days ago</Feed.Date>
<Feed.Summary>
You added <a>Jenny Hess</a> to your <a>coworker</a> group.
</Feed.Summary>
Expand Down
2 changes: 1 addition & 1 deletion docs/app/Examples/views/Feed/Content/DateSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const DateSummary = () => {
<Summary>
You added <a>Jenny Hess</a> to your <a>coworker</a> group.

<Date date='3 days ago' />
<Date children='3 days ago' />
</Summary>
</Content>
</Event>
Expand Down
15 changes: 11 additions & 4 deletions src/views/Feed/Feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ import {
META,
SUI,
} from '../../lib'
import {
DatePart,
createUserPart,
} from '../../parts'

import FeedContent from './FeedContent'
import FeedDate from './FeedDate'
// import FeedDate from './FeedDate'
import FeedEvent from './FeedEvent'
import FeedExtra from './FeedExtra'
import FeedLabel from './FeedLabel'
import FeedLike from './FeedLike'
import FeedMeta from './FeedMeta'
import FeedSummary from './FeedSummary'
import FeedUser from './FeedUser'
// import FeedUser from './FeedUser'

function Feed(props) {
const { children, className, events, size } = props
Expand Down Expand Up @@ -83,13 +88,15 @@ Feed.propTypes = {
}

Feed.Content = FeedContent
Feed.Date = FeedDate
// Feed.Date = FeedDate
Feed.Date = DatePart
Feed.Event = FeedEvent
Feed.Extra = FeedExtra
Feed.Label = FeedLabel
Feed.Like = FeedLike
Feed.Meta = FeedMeta
Feed.Summary = FeedSummary
Feed.User = FeedUser
// Feed.User = FeedUser
Feed.User = createUserPart({ elementType: 'a' })

export default Feed
13 changes: 8 additions & 5 deletions src/views/Feed/FeedContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import cx from 'classnames'
import React, { PropTypes } from 'react'

import {
customPropTypes,
getUnhandledProps,
META,
customPropTypes,
getUnhandledProps,
META,
} from '../../lib'
import FeedDate from './FeedDate'

import { createDatePart } from '../../parts'
// import FeedDate from './FeedDate'
import FeedExtra from './FeedExtra'
import FeedMeta from './FeedMeta'
import FeedSummary from './FeedSummary'
Expand All @@ -15,10 +17,11 @@ function FeedContent(props) {
const { children, content, className, extraImages, extraText, date, meta, summary } = props
const classes = cx(className, 'content')
const rest = getUnhandledProps(FeedContent, props)
const Date = createDatePart({ elementType: 'div' })

return (
<div {...rest} className={classes}>
{date && <FeedDate date={date} />}
{date && <Date>{date}</Date>}
{summary && <FeedSummary summary={summary} />}
{extraImages && <FeedExtra images={extraImages} />}
{extraText && <FeedExtra text={extraText} />}
Expand Down
82 changes: 41 additions & 41 deletions src/views/Feed/FeedDate.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import cx from 'classnames'
import React, { PropTypes } from 'react'

import {
customPropTypes,
getUnhandledProps,
META,
} from '../../lib'

function FeedDate(props) {
const { children, className, date } = props
const classes = cx(className, 'date')
const rest = getUnhandledProps(FeedDate, props)

return <div {...rest} className={classes}>{children || date}</div>
}

FeedDate._meta = {
name: 'FeedDate',
parent: 'Feed',
type: META.TYPES.VIEW,
}

FeedDate.propTypes = {
/** Primary content of the FeedDate. Mutually exclusive with the date prop. */
children: customPropTypes.every([
customPropTypes.disallow(['date']),
PropTypes.node,
]),

/** Classes that will be added to the FeedDate className. */
className: PropTypes.string,

/** Shorthand for primary content of the FeedDate. Mutually exclusive with the children prop. */
date: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.string,
]),
}

export default FeedDate
// import cx from 'classnames'
// import React, { PropTypes } from 'react'
//
// import {
// customPropTypes,
// getUnhandledProps,
// META,
// } from '../../lib'
//
// function FeedDate(props) {
// const { children, className, date } = props
// const classes = cx(className, 'date')
// const rest = getUnhandledProps(FeedDate, props)
//
// return <div {...rest} className={classes}>{children || date}</div>
// }
//
// FeedDate._meta = {
// name: 'FeedDate',
// parent: 'Feed',
// type: META.TYPES.VIEW,
// }
//
// FeedDate.propTypes = {
// /** Primary content of the FeedDate. Mutually exclusive with the date prop. */
// children: customPropTypes.every([
// customPropTypes.disallow(['date']),
// PropTypes.node,
// ]),
//
// /** Classes that will be added to the FeedDate className. */
// className: PropTypes.string,
//
// /** Shorthand for primary content of the FeedDate. Mutually exclusive with the children prop. */
// date: customPropTypes.every([
// customPropTypes.disallow(['children']),
// PropTypes.string,
// ]),
// }
//
// export default FeedDate
82 changes: 41 additions & 41 deletions src/views/Feed/FeedUser.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import cx from 'classnames'
import React, { PropTypes } from 'react'

import {
customPropTypes,
getUnhandledProps,
META,
} from '../../lib'

function FeedUser(props) {
const { children, className, user } = props
const classes = cx(className, 'user')
const rest = getUnhandledProps(FeedUser, props)

return <a {...rest} className={classes}>{children || user}</a>
}

FeedUser._meta = {
name: 'FeedUser',
parent: 'Feed',
type: META.TYPES.VIEW,
}

FeedUser.propTypes = {
/** Primary content of the FeedUser. */
children: customPropTypes.every([
customPropTypes.disallow(['user']),
PropTypes.node,
]),

/** Classes that will be added to the FeedUser className. */
className: PropTypes.string,

/** Shorthand for primary content of the FeedUser. Mutually exclusive with the children prop. */
user: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.string,
]),
}

export default FeedUser
// import cx from 'classnames'
// import React, { PropTypes } from 'react'
//
// import {
// customPropTypes,
// getUnhandledProps,
// META,
// } from '../../lib'
//
// function FeedUser(props) {
// const { children, className, user } = props
// const classes = cx(className, 'user')
// const rest = getUnhandledProps(FeedUser, props)
//
// return <a {...rest} className={classes}>{children || user}</a>
// }
//
// FeedUser._meta = {
// name: 'FeedUser',
// parent: 'Feed',
// type: META.TYPES.VIEW,
// }
//
// FeedUser.propTypes = {
// /** Primary content of the FeedUser. */
// children: customPropTypes.every([
// customPropTypes.disallow(['user']),
// PropTypes.node,
// ]),
//
// /** Classes that will be added to the FeedUser className. */
// className: PropTypes.string,
//
// /** Shorthand for primary content of the FeedUser. Mutually exclusive with the children prop. */
// user: customPropTypes.every([
// customPropTypes.disallow(['children']),
// PropTypes.string,
// ]),
// }
//
// export default FeedUser

0 comments on commit 1421756

Please sign in to comment.