Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles: Rename settings & userSettings props to value & inheritedValue respectively in ImageSettingsPanel #54593

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import {
} from '@wordpress/components';
import { __, _x } from '@wordpress/i18n';

export function useHasImageSettingsPanel( name, settings, userSettings ) {
// Note: If lightbox userSettings exists, that means
// they were defined via the Global Styles UI and
// will NOT be a boolean value or contain the `allowEditing`
// property, so we should show the settings panel in those cases.
export function useHasImageSettingsPanel( name, value, inheritedValue ) {
// Note: If lightbox `value` exists, that means it was
// defined via the the Global Styles UI and will NOT
// be a boolean value or contain the `allowEditing` property,
// so we should show the settings panel in those cases.
return (
( name === 'core/image' && settings?.lightbox?.allowEditing ) ||
!! userSettings?.lightbox
( name === 'core/image' && inheritedValue?.lightbox?.allowEditing ) ||
!! value?.lightbox
);
}

export default function ImageSettingsPanel( {
onChange,
userSettings,
settings,
value,
inheritedValue,
panelId,
} ) {
const resetLightbox = () => {
Expand All @@ -37,8 +37,8 @@ export default function ImageSettingsPanel( {

let lightboxChecked = false;

if ( settings?.lightbox?.enabled ) {
lightboxChecked = settings.lightbox.enabled;
if ( inheritedValue?.lightbox?.enabled ) {
lightboxChecked = inheritedValue.lightbox.enabled;
}

return (
Expand All @@ -53,7 +53,7 @@ export default function ImageSettingsPanel( {
// contains the core/theme values for the lightbox and we want to show the
// "RESET" button ONLY when the user has explicitly set a value in the
// Global Styles.
hasValue={ () => !! userSettings?.lightbox }
hasValue={ () => !! value?.lightbox }
label={ __( 'Expand on Click' ) }
onDeselect={ resetLightbox }
isShownByDefault={ true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function ScreenBlock( { name, variation } ) {
const hasFiltersPanel = useHasFiltersPanel( settings );
const hasImageSettingsPanel = useHasImageSettingsPanel(
name,
settings,
userSettings
userSettings,
settings
);
const hasVariationsPanel = !! blockVariations?.length && ! variation;
const { canEditCSS } = useSelect( ( select ) => {
Expand Down Expand Up @@ -297,8 +297,8 @@ function ScreenBlock( { name, variation } ) {
{ hasImageSettingsPanel && (
<ImageSettingsPanel
onChange={ onChangeLightbox }
userSettings={ userSettings }
settings={ settings }
value={ userSettings }
inheritedValue={ settings }
/>
) }

Expand Down
Loading