Skip to content

Commit

Permalink
chore(Card): add doc blocks to all Card component props
Browse files Browse the repository at this point in the history
  • Loading branch information
athurman committed Aug 18, 2016
1 parent a09c503 commit e855252
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 15 deletions.
29 changes: 21 additions & 8 deletions src/views/Card/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function Card(props) {
className,
color,
description,
extra,
fluid,
header,
href,
Expand All @@ -46,15 +47,21 @@ function Card(props) {
}
const CardComponent = href || onClick ? 'a' : 'div'

if (children) {
return (
<CardComponent {...rest} className={classes} href={href} onClick={handleClick}>
{children}
</CardComponent>
)
}

return (
<CardComponent
{...rest}
className={classes}
href={href}
onClick={handleClick}
>
<CardComponent {...rest} className={classes} href={href} onClick={handleClick}>
{createImage(image)}
{children || <CardContent description={description} header={header} meta={meta} />}
{(description || header || meta) && (
<CardContent description={description} header={header} meta={meta} />
)}
{extra && <CardContent extra>{extra}</CardContent>}
</CardComponent>
)
}
Expand Down Expand Up @@ -89,6 +96,12 @@ Card.propTypes = {
PropTypes.node,
]),

/** Shorthand prop for CardContent containing extra prop. Mutually exclusive with children. */
extra: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.node,
]),

/** A Card can be formatted to take up the width of its container. */
fluid: PropTypes.bool,

Expand All @@ -101,7 +114,7 @@ Card.propTypes = {
/** Render as an `a` tag instead of a `div` and adds the href attribute. */
href: PropTypes.string,

/** An card can contain image. */
/** A card can contain an Image component. */
image: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.node,
Expand Down
13 changes: 12 additions & 1 deletion src/views/Card/CardContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,37 @@ CardContent._meta = {
}

CardContent.propTypes = {
className: PropTypes.string,
/** Primary content of the CardContent. Mutually exclusive with all shorthand props. */
children: customPropTypes.every([
customPropTypes.disallow(['description', 'header', 'meta']),
PropTypes.node,
]),

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

/** Shorthand prop for CardDescription. Mutually exclusive with children. */
description: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
]),

/** A card can contain extra content meant to be formatted separately from the main content */
extra: PropTypes.bool,

/** Shorthand prop for CardHeader. Mutually exclusive with children. */
header: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
]),

/** Shorthand prop for CardMeta. Mutually exclusive with children. */
meta: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([
Expand Down
7 changes: 6 additions & 1 deletion src/views/Card/CardDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ CardDescription._meta = {
}

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

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

/** Primary content of the CardDescription. Mutually exclusive with children. */
content: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([
Expand Down
16 changes: 13 additions & 3 deletions src/views/Card/CardGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,34 @@ CardGroup._meta = {
}

CardGroup.propTypes = {
className: PropTypes.string,
/** A group of Card components. Mutually exclusive with items. */
children: customPropTypes.every([
customPropTypes.disallow(['items']),
PropTypes.node,
]),

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

/** A group of cards can double its column width for mobile */
doubling: PropTypes.bool,

/** Shorthand prop for children. Mutually exclusive with children. */
items: customPropTypes.every([
customPropTypes.disallow(['description', 'header']),
customPropTypes.disallow(['children']),
PropTypes.arrayOf(PropTypes.shape({
description: PropTypes.node,
meta: PropTypes.node,
key: PropTypes.string,
header: PropTypes.node,
})),
]),

/** A group of cards can set how many cards should exist in a row */
itemsPerRow: PropTypes.oneOf(CardGroup._meta.props.width),

/** A group of cards can automatically stack rows to a single columns on mobile devices */
stackable: PropTypes.bool,
width: PropTypes.oneOf(CardGroup._meta.props.width),
}

export default CardGroup
5 changes: 4 additions & 1 deletion src/views/Card/CardHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ CardHeader._meta = {
}

CardHeader.propTypes = {
className: PropTypes.string,
children: customPropTypes.every([
customPropTypes.disallow(['content']),
PropTypes.node,
]),

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

content: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([
Expand Down
7 changes: 6 additions & 1 deletion src/views/Card/CardMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ CardMeta._meta = {
}

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

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

/** Primary content of the CardMeta. Mutually exclusive with children. */
content: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([
Expand Down

0 comments on commit e855252

Please sign in to comment.