-
Notifications
You must be signed in to change notification settings - Fork 54
feat(utils): add wrapper for the createComponent function #503
Conversation
@mnajdova, please, note that example's code provided in description could be simplified: const StyledButton = createComponent({
displayName: 'MyStyledButton',
render(stardust, props) {
const { classes } = stardust
// note that we should respect client's classes passed as well
return (<button className={cx(props.className, classes.root)} {...props} />)
},
}) |
Codecov Report
@@ Coverage Diff @@
## master #503 +/- ##
==========================================
+ Coverage 88.41% 88.42% +0.01%
==========================================
Files 42 42
Lines 1450 1452 +2
Branches 186 186
==========================================
+ Hits 1282 1284 +2
Misses 163 163
Partials 5 5
Continue to review full report at Codecov.
|
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.
left comments
…entConfig -updated changelog
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.
Minor changes requested, no blockers from me
Next up we'll publish some docs and examples showing how to use this. There should be a new Guide for "Custom Components". |
Sweet! |
Introducing createComponent functionality as part of the public API in Stardust
This PR aims to fix #498 by adding a wrapper around the internal createComponent function. The API for the function looks like this:
Only the bits related to the styles are added in the config of the component.
Usage example
Definition of the custom component
The createComponent function should be used for defining custom components in the following way:
Example usage of the custom component
Some example usages of the
StyledButton
component would be:Using styles and accessing the theme from the Provider
Using styles and accessing the props as they would use with some Stardust component
Theming support