-
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
Feature/add sd item #65
Conversation
static propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
description: PropTypes.node, |
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.
Need to add utility for adding warning if children exists.
029fa46
to
41b6509
Compare
🍂 |
}, | ||
}; | ||
|
||
export default customPropTypes; |
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.
new utility to be used with customPropType validation and checking.
if (props[propName] && props[exclusiveProp]) { | ||
throw new Error( | ||
`\`${componentName}\` should only have one of type \`${propName}\` or \`${exclusiveProp}\` not both.` | ||
); |
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 didn't think of throwing error messages with ticks. nice!
🍂 |
'item', | ||
); | ||
return ( | ||
<div {...this.props} 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.
Component props used for Stardust purposes should be removed from this.props
before spreading. Only the user's props should be spread. Since this component takes in:
children
className
description
extra
heading
image
meta
We should remove those props before spreading them onto the Item
. Otherwise, we'll be spreading components and other unintended things:
let props = _.clone(this.props);
delete props.children;
delete props.className;
delete props.description;
delete props.extra;
delete props.heading;
delete props.image;
delete props.meta;
// then
<div {...props} ...
Thinking about this, I believe we should always remove static PropTypes
props, except for static defaultProps
before spreading. This way we only spread "extra" user defined props and defaultProps the user didn't specify. Linking #69 spreadable props util here for this reference.
For now, add the clone/delete step before spreading.
import faker from 'faker'; | ||
|
||
describe('Item', () => { | ||
it('has children', () => { |
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.
Small semantic request here. This test isn't testing that Item has children
but that Item renders children
.
Good to merge after hitting the last to comments: Also, can close #68. Nice work on that, and bundling the 👍 ⚡ |
2 New SD components for the Semantic UI Item view:
EDIT
PR also addresses GH Issue #68