From 8348e40daae5a4c6cd01c36a5e33dc6d3b2968f6 Mon Sep 17 00:00:00 2001 From: Levi Thomason Date: Sat, 13 Aug 2016 19:44:07 -0700 Subject: [PATCH] refactor(Feed): use new component parts --- docs/app/Examples/views/Feed/Content/Date.js | 2 +- .../views/Feed/Content/DateSummary.js | 2 +- src/views/Feed/Feed.js | 15 ++- src/views/Feed/FeedContent.js | 7 +- src/views/Feed/FeedDate.js | 98 ++++++++-------- src/views/Feed/FeedUser.js | 106 +++++++++--------- 6 files changed, 120 insertions(+), 110 deletions(-) diff --git a/docs/app/Examples/views/Feed/Content/Date.js b/docs/app/Examples/views/Feed/Content/Date.js index 2e2dd0c387..3257420f03 100644 --- a/docs/app/Examples/views/Feed/Content/Date.js +++ b/docs/app/Examples/views/Feed/Content/Date.js @@ -19,7 +19,7 @@ const Date = () => { - + 3 days ago You added Jenny Hess to your coworker group. diff --git a/docs/app/Examples/views/Feed/Content/DateSummary.js b/docs/app/Examples/views/Feed/Content/DateSummary.js index ff00dbdb1f..ecccf4c66e 100644 --- a/docs/app/Examples/views/Feed/Content/DateSummary.js +++ b/docs/app/Examples/views/Feed/Content/DateSummary.js @@ -24,7 +24,7 @@ const DateSummary = () => { You added Jenny Hess to your coworker group. - + diff --git a/src/views/Feed/Feed.js b/src/views/Feed/Feed.js index d1c07eb653..24f20dd71a 100644 --- a/src/views/Feed/Feed.js +++ b/src/views/Feed/Feed.js @@ -9,15 +9,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 @@ -91,13 +96,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 diff --git a/src/views/Feed/FeedContent.js b/src/views/Feed/FeedContent.js index 42647300f1..482d07e141 100644 --- a/src/views/Feed/FeedContent.js +++ b/src/views/Feed/FeedContent.js @@ -7,7 +7,9 @@ import { 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' @@ -17,10 +19,11 @@ function FeedContent(props) { const classes = cx(className, 'content') const rest = getUnhandledProps(FeedContent, props) const ElementType = getElementType(FeedContent, props) + const Date = createDatePart({ elementType: 'div' }) return ( - {date && } + {date && {date}} {summary && } {extraImages && } {extraText && } diff --git a/src/views/Feed/FeedDate.js b/src/views/Feed/FeedDate.js index a6be947f46..764593f820 100644 --- a/src/views/Feed/FeedDate.js +++ b/src/views/Feed/FeedDate.js @@ -1,49 +1,49 @@ -import cx from 'classnames' -import React, { PropTypes } from 'react' - -import { - customPropTypes, - getElementType, - getUnhandledProps, - META, -} from '../../lib' - -function FeedDate(props) { - const { children, className, date } = props - const classes = cx(className, 'date') - const rest = getUnhandledProps(FeedDate, props) - const ElementType = getElementType(FeedDate, props) - - return {children || date} -} - -FeedDate._meta = { - name: 'FeedDate', - parent: 'Feed', - type: META.TYPES.VIEW, -} - -FeedDate.propTypes = { - /** An element type to render as (string or function). */ - as: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.func, - ]), - - /** 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, +// getElementType, +// getUnhandledProps, +// META, +// } from '../../lib' +// +// function FeedDate(props) { +// const { children, className, date } = props +// const classes = cx(className, 'date') +// const rest = getUnhandledProps(FeedDate, props) +// const ElementType = getElementType(FeedDate, props) +// +// return {children || date} +// } +// +// FeedDate._meta = { +// name: 'FeedDate', +// parent: 'Feed', +// type: META.TYPES.VIEW, +// } +// +// FeedDate.propTypes = { +// /** An element type to render as (string or function). */ +// as: PropTypes.oneOfType([ +// PropTypes.string, +// PropTypes.func, +// ]), +// +// /** 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 diff --git a/src/views/Feed/FeedUser.js b/src/views/Feed/FeedUser.js index c723e1624f..b6e7d7b23d 100644 --- a/src/views/Feed/FeedUser.js +++ b/src/views/Feed/FeedUser.js @@ -1,53 +1,53 @@ -import cx from 'classnames' -import React, { PropTypes } from 'react' - -import { - customPropTypes, - getElementType, - getUnhandledProps, - META, -} from '../../lib' - -function FeedUser(props) { - const { children, className, user } = props - const classes = cx(className, 'user') - const rest = getUnhandledProps(FeedUser, props) - const ElementType = getElementType(FeedUser, props) - - return {children || user} -} - -FeedUser._meta = { - name: 'FeedUser', - parent: 'Feed', - type: META.TYPES.VIEW, -} - -FeedUser.propTypes = { - /** An element type to render as (string or function). */ - as: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.func, - ]), - - /** 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, - ]), -} - -FeedUser.defaultProps = { - as: 'a', -} - -export default FeedUser +// import cx from 'classnames' +// import React, { PropTypes } from 'react' +// +// import { +// customPropTypes, +// getElementType, +// getUnhandledProps, +// META, +// } from '../../lib' +// +// function FeedUser(props) { +// const { children, className, user } = props +// const classes = cx(className, 'user') +// const rest = getUnhandledProps(FeedUser, props) +// const ElementType = getElementType(FeedUser, props) +// +// return {children || user} +// } +// +// FeedUser._meta = { +// name: 'FeedUser', +// parent: 'Feed', +// type: META.TYPES.VIEW, +// } +// +// FeedUser.propTypes = { +// /** An element type to render as (string or function). */ +// as: PropTypes.oneOfType([ +// PropTypes.string, +// PropTypes.func, +// ]), +// +// /** 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, +// ]), +// } +// +// FeedUser.defaultProps = { +// as: 'a', +// } +// +// export default FeedUser