/
navigation-menu-name-modal.js
69 lines (67 loc) · 1.33 KB
/
navigation-menu-name-modal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* WordPress dependencies
*/
import {
Button,
Flex,
FlexItem,
Modal,
TextControl,
} from '@wordpress/components';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
export default function NavigationMenuNameModal( {
title,
finishButtonText = __( 'Create' ),
onFinish,
onRequestClose,
value = '',
} ) {
const [ name, setName ] = useState( value );
return (
<Modal
title={ title }
closeLabel={ __( 'Cancel' ) }
onRequestClose={ onRequestClose }
overlayClassName="wp-block-template-part__placeholder-create-new__title-form"
>
<form
onSubmit={ ( event ) => {
event.preventDefault();
onFinish( name );
} }
>
<TextControl
label={ __( 'Name' ) }
value={ name }
onChange={ setName }
/>
<Flex
className="wp-block-template-part__placeholder-create-new__title-form-actions"
justify="flex-end"
>
<FlexItem>
<Button
variant="secondary"
onClick={ () => {
onRequestClose();
} }
>
{ __( 'Cancel' ) }
</Button>
</FlexItem>
<FlexItem>
<Button
variant="primary"
type="submit"
disabled={ ! name.length }
aria-disabled={ ! name.length }
>
{ finishButtonText }
</Button>
</FlexItem>
</Flex>
</form>
</Modal>
);
}