-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RNMobile] Global styles provider (#21637)
* use edit wrapper props * use context to pass wrapper styles * split to globalStyles and wrapperProps * fix import name * fix paragraph block * add default value to the wrapperProps in compose * change heading and paragraph to support other wrapperprops * rename globalStyle to mergedStyle and merge styles before passing * use wrapperProps in button edit * add some inline comments
- Loading branch information
Showing
7 changed files
with
87 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
22 changes: 22 additions & 0 deletions
22
packages/components/src/mobile/global-styles-context/index.native.js
This file contains 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,22 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createContext, useContext } from '@wordpress/element'; | ||
|
||
const GlobalStylesContext = createContext( { style: {} } ); | ||
|
||
export const useGlobalStyles = () => { | ||
const globalStyles = useContext( GlobalStylesContext ); | ||
|
||
return globalStyles; | ||
}; | ||
|
||
export const withGlobalStyles = ( WrappedComponent ) => ( props ) => ( | ||
<GlobalStylesContext.Consumer> | ||
{ ( globalStyles ) => ( | ||
<WrappedComponent { ...props } globalStyles={ globalStyles } /> | ||
) } | ||
</GlobalStylesContext.Consumer> | ||
); | ||
|
||
export default GlobalStylesContext; |