Skip to content

Commit

Permalink
Simplify the settings merging hook
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Feb 15, 2023
1 parent d5b79c6 commit 4fdbd9f
Showing 1 changed file with 31 additions and 53 deletions.
84 changes: 31 additions & 53 deletions packages/block-editor/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,61 +249,39 @@ export function useSettingsForBlockElement(
};
}

if ( ! supportedStyles.includes( 'lineHeight' ) ) {
updatedSettings.typography = {
...updatedSettings.typography,
lineHeight: false,
};
}

if ( ! supportedStyles.includes( 'fontStyle' ) ) {
updatedSettings.typography = {
...updatedSettings.typography,
fontStyle: false,
};
}

if ( ! supportedStyles.includes( 'fontWeight' ) ) {
updatedSettings.typography = {
...updatedSettings.typography,
fontWeight: false,
};
}

if ( ! supportedStyles.includes( 'letterSpacing' ) ) {
updatedSettings.typography = {
...updatedSettings.typography,
letterSpacing: false,
};
}

if ( ! supportedStyles.includes( 'textTransform' ) ) {
updatedSettings.typography = {
...updatedSettings.typography,
textTransform: false,
};
}

if ( ! supportedStyles.includes( 'textDecoration' ) ) {
updatedSettings.typography = {
...updatedSettings.typography,
textDecoration: false,
};
}
[
'lineHeight',
'fontStyle',
'fontWeight',
'letterSpacing',
'textTransform',
'textDecoration',
].forEach( ( key ) => {
if ( ! supportedStyles.includes( key ) ) {
updatedSettings.typography = {
...updatedSettings.typography,
[ key ]: false,
};
}
} );

if ( ! supportedStyles.includes( 'contentSize' ) ) {
updatedSettings.layout = {
...updatedSettings.layout,
contentSize: false,
};
}
[ 'contentSize', 'wideSize' ].forEach( ( key ) => {
if ( ! supportedStyles.includes( key ) ) {
updatedSettings.layout = {
...updatedSettings.layout,
[ key ]: false,
};
}
} );

if ( ! supportedStyles.includes( 'wideSize' ) ) {
updatedSettings.layout = {
...updatedSettings.layout,
wideSize: false,
};
}
[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {
if ( ! supportedStyles.includes( key ) ) {
updatedSettings.spacing = {
...updatedSettings.spacing,
[ key ]: false,
};
}
} );

if ( ! supportedStyles.includes( 'padding' ) ) {
updatedSettings.spacing = {
Expand Down

0 comments on commit 4fdbd9f

Please sign in to comment.