Skip to content
Closed
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
139 changes: 88 additions & 51 deletions packages/block-library/src/post-navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
ToggleControl,
SelectControl,
PanelBody,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import {
InspectorControls,
Expand All @@ -24,6 +25,11 @@ import { __, _x } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

export default function PostNavigationLinkEdit( {
context: { postType },
attributes: {
Expand All @@ -47,6 +53,7 @@ export default function PostNavigationLinkEdit( {
};

const displayArrow = arrowMap[ arrow ];
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

if ( showTitle ) {
placeholder = isNext
Expand Down Expand Up @@ -94,70 +101,100 @@ export default function PostNavigationLinkEdit( {
return (
<>
<InspectorControls>
<PanelBody>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanel
label={ __( 'Settings' ) }
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
Comment thread
rinkalpagdar marked this conversation as resolved.
hasValue={ () => !! showTitle }
label={ __( 'Display the title as a link' ) }
help={ __(
'If you have entered a custom label, it will be prepended before the title.'
) }
checked={ !! showTitle }
onChange={ () =>
setAttributes( {
showTitle: ! showTitle,
} )
onDeselect={ () =>
setAttributes( { showTitle: false } )
}
/>
{ showTitle && (
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __(
'Include the label as part of the link'
label={ __( 'Display the title as a link' ) }
help={ __(
'If you have entered a custom label, it will be prepended before the title.'
) }
checked={ !! linkLabel }
checked={ !! showTitle }
onChange={ () =>
setAttributes( {
linkLabel: ! linkLabel,
showTitle: ! showTitle,
} )
}
/>
</ToolsPanelItem>
{ showTitle && (
<ToolsPanelItem
hasValue={ () => !! linkLabel }
label={ __(
'Include the label as part of the link'
) }
onDeselect={ () =>
setAttributes( { linkLabel: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __(
'Include the label as part of the link'
) }
checked={ !! linkLabel }
onChange={ () =>
setAttributes( {
linkLabel: ! linkLabel,
} )
}
/>
</ToolsPanelItem>
) }
<ToggleGroupControl
__next40pxDefaultSize
__nextHasNoMarginBottom
<ToolsPanelItem
hasValue={ () => arrow !== 'none' }
label={ __( 'Arrow' ) }
value={ arrow }
onChange={ ( value ) => {
setAttributes( { arrow: value } );
} }
help={ __(
'A decorative arrow for the next and previous link.'
) }
isBlock
onDeselect={ () => setAttributes( { arrow: 'none' } ) }
isShownByDefault
>
<ToggleGroupControlOption
value="none"
label={ _x(
'None',
'Arrow option for Next/Previous link'
) }
/>
<ToggleGroupControlOption
value="arrow"
label={ _x(
'Arrow',
'Arrow option for Next/Previous link'
) }
/>
<ToggleGroupControlOption
value="chevron"
label={ _x(
'Chevron',
'Arrow option for Next/Previous link'
<ToggleGroupControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Arrow' ) }
value={ arrow }
onChange={ ( value ) => {
setAttributes( { arrow: value } );
} }
help={ __(
'A decorative arrow for the next and previous link.'
) }
/>
</ToggleGroupControl>
</PanelBody>
isBlock
>
<ToggleGroupControlOption
value="none"
label={ _x(
'None',
'Arrow option for Next/Previous link'
) }
/>
<ToggleGroupControlOption
value="arrow"
label={ _x(
'Arrow',
'Arrow option for Next/Previous link'
) }
/>
<ToggleGroupControlOption
value="chevron"
label={ _x(
'Chevron',
'Arrow option for Next/Previous link'
) }
/>
</ToggleGroupControl>
</ToolsPanelItem>
</ToolsPanel>
</InspectorControls>
<InspectorControls group="advanced">
<SelectControl
Expand Down