-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathsearch-create-button.js
67 lines (61 loc) · 1.31 KB
/
search-create-button.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
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { Icon, plus } from '@wordpress/icons';
export const LinkControlSearchCreate = ( {
searchTerm,
onClick,
itemProps,
isSelected,
buttonText,
} ) => {
if ( ! searchTerm ) {
return null;
}
let text;
if ( buttonText ) {
text =
typeof buttonText === 'function'
? buttonText( searchTerm )
: buttonText;
} else {
text = createInterpolateElement(
sprintf(
/* translators: %s: search term. */
__( 'Create: <mark>%s</mark>' ),
searchTerm
),
{ mark: <mark /> }
);
}
return (
<Button
{ ...itemProps }
className={ classnames(
'block-editor-link-control__search-create block-editor-link-control__search-item',
{
'is-selected': isSelected,
}
) }
onClick={ onClick }
>
<Icon
className="block-editor-link-control__search-item-icon"
icon={ plus }
/>
<span className="block-editor-link-control__search-item-header">
<span className="block-editor-link-control__search-item-title">
{ text }
</span>
</span>
</Button>
);
};
export default LinkControlSearchCreate;