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 / extend / inspector-control / controls / layout / components / LayoutControl.js
generateblocks / src / extend / inspector-control / controls / layout / components Last commit date
Display.js 3 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
LayoutControl.js
56 lines
1 import { BaseControl, ButtonGroup, Button, Tooltip } from '@wordpress/components';
2 import { Fragment } from '@wordpress/element';
3 import { flexOptions } from '../options';
4 import './editor.scss';
5 import classnames from 'classnames';
6
7 export default ( props ) => {
8 const {
9 value,
10 onChange,
11 label,
12 attributeName,
13 directionValue,
14 fallback,
15 } = props;
16
17 function ButtonElement( option ) {
18 return (
19 <Button
20 isPrimary={ option.value === value }
21 className={ ! value && fallback === option.value ? 'is-inherited' : '' }
22 onClick={ () => onChange( option.value ) }
23 >
24 { option.icon || option.label }
25 </Button>
26 );
27 }
28
29 return (
30 <BaseControl
31 id={ attributeName }
32 label={ label }
33 className={ classnames( {
34 [ `gblocks-flex-direction-${ attributeName + '-' + directionValue }` ]: true,
35 } ) }
36 >
37 <ButtonGroup id={ attributeName } className="gblocks-flex-button-group">
38 {
39 flexOptions[ attributeName ].map( ( flexOption, index ) => {
40 return (
41 <Fragment key={ attributeName + index }>
42 { !! flexOption.icon
43 ? <Tooltip text={ flexOption.label || flexOption.value }>
44 { ButtonElement( flexOption ) }
45 </Tooltip>
46 : ButtonElement( flexOption )
47 }
48 </Fragment>
49 );
50 } )
51 }
52 </ButtonGroup>
53 </BaseControl>
54 );
55 };
56