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

Post Featured Image: Use the 'ResolutionTool' component #68294

Merged
merged 2 commits into from
Dec 26, 2024
Merged
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 @@ -12,10 +12,18 @@ import {
} from '@wordpress/components';
import {
useSettings,
privateApis as blockEditorPrivateApis,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import { unlock } from '../lock-unlock';

const { ResolutionTool } = unlock( blockEditorPrivateApis );

const SCALE_OPTIONS = (
<>
<ToggleGroupControlOption
Expand Down Expand Up @@ -223,30 +231,19 @@ const DimensionControls = ( {
</ToolsPanelItem>
) }
{ !! imageSizeOptions.length && (
<ToolsPanelItem
hasValue={ () => !! sizeSlug }
label={ __( 'Resolution' ) }
onDeselect={ () =>
setAttributes( { sizeSlug: undefined } )
<ResolutionTool
panelId={ clientId }
value={ sizeSlug }
defaultValue={ DEFAULT_SIZE }
options={ imageSizeOptions }
onChange={ ( nextSizeSlug ) =>
setAttributes( { sizeSlug: nextSizeSlug } )
}
isShownByDefault={ false }
resetAllFilter={ () => ( {
sizeSlug: undefined,
sizeSlug: DEFAULT_SIZE,
} ) }
isShownByDefault={ false }
panelId={ clientId }
>
<SelectControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Resolution' ) }
value={ sizeSlug || DEFAULT_SIZE }
options={ imageSizeOptions }
onChange={ ( nextSizeSlug ) =>
setAttributes( { sizeSlug: nextSizeSlug } )
}
help={ __( 'Select the size of the source image.' ) }
/>
</ToolsPanelItem>
/>
) }
</>
);
Expand Down
Loading