PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.2
GenerateBlocks v2.0.2
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / components / TagNameToolbar / TagNameToolbar.jsx
generateblocks / src / components / TagNameToolbar Last commit date
TagNameIcon.jsx 1 year ago TagNameToolbar.jsx 1 year ago
TagNameToolbar.jsx
70 lines
1 import { TagNameIcon } from './TagNameIcon';
2 import { __ } from '@wordpress/i18n';
3 import { ToolbarGroup } from '@wordpress/components';
4 import { BlockControls } from '@wordpress/block-editor';
5
6 export function TagNameToolbar( { label, onChange, tagName } ) {
7 const options = [
8 {
9 label: __( 'Heading 1', 'generateblocks' ),
10 value: 'h1',
11 },
12 {
13 label: __( 'Heading 2', 'generateblocks' ),
14 value: 'h2',
15 },
16 {
17 label: __( 'Heading 3', 'generateblocks' ),
18 value: 'h3',
19 },
20 {
21 label: __( 'Heading 4', 'generateblocks' ),
22 value: 'h4',
23 },
24 {
25 label: __( 'Heading 5', 'generateblocks' ),
26 value: 'h5',
27 },
28 {
29 label: __( 'Heading 6', 'generateblocks' ),
30 value: 'h6',
31 },
32 {
33 label: __( 'Paragraph', 'generateblocks' ),
34 value: 'p',
35 },
36 {
37 label: __( 'Div', 'generateblocks' ),
38 value: 'div',
39 },
40 {
41 label: __( 'Span', 'generateblocks' ),
42 value: 'span',
43 },
44 ];
45
46 if ( ! options.find( ( option ) => option.value === tagName ) ) {
47 return null;
48 }
49
50 const controls = options.map( ( option ) => {
51 return {
52 isActive: option.value === tagName,
53 icon: <TagNameIcon level={ option.value } />,
54 title: option.label,
55 onClick: () => onChange( option.value ),
56 };
57 } );
58
59 return (
60 <BlockControls>
61 <ToolbarGroup
62 isCollapsed={ true }
63 icon={ <TagNameIcon level={ tagName } /> }
64 label={ label }
65 controls={ controls }
66 />
67 </BlockControls>
68 );
69 }
70