Skip to content

Commit

Permalink
Client: update getters in GS provider
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Apr 15, 2021
1 parent 4838111 commit ef78b66
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/edit-site/src/components/editor/global-styles-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ export default function GlobalStylesProvider( { children, baseStyles } ) {
name: ROOT_BLOCK_NAME,
},
contexts,
getSetting: ( context, path ) =>
get( userStyles?.settings?.[ context ], path ),
getSetting: ( context, path ) => {
const fullPath =
context === ROOT_BLOCK_NAME
? path
: `blocks.${ context }.${ path }`;
get( userStyles?.settings, fullPath );
},
setSetting: ( context, path, newValue ) => {
const newContent = { ...userStyles };
let contextSettings = newContent?.settings?.[ context ];
Expand All @@ -188,10 +193,13 @@ export default function GlobalStylesProvider( { children, baseStyles } ) {
const styleOrigin =
'user' === origin ? userStyles : mergedStyles;

const value = get(
styleOrigin?.styles?.[ context ],
STYLE_PROPERTY[ propertyName ].value
);
const path = STYLE_PROPERTY[ propertyName ].value;
const fullPath =
context === ROOT_BLOCK_NAME
? path
: `blocks.${ context }.${ path }`;

const value = get( styleOrigin?.styles, fullPath );
return getValueFromVariable( mergedStyles, context, value );
},
setStyle: ( context, propertyName, newValue ) => {
Expand Down

0 comments on commit ef78b66

Please sign in to comment.