Skip to content

Commit

Permalink
adding site to useGlobalStyle hook
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Apr 28, 2023
1 parent 58fa7d9 commit f72324d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/block-editor/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,18 @@ export function useGlobalStyle(
merged: mergedConfig,
base: baseConfig,
user: userConfig,
site: siteConfig,
setUserConfig,
setSiteConfig,
} = useContext( GlobalStylesContext );
const appendedPath = path ? '.' + path : '';
const finalPath = ! blockName
? `styles${ appendedPath }`
: `styles.blocks.${ blockName }${ appendedPath }`;

const setStyle = ( newValue ) => {
setUserConfig( ( currentConfig ) => {
const setConfig = source === 'site' ? setSiteConfig : setUserConfig;
setConfig( ( currentConfig ) => {
// Deep clone `currentConfig` to avoid mutating it later.
const newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );
set(
Expand Down Expand Up @@ -196,6 +199,12 @@ export function useGlobalStyle(
? getValueFromVariable( mergedConfig, blockName, rawResult )
: rawResult;
break;
case 'site':
rawResult = get( siteConfig, finalPath );
result = shouldDecodeEncode
? getValueFromVariable( mergedConfig, blockName, rawResult )
: rawResult;
break;
case 'base':
rawResult = get( baseConfig, finalPath );
result = shouldDecodeEncode
Expand Down

0 comments on commit f72324d

Please sign in to comment.