forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
1,387 additions
and
952 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
78 changes: 78 additions & 0 deletions
78
packages/block-editor/src/components/global-styles/README.md
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,78 @@ | ||
# Global Styles | ||
|
||
This folder contains all the necessary APIs to manipulate the global styles data. It can be potentially extracted to its own package. | ||
|
||
# Available public APIs | ||
|
||
## useGlobalStylesReset | ||
|
||
A React hook used to retrieve whether the Global Styles have been edited and a callback to reset to the default theme values. | ||
|
||
```js | ||
import { useGlobalStylesReset } from '@wordpress/block-editor'; | ||
|
||
function MyComponent() { | ||
const [ canReset, reset ] = useGlobalStylesReset(); | ||
|
||
return canReset | ||
? <Button onClick={ () => reset() }>Reset</Button> | ||
: null; | ||
} | ||
``` | ||
|
||
## useGlobalStylesOutput | ||
|
||
A React hook used to retrieve the styles array and settings to provide for block editor instances based on the current global styles. | ||
|
||
```js | ||
import { useGlobalStylesOutput, BlockEditorProvider, BlockList } from '@wordpress/block-editor'; | ||
|
||
function MyComponent() { | ||
const [ styles, settings ] = useGlobalStylesOutput(); | ||
|
||
return <BlockEditorProvider settings={{ | ||
styles, | ||
__experimentalFeatures: settings | ||
}}> | ||
<BlockList /> | ||
</BlockEditorProvider> | ||
} | ||
``` | ||
|
||
## useGlobalStyle | ||
|
||
A react hook used to retrieve the style applied to a given context. | ||
|
||
```js | ||
import { useGlobalStyle } from '@wordpress/block-editor'; | ||
|
||
function MyComponent() { | ||
// Text color for the site root. | ||
const [ color, setColor ] = useGlobalStyle( 'color.text' ); | ||
|
||
// The user modified color for the core paragraph block. | ||
const [ pColor, setPColor ] = useGlobalStyle( 'color.text', 'core/paragraph', 'user' ); | ||
|
||
return "Something"; | ||
} | ||
``` | ||
|
||
## useGlobalSetting | ||
|
||
A react hook used to retrieve the setting applied to a given context. | ||
|
||
```js | ||
import { useGlobalSetting } from '@wordpress/block-editor'; | ||
|
||
function MyComponent() { | ||
// The default color palette. | ||
const [ colorPalette, setColorPalette ] = useGlobalSetting( 'color.palette' ); | ||
|
||
// The base (theme + core) color palette for the paragraph block, | ||
// ignoring user provided palette. | ||
// If the palette is not defined for the paragraph block, the root one is returned. | ||
const [ pColor, setPColor ] = useGlobalSetting( 'color.palette', 'core/paragraph', 'base' ); | ||
|
||
return "Something"; | ||
} | ||
``` |
File renamed without changes.
Oops, something went wrong.