-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style(Table|mixed): update typings, tests and propTypes usage #1200
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ import { | |
} from '../../lib' | ||
import Icon from '../../elements/Icon' | ||
|
||
/** | ||
* A table row can have cells. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added jsdoc for subcomponents. |
||
function TableCell(props) { | ||
const { | ||
active, | ||
|
@@ -70,11 +73,6 @@ TableCell._meta = { | |
name: 'TableCell', | ||
type: META.TYPES.COLLECTION, | ||
parent: 'Table', | ||
props: { | ||
textAlign: SUI.TEXT_ALIGNMENTS, | ||
verticalAlign: SUI.VERTICAL_ALIGNMENTS, | ||
width: SUI.WIDTHS, | ||
}, | ||
} | ||
|
||
TableCell.defaultProps = { | ||
|
@@ -122,16 +120,16 @@ TableCell.propTypes = { | |
singleLine: PropTypes.bool, | ||
|
||
/** A table cell can adjust its text alignment. */ | ||
textAlign: PropTypes.oneOf(TableCell._meta.props.textAlign), | ||
textAlign: PropTypes.oneOf(_.without(SUI.TEXT_ALIGNMENTS, 'justified')), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/** A table cell can adjust its text alignment. */ | ||
verticalAlign: PropTypes.oneOf(TableCell._meta.props.verticalAlign), | ||
verticalAlign: PropTypes.oneOf(SUI.VERTICAL_ALIGNMENTS), | ||
|
||
/** A cell may warn a user. */ | ||
warning: PropTypes.bool, | ||
|
||
/** A table can specify the width of individual columns independently. */ | ||
width: PropTypes.oneOf(TableCell._meta.props.width), | ||
width: PropTypes.oneOf(SUI.WIDTHS), | ||
} | ||
|
||
TableCell.create = createShorthandFactory(TableCell, content => ({ content }), true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import cx from 'classnames' | ||
import React, { PropTypes } from 'react' | ||
|
||
import { | ||
customPropTypes, | ||
getUnhandledProps, | ||
|
@@ -8,23 +9,24 @@ import { | |
} from '../../lib' | ||
import TableCell from './TableCell' | ||
|
||
/** | ||
* A table can have a header cell. | ||
*/ | ||
function TableHeaderCell(props) { | ||
const { as, className, sorted } = props | ||
const classes = cx( | ||
useValueAndKey(sorted, 'sorted'), | ||
className | ||
) | ||
const rest = getUnhandledProps(TableHeaderCell, props) | ||
return <TableCell as={as} {...rest} className={classes} /> | ||
|
||
return <TableCell {...rest} as={as} className={classes} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually, when spreading this is true. But, since |
||
} | ||
|
||
TableHeaderCell._meta = { | ||
name: 'TableHeaderCell', | ||
type: META.TYPES.COLLECTION, | ||
parent: 'Table', | ||
props: { | ||
sorted: ['ascending', 'descending'], | ||
}, | ||
} | ||
|
||
TableHeaderCell.propTypes = { | ||
|
@@ -35,7 +37,7 @@ TableHeaderCell.propTypes = { | |
className: PropTypes.string, | ||
|
||
/** A header cell can be sorted in ascending or descending order. */ | ||
sorted: PropTypes.oneOf(TableHeaderCell._meta.props.sorted), | ||
sorted: PropTypes.oneOf(['ascending', 'descending']), | ||
} | ||
|
||
TableHeaderCell.defaultProps = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created new type
SemanticWIDTHS
, it's more strict and compact.