Skip to content
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

Merged
merged 2 commits into from
Jan 24, 2017

Conversation

layershifter
Copy link
Member

This PR promised to be small, but...

It contains:

@@ -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';
Copy link
Member Author

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'),
},
Copy link
Member Author

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.
*/
Copy link
Member Author

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} />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{...rest} must be first.

Copy link
Member

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 => {
Copy link
Member Author

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 = {}) => {
Copy link
Member Author

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')
Copy link
Member Author

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')),
Copy link
Member Author

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')),
Copy link
Member Author

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.

@codecov-io
Copy link

Current coverage is 95.89% (diff: 100%)

No coverage report found for master at af12695.

Powered by Codecov. Last update af12695...515878b

Copy link
Member

@levithomason levithomason left a 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} />
Copy link
Member

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, 👍

@levithomason levithomason merged commit efd079b into master Jan 24, 2017
@levithomason levithomason deleted the style/table-typings branch January 24, 2017 16:50
DomiR added a commit to DomiR/Semantic-UI-React that referenced this pull request Jan 26, 2017
* 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)
  ...
harel pushed a commit to harel/Semantic-UI-React that referenced this pull request Feb 18, 2017
…ic-Org#1200)

* style(Table|mixed): update typings, tests and propTypes usage

* style(Table): add missing prop to typings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants