Skip to content

Commit

Permalink
Make selector for theme spacing values more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Apr 9, 2021
1 parent 24ffb30 commit f6668f7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/edit-site/src/components/sidebar/spacing-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,24 @@ function filterValuesBySides( values, sides ) {
return filteredValues;
}

export default function SpacingPanel( { context, getStyle, setStyle } ) {
const { name } = context;
const showPaddingControl = useHasPadding( context );
const units = useCustomUnits( { contextName: name } );

const paddingValues = getStyle( name, 'padding' );
const themePaddingValues = useSelect(
function useThemeValues( name, feature ) {
return useSelect(
( select ) => {
const baseStyles = select( editSiteStore ).getSettings()
.__experimentalGlobalStylesBaseStyles;
return baseStyles?.styles?.[ name ]?.spacing?.padding;
return baseStyles?.styles?.[ name ]?.spacing?.[ feature ];
},
[ name ]
[ name, feature ]
);
}

export default function SpacingPanel( { context, getStyle, setStyle } ) {
const { name } = context;
const showPaddingControl = useHasPadding( context );
const units = useCustomUnits( { contextName: name } );

const paddingValues = getStyle( name, 'padding' );
const themePaddingValues = useThemeValues( name, 'padding' );
const paddingSides = useCustomSides( name, 'padding' );

const setPaddingValues = ( newPaddingValues ) => {
Expand Down

0 comments on commit f6668f7

Please sign in to comment.