Skip to content

Commit

Permalink
feat(shorthand): Custom shorthand proptypes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcarbs committed Oct 4, 2016
1 parent c5776bd commit 40a40ed
Show file tree
Hide file tree
Showing 106 changed files with 379 additions and 481 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ Label.propTypes = {
/** A label can reduce its complexity. */
basic: PropTypes.bool,
/** Primary content of the label, same as text. */
/** Primary content. */
children: PropTypes.node,
/** Classes to add to the label className. */
Expand Down
4 changes: 2 additions & 2 deletions src/addons/Portal/Portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const _meta = {
*/
class Portal extends Component {
static propTypes = {
/** Primary content */
/** Primary content. */
children: PropTypes.node.isRequired,

/** Classes to be added to the portal node element. */
/** Additional classes. */
className: PropTypes.string,

/** Controls whether or not the portal should close on a click outside. */
Expand Down
4 changes: 2 additions & 2 deletions src/collections/Breadcrumb/Breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ Breadcrumb.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content of the Breadcrumb */
/** Primary content. */
children: customPropTypes.every([
customPropTypes.disallow(['sections', 'icon', 'divider']),
PropTypes.node,
]),

/** Classes that will be added to the Breadcrumb className. */
/** Additional classes. */
className: PropTypes.string,

/** For use with the sections prop. Primary content of the Breadcrumb.Divider. */
Expand Down
4 changes: 2 additions & 2 deletions src/collections/Breadcrumb/BreadcrumbDivider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ BreadcrumbDivider.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content of the Breadcrumb.Divider. */
/** Primary content. */
children: customPropTypes.every([
customPropTypes.disallow(['icon']),
PropTypes.node,
]),

/** Classes that will be added to the BreadcrumbDivider className. */
/** Additional classes. */
className: PropTypes.string,

/** Render as an `Icon` component with `divider` class instead of a `div`. */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Breadcrumb/BreadcrumbSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ BreadcrumbSection.propTypes = {
/** Style as the currently active section. */
active: PropTypes.bool,

/** Primary content of the Breadcrumb.Section. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(BreadcrumbSection),

/** Classes that will be added to the BreadcrumbSection className. */
/** Additional classes. */
className: PropTypes.string,

/** Render as an `a` tag instead of a `div`. */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ Form.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(Form),

/** Additional classes */
/** Additional classes. */
className: PropTypes.string,

/** Automatically show a loading indicator */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Form/FormField.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ FormField.propTypes = {
PropTypes.oneOf(FormField._meta.props.control),
]),

/** Primary content */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(FormField),

/** Additional classes to add */
/** Additional classes. */
className: PropTypes.string,

/** Individual fields may be disabled */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Form/FormGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ FormGroup.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content. Intended to be Form Fields. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(FormGroup),

/** Additional classes */
/** Additional classes. */
className: PropTypes.string,

/** Fields can show related choices */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ Grid.propTypes = {
/** A grid can have its columns centered. */
centered: PropTypes.bool,

/** Primary content of the Grid. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(Grid),

/** Classes that will be added to the Grid className. */
/** Additional classes. */
className: PropTypes.string,

/** Represents column count per row in Grid. */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Grid/GridColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ GridColumn.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content of the GridColumn. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(GridColumn),

/** Classes that will be added to the GridColumn className. */
/** Additional classes. */
className: PropTypes.string,

/** A column can specify a width for a computer. */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Grid/GridRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ GridRow.propTypes = {
/** A row can have its columns centered. */
centered: PropTypes.bool,

/** Primary content of the GridRow. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(GridRow),

/** Classes that will be added to the GridRow className. */
/** Additional classes. */
className: PropTypes.string,

/** A grid row can be colored. */
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class Menu extends Component {
/** A menu item or menu can have no borders. */
borderless: PropTypes.bool,

/** Primary content of the Menu. Mutually exclusive with items. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(Menu),

/** Classes that will be added to the Menu className. */
/** Additional classes. */
className: PropTypes.string,

/** Additional colors can be specified. */
Expand Down
13 changes: 5 additions & 8 deletions src/collections/Menu/MenuHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ MenuHeader.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(MenuHeader),

/** Additional classes */
/** Additional classes. */
className: PropTypes.string,

/** Shorthand for primary content */
content: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
/** Shorthand for primary content. */
content: customPropTypes.nodeShorthand,
}

export default MenuHeader
16 changes: 5 additions & 11 deletions src/collections/Menu/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,17 @@ MenuItem.propTypes = {
/** A menu item can be active. */
active: PropTypes.bool,

/** Primary content of the MenuItem. */
children: customPropTypes.every([
customPropTypes.disallow(['content']),
PropTypes.node,
]),
/** Primary content. */
children: customPropTypes.children(MenuItem),

/** Classes that will be added to the MenuItem className. */
/** Additional classes. */
className: PropTypes.string,

/** Additional colors can be specified. */
color: PropTypes.oneOf(MenuItem._meta.props.color),

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

/** A menu item or menu can remove element padding, vertically or horizontally. */
fitted: PropTypes.oneOfType([
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Menu/MenuMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ MenuMenu.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content of the MenuMenu. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(MenuMenu),

/** Classes that will be added to the MenuMenu className. */
/** Additional classes. */
className: PropTypes.string,

/** A sub menu can take right position. */
Expand Down
2 changes: 1 addition & 1 deletion src/collections/Message/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Message.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content of the message. */
/** Primary content. */
children: customPropTypes.every([
PropTypes.node,
customPropTypes.disallow(['header', 'content']),
Expand Down
2 changes: 1 addition & 1 deletion src/collections/Message/MessageContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MessageContent.propTypes = {
as: customPropTypes.as,

/** Primary content. */
children: PropTypes.node,
children: customPropTypes.children(MessageContent),

/** Additional classes. */
className: PropTypes.node,
Expand Down
2 changes: 1 addition & 1 deletion src/collections/Message/MessageHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MessageHeader.propTypes = {
as: customPropTypes.as,

/** Primary content. */
children: PropTypes.node,
children: customPropTypes.children(MessageHeader),

/** Additional classes. */
className: PropTypes.node,
Expand Down
2 changes: 1 addition & 1 deletion src/collections/Message/MessageItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MessageItem.propTypes = {
as: customPropTypes.as,

/** Primary content. */
children: PropTypes.node,
children: customPropTypes.children(MessageItem),

/** Additional classes. */
className: PropTypes.node,
Expand Down
2 changes: 1 addition & 1 deletion src/collections/Message/MessageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MessageList.propTypes = {
as: customPropTypes.as,

/** Primary content. */
children: PropTypes.node,
children: customPropTypes.children(MessageList),

/** Additional classes. */
className: PropTypes.node,
Expand Down
23 changes: 8 additions & 15 deletions src/collections/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Table(props) {
return (
<ElementType {...rest} className={classes}>
{headerRow && <TableHeader>{TableRow.create(headerRow, { cellAs: 'th' })}</TableHeader>}
{<TableBody>{_.map(tableData, (data, index) => TableRow.create(renderBodyRow(data, index)))}</TableBody>}
<TableBody>{_.map(tableData, (data, index) => TableRow.create(renderBodyRow(data, index)))}</TableBody>
{footerRow && <TableFooter>{TableRow.create(footerRow)}</TableFooter>}
</ElementType>
)
Expand Down Expand Up @@ -126,13 +126,10 @@ Table.propTypes = {
/** A table may be divided each row into separate cells. */
celled: PropTypes.bool,

/** Primary content of the Table. */
children: customPropTypes.every([
customPropTypes.disallow(['headerRow', 'renderBodyRow', 'footerRow', 'tableData']),
PropTypes.node,
]),
/** Primary content. */
children: customPropTypes.children(Table),

/** Classes that will be added to the Table className. */
/** Additional classes. */
className: PropTypes.string,

/** A table can be collapsing, taking up only as much space as its rows. */
Expand All @@ -159,16 +156,10 @@ Table.propTypes = {
fixed: PropTypes.bool,

/** Shorthand for a TableRow to be placed within Table.Footer. */
footerRow: PropTypes.oneOfType([
PropTypes.array,
PropTypes.element,
]),
footerRow: customPropTypes.collectionShorthand,

/** Shorthand for a TableRow to be placed within Table.Header. */
headerRow: PropTypes.oneOfType([
PropTypes.array,
PropTypes.element,
]),
headerRow: customPropTypes.collectionShorthand,

/** A table's colors can be inverted. */
inverted: PropTypes.bool,
Expand All @@ -184,6 +175,7 @@ Table.propTypes = {
* to be placed within Table.Body.
*/
renderBodyRow: customPropTypes.every([
customPropTypes.disallow(['children']),
customPropTypes.demand(['tableData']),
PropTypes.func,
]),
Expand All @@ -208,6 +200,7 @@ Table.propTypes = {

/** Data to be passed to the renderBodyRow function. */
tableData: customPropTypes.every([
customPropTypes.disallow(['children']),
customPropTypes.demand(['renderBodyRow']),
PropTypes.array,
]),
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Table/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ TableBody.propTypes = {
/** An element type to render as (string or function). */
as: customPropTypes.as,

/** Primary content of the TableBody. */
children: PropTypes.node,
/** Primary content. */
children: customPropTypes.children(TableBody),

/** Classes that will be added to the TableBody className. */
/** Additional classes. */
className: PropTypes.string,
}

Expand Down
25 changes: 6 additions & 19 deletions src/collections/Table/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,17 @@ TableCell.propTypes = {
/** A cell can be active or selected by a user. */
active: PropTypes.bool,

/** Primary content of the TableCell. */
children: customPropTypes.every([
customPropTypes.disallow(['content', 'icon']),
PropTypes.node,
]),
/** Primary content. */
children: customPropTypes.children(TableCell),

/** Classes that will be added to the TableCell className. */
/** Additional classes. */
className: PropTypes.string,

/** A cell can be collapsing so that it only uses as much space as required. */
collapsing: PropTypes.bool,

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

/** A cell can be disabled. */
disabled: PropTypes.bool,
Expand All @@ -110,14 +104,7 @@ TableCell.propTypes = {
error: PropTypes.bool,

/** Add an Icon by name, props object, or pass an <Icon /> */
icon: customPropTypes.every([
customPropTypes.disallow(['children']),
PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.element,
]),
]),
icon: customPropTypes.itemShorthand,

/** A cell may let a user know whether a value is bad. */
negative: PropTypes.bool,
Expand Down
Loading

0 comments on commit 40a40ed

Please sign in to comment.