-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Page List: Move modal to it's own file
- Loading branch information
Showing
2 changed files
with
58 additions
and
51 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/block-library/src/page-list/convert-to-links-modal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { BlockControls } from '@wordpress/block-editor'; | ||
import { ToolbarButton, Button, Modal } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { useState } from '@wordpress/element'; | ||
|
||
export const convertDescription = __( | ||
'This menu is automatically kept in sync with pages on your site. You can manage the menu yourself by clicking "Edit" below.' | ||
); | ||
|
||
export function ConvertToLinksModal( { onClick, disabled } ) { | ||
const [ isOpen, setOpen ] = useState( false ); | ||
const openModal = () => setOpen( true ); | ||
const closeModal = () => setOpen( false ); | ||
|
||
return ( | ||
<> | ||
<BlockControls group="other"> | ||
<ToolbarButton title={ __( 'Edit' ) } onClick={ openModal }> | ||
{ __( 'Edit' ) } | ||
</ToolbarButton> | ||
</BlockControls> | ||
{ isOpen && ( | ||
<Modal | ||
onRequestClose={ closeModal } | ||
title={ __( 'Edit this menu' ) } | ||
className={ 'wp-block-page-list-modal' } | ||
aria={ { | ||
describedby: 'wp-block-page-list-modal__description', | ||
} } | ||
> | ||
<p id={ 'wp-block-page-list-modal__description' }> | ||
{ convertDescription } | ||
</p> | ||
<div className="wp-block-page-list-modal-buttons"> | ||
<Button variant="tertiary" onClick={ closeModal }> | ||
{ __( 'Cancel' ) } | ||
</Button> | ||
<Button | ||
variant="primary" | ||
disabled={ disabled } | ||
onClick={ onClick } | ||
> | ||
{ __( 'Edit' ) } | ||
</Button> | ||
</div> | ||
</Modal> | ||
) } | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters