PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.0
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 / extend / inspector-control / controls / layout / components / ThemeWidth.js
generateblocks / src / extend / inspector-control / controls / layout / components Last commit date
Display.js 2 years ago FlexDirection.js 3 years ago LayoutCSS.js 3 years ago LayoutControl.js 3 years ago ThemeWidth.js 2 years ago ZIndex.js 3 years ago editor.scss 3 years ago
ThemeWidth.js
68 lines
1 import { BaseControl, Button, ButtonGroup, Tooltip } from '@wordpress/components';
2 import { __ } from '@wordpress/i18n';
3 import { alignNone, stretchWide, stretchFullWidth } from '@wordpress/icons';
4 import { useSelect } from '@wordpress/data';
5 import { store as blockEditorStore, useSetting } from '@wordpress/block-editor';
6
7 export default function ThemeWidth( { value, onChange } ) {
8 const hasWideSize = useSetting( 'layout.wideSize' );
9 const { themeSupportsAlignWide } = useSelect(
10 ( select ) => {
11 const { getSettings } = select( blockEditorStore );
12 return {
13 themeSupportsAlignWide: getSettings()?.alignWide,
14 };
15 },
16 []
17 );
18
19 if ( ! themeSupportsAlignWide && ! hasWideSize ) {
20 return null;
21 }
22
23 const options = [
24 {
25 label: __( 'Default', 'generateblocks' ),
26 value: '',
27 icon: alignNone,
28 },
29 {
30 label: __( 'Wide', 'generateblocks' ),
31 value: 'wide',
32 icon: stretchWide,
33 },
34 {
35 label: __( 'Full', 'generateblocks' ),
36 value: 'full',
37 icon: stretchFullWidth,
38 },
39 ];
40
41 return (
42 <BaseControl
43 label={ __( 'Block Alignment', 'generateblocks' ) }
44 id="gblocks-theme-width-button-group"
45 help={ __( 'Change the width of this block using a method defined by your theme.', 'generateblocks' ) }
46 >
47 <div>
48 <ButtonGroup
49 className="gblocks-alignment-button-group"
50 id="gblocks-theme-width-button-group"
51 >
52 { options.map( ( option ) => {
53 return (
54 <Tooltip key={ 'align' + option.value } text={ option.label }>
55 <Button
56 variant={ value === option.value ? 'primary' : '' }
57 onClick={ () => onChange( option.value ) }
58 icon={ option.icon }
59 />
60 </Tooltip>
61 );
62 } ) }
63 </ButtonGroup>
64 </div>
65 </BaseControl>
66 );
67 }
68