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

[pull] trunk from WordPress:trunk #169

Merged
merged 3 commits into from
Jan 17, 2025
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
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ Displays the contents of a post or page. ([Source](https://github.com/WordPress/

- **Name:** core/post-content
- **Category:** theme
- **Supports:** align (full, wide), background (backgroundImage, backgroundSize), color (background, gradients, link, text), dimensions (minHeight), layout, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, wide), background (backgroundImage, backgroundSize), color (background, gradients, heading, link, text), dimensions (minHeight), layout, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~

## Date

Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-content/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"color": {
"gradients": true,
"heading": true,
"link": true,
"__experimentalDefaultControls": {
"background": false,
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-terms/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default function PostTermsEdit( {
key={ postTerm.id }
href={ postTerm.link }
onClick={ ( event ) => event.preventDefault() }
rel="tag"
>
{ decodeEntities( postTerm.name ) }
</a>
Expand Down
173 changes: 99 additions & 74 deletions packages/block-library/src/search/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import {
ToolbarGroup,
ToolbarButton,
ResizableBox,
PanelBody,
__experimentalVStack as VStack,
__experimentalUseCustomUnits as useCustomUnits,
__experimentalUnitControl as UnitControl,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { useInstanceId } from '@wordpress/compose';
import { Icon, search } from '@wordpress/icons';
Expand All @@ -54,6 +55,7 @@ import {
MIN_WIDTH,
isPercentageUnit,
} from './utils.js';
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

// Used to calculate border radius adjustment to avoid "fat" corners when
// button is placed inside wrapper.
Expand Down Expand Up @@ -370,6 +372,7 @@ export default function SearchEdit( {
</>
);
};
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

const controls = (
<>
Expand Down Expand Up @@ -408,79 +411,101 @@ export default function SearchEdit( {
</BlockControls>

<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<VStack
className="wp-block-search__inspector-controls"
spacing={ 4 }
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( {
width: undefined,
widthUnit: undefined,
} );
} }
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
hasValue={ () => !! width }
label={ __( 'Width' ) }
onDeselect={ () => {
setAttributes( {
width: undefined,
widthUnit: undefined,
} );
} }
isShownByDefault
>
<UnitControl
__next40pxDefaultSize
label={ __( 'Width' ) }
id={ unitControlInputId } // unused, kept for backwards compatibility
min={
isPercentageUnit( widthUnit ) ? 0 : MIN_WIDTH
}
max={
isPercentageUnit( widthUnit ) ? 100 : undefined
}
step={ 1 }
onChange={ ( newWidth ) => {
const parsedNewWidth =
newWidth === ''
? undefined
: parseInt( newWidth, 10 );
setAttributes( {
width: parsedNewWidth,
} );
} }
onUnitChange={ ( newUnit ) => {
setAttributes( {
width:
'%' === newUnit
? PC_WIDTH_DEFAULT
: PX_WIDTH_DEFAULT,
widthUnit: newUnit,
} );
} }
__unstableInputWidth="80px"
value={ `${ width }${ widthUnit }` }
units={ units }
/>
<ToggleGroupControl
label={ __( 'Percentage Width' ) }
value={
PERCENTAGE_WIDTHS.includes( width ) &&
widthUnit === '%'
? width
: undefined
}
hideLabelFromVision
onChange={ ( newWidth ) => {
setAttributes( {
width: newWidth,
widthUnit: '%',
} );
} }
isBlock
__next40pxDefaultSize
__nextHasNoMarginBottom
>
{ PERCENTAGE_WIDTHS.map( ( widthValue ) => {
return (
<ToggleGroupControlOption
key={ widthValue }
value={ widthValue }
label={ sprintf(
/* translators: Percentage value. */
__( '%d%%' ),
widthValue
) }
/>
);
} ) }
</ToggleGroupControl>
</VStack>
</PanelBody>
<VStack>
<UnitControl
__next40pxDefaultSize
label={ __( 'Width' ) }
id={ unitControlInputId } // Unused, kept for backwards compatibility
min={
isPercentageUnit( widthUnit )
? 0
: MIN_WIDTH
}
max={
isPercentageUnit( widthUnit )
? 100
: undefined
}
step={ 1 }
onChange={ ( newWidth ) => {
const parsedNewWidth =
newWidth === ''
? undefined
: parseInt( newWidth, 10 );
setAttributes( {
width: parsedNewWidth,
} );
} }
onUnitChange={ ( newUnit ) => {
setAttributes( {
width:
'%' === newUnit
? PC_WIDTH_DEFAULT
: PX_WIDTH_DEFAULT,
widthUnit: newUnit,
} );
} }
__unstableInputWidth="80px"
value={ `${ width }${ widthUnit }` }
units={ units }
/>
<ToggleGroupControl
label={ __( 'Percentage Width' ) }
value={
PERCENTAGE_WIDTHS.includes( width ) &&
widthUnit === '%'
? width
: undefined
}
hideLabelFromVision
onChange={ ( newWidth ) => {
setAttributes( {
width: newWidth,
widthUnit: '%',
} );
} }
isBlock
__next40pxDefaultSize
__nextHasNoMarginBottom
>
{ PERCENTAGE_WIDTHS.map( ( widthValue ) => {
return (
<ToggleGroupControlOption
key={ widthValue }
value={ widthValue }
label={ sprintf(
/* translators: Percentage value. */
__( '%d%%' ),
widthValue
) }
/>
);
} ) }
</ToggleGroupControl>
</VStack>
</ToolsPanelItem>
</ToolsPanel>
</InspectorControls>
</>
);
Expand Down
Loading