This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
feat(utils): add wrapper for the createComponent function #503
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bbb35cb
-introduced createStardustComponent method
200b1d1
-renamed export
25252ee
-addressed comments
731ce0f
-addressed comments
df34917
-exported types, refactored typings
73b3286
-exported types from function file
2b78ad5
-updated params for the render method inside the CreateStardustCompon…
eb18bf8
-addressed comments: lodash , themes imports
37ec45a
-changed displayName to be required
0739bfb
Merge branch 'master' into feat/stardust-component
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import createComponentInternal from './createComponent' | ||
import * as React from 'react' | ||
import * as _ from 'lodash' | ||
import { ComponentSlotClasses } from '../themes/types' | ||
|
||
export interface RenderStardustResultConfig { | ||
mnajdova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
classes: ComponentSlotClasses | ||
rtl: boolean | ||
} | ||
|
||
export interface CreateStardustComponentConfig<P> { | ||
displayName: string | ||
render: (props: P & { stardust: RenderStardustResultConfig }) => React.ReactNode | ||
} | ||
|
||
const createComponent = <P extends {} = {}, S extends {} = {}>({ | ||
displayName, | ||
render, | ||
}: CreateStardustComponentConfig<P>): React.SFC<P> => { | ||
return createComponentInternal<P, S>({ | ||
displayName, | ||
mnajdova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
render: (config, props) => { | ||
const filteredConfig = _.pick(config, ['classes', 'rtl']) | ||
return render(Object.assign({ stardust: filteredConfig }, props)) | ||
mnajdova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}) | ||
} | ||
|
||
export default createComponent |
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
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.
Uh oh!
There was an error while loading. Please reload this page.