-
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
Conversation
@@ -54,7 +53,7 @@ interface FormProps { | |||
warning?: boolean; | |||
|
|||
/** Forms can automatically divide fields to be equal width */ | |||
widths?: SemanticWIDTHSSTRING | SemanticWIDTHSNUMBER | number | 'equal'; | |||
widths?: SemanticWIDTHS | 'equal'; |
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.
compact: ['very'], | ||
padded: ['very'], | ||
size: _.without(SUI.SIZES, 'mini', 'tiny', 'medium', 'big', 'huge', 'massive'), | ||
}, |
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.
_meta.props
removal 😄
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Added jsdoc for subcomponents.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
{...rest}
must be first.
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.
Usually, when spreading this is true. But, since rest
excludes as
and className
due to getUnhandledProps
there is no danger of overwriting. I still think it is good to move it to the first position though, 👍
@@ -873,7 +873,7 @@ export const implementsTextAlignProp = (Component, alignments = SUI.TEXT_ALIGNME | |||
_noDefaultClassNameFromProp(Component, 'textAlign', options) | |||
_noClassNameFromBoolProps(Component, 'textAlign', options) | |||
|
|||
_.each(alignments, propVal => { | |||
alignments.forEach(propVal => { |
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.
Lodash's each
will work even alignments
will not be array, we need to be more strict there.
* @param {Object} [options={}] | ||
* @param {Object} [options.requiredProps={}] Props required to render the component. | ||
* @param {Object} [options.className=propKey] The className to assert exists. | ||
*/ | ||
export const propValueOnlyToClassName = (Component, propKey, options = {}) => { | ||
export const propValueOnlyToClassName = (Component, propKey, propValues, options = {}) => { |
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.
Updated test.
@@ -19,7 +20,7 @@ describe('Image Component', () => { | |||
ShorthandComponent: Dimmer, | |||
mapValueToProps: val => ({ content: val }), | |||
}) | |||
common.implementsVerticalAlignProp(Image, 'verticalAlign') |
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.
Cruft.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Table
doesn't have justify
.
@@ -148,7 +148,7 @@ Segment.propTypes = { | |||
tertiary: PropTypes.bool, | |||
|
|||
/** Formats content to be aligned as part of a vertical group. */ | |||
textAlign: PropTypes.oneOf(SUI.TEXT_ALIGNMENTS), | |||
textAlign: PropTypes.oneOf(_.without(SUI.TEXT_ALIGNMENTS, 'justified')), |
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.
Segment
doesn't have justify
.
Current coverage is 95.89% (diff: 100%)
|
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.
Awesome, I'm so grateful for all the work you're putting into this. It is immensely helpful and much appreciated. If you weren't doing this, it wouldn't be getting done. 🎉
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, when spreading this is true. But, since rest
excludes as
and className
due to getUnhandledProps
there is no danger of overwriting. I still think it is good to move it to the first position though, 👍
* Semantic-Org/master: (111 commits) fix(docs): fix usage of arrow function (Semantic-Org#1228) fix(Icon): Incorrect definition in typings (Semantic-Org#1225) fix(Button): fix `tabIndex` in typings (Semantic-Org#1224) fix(typings): add item prop to the DropdownProps (Semantic-Org#1223) docs(examples): add missing `key` props (Semantic-Org#1220) docs(changelog): update changelog [ci skip] 0.64.4 feat(Form): add `inverted` prop (Semantic-Org#1218) fix(ComponentExample): use explicit babel presets (Semantic-Org#1219) style(Button): update typings and propTypes usage (Semantic-Org#1216) style(Embed): update typings and propTypes usage (Semantic-Org#1217) chore(package): support for jsnext:main (Semantic-Org#1210) style(Step): update typings, tests and propTypes usage (Semantic-Org#1203) fix(Portal): do not take focus after first render (Semantic-Org#1215) style(Table|mixed): update typings, tests and propTypes usage (Semantic-Org#1200) fix(Dropdown): use `item` instead of `as={Menu.Item}` (Semantic-Org#659) fix(Dropdown): respect `closeOnBlur={false}` (Semantic-Org#1148) style(Breadcrumb): update typings and propTypes usage (Semantic-Org#1209) style(Dimmer): update typings (Semantic-Org#1208) fix(Divider|FormInput): fix the broken typings (Semantic-Org#1179) ...
…ic-Org#1200) * style(Table|mixed): update typings, tests and propTypes usage * style(Table): add missing prop to typings
This PR promised to be small, but...
It contains:
Table
for fix(typings): unable to set many typical html element props #1072 & Add docs forsortable
Table andsorted
TableCell #1195;propTypes
usage for RFC: remove production propTypes, allow small custom builds #524;SemanticWIDTHS
;Table
's subcomponents;propKeyAndValueToClassName
test.