PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.2
GenerateBlocks v1.8.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 / blocks / headline / components / BlockControls.js
generateblocks / src / blocks / headline / components Last commit date
BlockControls.js 2 years ago ComponentCSS.js 4 years ago HeadlineContentRenderer.js 3 years ago InspectorAdvancedControls.js 3 years ago TagName.js 3 years ago ToolbarGroup.js 4 years ago
BlockControls.js
50 lines
1 import ToolbarGroup from './ToolbarGroup';
2 import { AlignmentToolbar, BlockControls } from '@wordpress/block-editor';
3 import isFlexItem from '../../../utils/is-flex-item';
4 import getAttribute from '../../../utils/get-attribute';
5 import typographyOptions from '../../../extend/inspector-control/controls/typography/options';
6 import getDeviceType from '../../../utils/get-device-type';
7
8 export default function HeadlineBlockControls( props ) {
9 const {
10 attributes,
11 setAttributes,
12 } = props;
13
14 const {
15 element,
16 isCaption,
17 display,
18 displayTablet,
19 displayMobile,
20 } = attributes;
21
22 const device = getDeviceType();
23
24 return (
25 <BlockControls>
26 <ToolbarGroup
27 setAttributes={ setAttributes }
28 element={ element }
29 isCaption={ isCaption }
30 />
31
32 { ! isFlexItem( { device, display, displayTablet, displayMobile } ) &&
33 <>
34 <AlignmentToolbar
35 value={ getAttribute( 'textAlign', { attributes: attributes.typography, deviceType: device } ) }
36 onChange={ ( value ) => {
37 setAttributes( {
38 typography: {
39 [ getAttribute( 'textAlign', { attributes: attributes.typography, deviceType: device }, true ) ]: value,
40 },
41 } );
42 } }
43 alignmentControls={ typographyOptions.alignments }
44 />
45 </>
46 }
47 </BlockControls>
48 );
49 }
50