Skip to content
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
147 changes: 96 additions & 51 deletions packages/block-library/src/post-navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import clsx from 'clsx';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
ToggleControl,
SelectControl,
PanelBody,
} from '@wordpress/components';
import {
InspectorControls,
Expand All @@ -25,6 +26,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 Down Expand Up @@ -94,73 +100,112 @@ export default function PostNavigationLinkEdit( {
return [ selectOption, ...taxonomyOptions ];
};

const dropdownMenuProps = useToolsPanelDropdownMenuProps();

return (
<>
<InspectorControls>
<PanelBody>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( {
showTitle: false,
linkLabel: false,
arrow: 'none',
} );
} }
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
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,
} )
isShownByDefault
hasValue={ () => showTitle }
onDeselect={ () =>
setAttributes( { showTitle: false } )
}
/>
{ showTitle && (
>
<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
label={ __(
'Include the label as part of the link'
) }
isShownByDefault
hasValue={ () => !! linkLabel }
onDeselect={ () =>
setAttributes( { linkLabel: false } )
}
>
<ToggleControl
__nextHasNoMarginBottom
label={ __(
'Include the label as part of the link'
) }
checked={ !! linkLabel }
onChange={ () =>
setAttributes( {
linkLabel: ! linkLabel,
} )
}
/>
</ToolsPanelItem>
) }
<ToggleGroupControl
__next40pxDefaultSize
__nextHasNoMarginBottom
<ToolsPanelItem
label={ __( 'Arrow' ) }
value={ arrow }
onChange={ ( value ) => {
setAttributes( { arrow: value } );
} }
help={ __(
'A decorative arrow for the next and previous link.'
) }
isBlock
isShownByDefault
hasValue={ () => arrow !== 'none' }
onDeselect={ () => setAttributes( { arrow: 'none' } ) }
>
<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
Loading