This repository was archived by the owner on Mar 4, 2020. It is now read-only.
feat(utils): add wrapper for the createComponent function #503
Merged
feat(utils): add wrapper for the createComponent function #503
Conversation
Contributor
|
@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.
|
kuzhelov
reviewed
Nov 20, 2018
kuzhelov
reviewed
Nov 20, 2018
kuzhelov
reviewed
Nov 20, 2018
added 2 commits
November 20, 2018 17:08
…entConfig -updated changelog
mnajdova
commented
Nov 20, 2018
levithomason
approved these changes
Nov 21, 2018
Member
levithomason
left a comment
There was a problem hiding this comment.
Minor changes requested, no blockers from me
Member
|
Next up we'll publish some docs and examples showing how to use this. There should be a new Guide for "Custom Components". |
kuzhelov
reviewed
Nov 21, 2018
kuzhelov
approved these changes
Nov 21, 2018
added 3 commits
November 21, 2018 18:29
alinais
approved these changes
Nov 21, 2018
Collaborator
|
Sweet! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
StyledButtoncomponent 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