From 37877e53c40d7e3351b7061c76183298839108db Mon Sep 17 00:00:00 2001 From: Levi Thomason Date: Sat, 13 Aug 2016 14:48:55 -0700 Subject: [PATCH] refactor(Card): update to use refactored utils --- src/views/Card/Card.js | 12 ++++---- src/views/Card/CardContent.js | 46 +++++++++++++++++++------------ src/views/Card/CardDescription.js | 25 ++++++++++------- src/views/Card/CardHeader.js | 25 ++++++++++------- src/views/Card/CardMeta.js | 25 ++++++++++------- 5 files changed, 81 insertions(+), 52 deletions(-) diff --git a/src/views/Card/Card.js b/src/views/Card/Card.js index c2acb2602f..484605ecc5 100644 --- a/src/views/Card/Card.js +++ b/src/views/Card/Card.js @@ -1,9 +1,11 @@ import cx from 'classnames' import React, { PropTypes } from 'react' -import META from '../../utils/Meta' -import * as sui from '../../utils/semanticUtils' -import { useKeyOnly } from '../../utils/propUtils' +import { + META, + SUI, + useKeyOnly, +} from '../../lib' import CardContent from './CardContent' import CardDescription from './CardDescription' import CardHeader from './CardHeader' @@ -50,9 +52,9 @@ function Card(props) { Card._meta = { name: 'Card', - type: META.type.view, + type: META.TYPES.VIEW, props: { - color: sui.colors, + color: SUI.COLORS, }, } diff --git a/src/views/Card/CardContent.js b/src/views/Card/CardContent.js index b9ce1a918d..3fb3191a05 100644 --- a/src/views/Card/CardContent.js +++ b/src/views/Card/CardContent.js @@ -1,8 +1,11 @@ import React, { PropTypes } from 'react' import cx from 'classnames' -import META from '../../utils/Meta' -import { customPropTypes, useKeyOnly } from '../../utils/propUtils' +import { + customPropTypes, + META, + useKeyOnly, +} from '../../lib' import CardDescription from './CardDescription' import CardHeader from './CardHeader' import CardMeta from './CardMeta' @@ -21,9 +24,9 @@ function CardContent(props) { return (
- {header && } - {meta && } - {description && } + {header && } + {meta && } + {description && }
) } @@ -31,27 +34,36 @@ function CardContent(props) { CardContent._meta = { name: 'CardContent', parent: 'Card', - type: META.type.view, + type: META.TYPES.VIEW, } CardContent.propTypes = { className: PropTypes.string, - children: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['description', 'header', 'meta']), + children: customPropTypes.every([ + customPropTypes.disallow(['description', 'header', 'meta']), PropTypes.node, ]), - description: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['children']), - PropTypes.node, + description: customPropTypes.every([ + customPropTypes.disallow(['children']), + PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ]), ]), extra: PropTypes.bool, - header: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['children']), - PropTypes.node, + header: customPropTypes.every([ + customPropTypes.disallow(['children']), + PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ]), ]), - meta: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['children']), - PropTypes.node, + meta: customPropTypes.every([ + customPropTypes.disallow(['children']), + PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ]), ]), } diff --git a/src/views/Card/CardDescription.js b/src/views/Card/CardDescription.js index d4e523ec68..f2906820ca 100644 --- a/src/views/Card/CardDescription.js +++ b/src/views/Card/CardDescription.js @@ -1,31 +1,36 @@ import cx from 'classnames' import React, { PropTypes } from 'react' -import META from '../../utils/Meta' -import { customPropTypes } from '../../utils/propUtils' +import { + customPropTypes, + META, +} from '../../lib' function CardDescription(props) { - const { className, children, description, ...rest } = props + const { className, children, content, ...rest } = props const classes = cx(className, 'description') - return
{ children || description }
+ return
{ children || content }
} CardDescription._meta = { name: 'CardDescription', parent: 'Card', - type: META.type.view, + type: META.TYPES.VIEW, } CardDescription.propTypes = { className: PropTypes.string, - children: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['description']), + children: customPropTypes.every([ + customPropTypes.disallow(['description']), PropTypes.node, ]), - description: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['children']), - PropTypes.node, + content: customPropTypes.every([ + customPropTypes.disallow(['children']), + PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ]), ]), } diff --git a/src/views/Card/CardHeader.js b/src/views/Card/CardHeader.js index c62231e8ab..2ae3a3f9d6 100644 --- a/src/views/Card/CardHeader.js +++ b/src/views/Card/CardHeader.js @@ -1,31 +1,36 @@ import cx from 'classnames' import React, { PropTypes } from 'react' -import META from '../../utils/Meta' -import { customPropTypes } from '../../utils/propUtils' +import { + customPropTypes, + META, +} from '../../lib' function CardHeader(props) { - const { className, children, header, ...rest } = props + const { className, children, content, ...rest } = props const classes = cx(className, 'header') - return
{children || header}
+ return
{children || content}
} CardHeader._meta = { name: 'CardHeader', parent: 'Card', - type: META.type.view, + type: META.TYPES.VIEW, } CardHeader.propTypes = { className: PropTypes.string, - children: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['header']), + children: customPropTypes.every([ + customPropTypes.disallow(['header']), PropTypes.node, ]), - header: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['children']), - PropTypes.node, + content: customPropTypes.every([ + customPropTypes.disallow(['children']), + PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ]), ]), } diff --git a/src/views/Card/CardMeta.js b/src/views/Card/CardMeta.js index e0b92db091..c2f5509fa0 100644 --- a/src/views/Card/CardMeta.js +++ b/src/views/Card/CardMeta.js @@ -1,31 +1,36 @@ import cx from 'classnames' import React, { PropTypes } from 'react' -import META from '../../utils/Meta' -import { customPropTypes } from '../../utils/propUtils' +import { + customPropTypes, + META, +} from '../../lib' function CardMeta(props) { - const { className, children, meta, ...rest } = props + const { className, children, content, ...rest } = props const classes = cx(className, 'meta') - return
{children || meta}
+ return
{children || content}
} CardMeta._meta = { name: 'CardMeta', parent: 'Card', - type: META.type.view, + type: META.TYPES.VIEW, } CardMeta.propTypes = { className: PropTypes.string, - children: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['meta']), + children: customPropTypes.every([ + customPropTypes.disallow(['meta']), PropTypes.node, ]), - meta: customPropTypes.all([ - customPropTypes.mutuallyExclusive(['children']), - PropTypes.node, + content: customPropTypes.every([ + customPropTypes.disallow(['children']), + PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ]), ]), }