PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.3
GenerateBlocks v1.8.3
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 / FlexDirection.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
FlexDirection.js
77 lines
1 import { BaseControl, ButtonGroup, Button, Tooltip } from '@wordpress/components';
2 import { Fragment } from '@wordpress/element';
3 import { __ } from '@wordpress/i18n';
4 import { flexOptions } from '../options';
5 import './editor.scss';
6 import classnames from 'classnames';
7
8 export default ( props ) => {
9 const {
10 value,
11 onChange,
12 onReverse,
13 label,
14 directionValue,
15 fallback,
16 } = props;
17
18 function ButtonElement( option ) {
19 return (
20 <Button
21 isPrimary={ value.includes( option.value ) }
22 className={ ! value && fallback.includes( option.value ) ? 'is-inherited' : '' }
23 onClick={ () => onChange( option.value ) }
24 >
25 { option.icon || option.label }
26 </Button>
27 );
28 }
29
30 function ReverseIcon() {
31 let icon = <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z" /><path d="m9 19 1.41-1.41L5.83 13H22v-2H5.83l4.59-4.59L9 5l-7 7 7 7z" /></svg>;
32
33 if ( value.includes( 'column' ) || ( ! value && fallback.includes( 'column' ) ) ) {
34 icon = <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z" /><path d="m5 9 1.41 1.41L11 5.83V22h2V5.83l4.59 4.59L19 9l-7-7-7 7z" /></svg>;
35 }
36
37 return icon;
38 }
39
40 return (
41 <BaseControl
42 id={ 'flexDirection' }
43 label={ label }
44 className={ classnames( {
45 [ `gblocks-flex-direction-flexDirection-${ directionValue }` ]: true,
46 } ) }
47 >
48 <ButtonGroup id={ 'flexDirection' } className="gblocks-flex-button-group">
49 {
50 flexOptions.flexDirection.map( ( flexOption, index ) => {
51 return (
52 <Fragment key={ label + index }>
53 { !! flexOption.icon
54 ? <Tooltip text={ flexOption.label || flexOption.value }>
55 { ButtonElement( flexOption ) }
56 </Tooltip>
57 : ButtonElement( flexOption )
58 }
59 </Fragment>
60 );
61 } )
62 }
63
64 <Tooltip text={ __( 'Reverse', 'generateblocks' ) }>
65 <Button
66 isPrimary={ value.includes( 'reverse' ) }
67 className={ ! value && fallback.includes( 'reverse' ) ? 'is-inherited' : '' }
68 onClick={ () => onReverse( value ) }
69 >
70 { ReverseIcon() }
71 </Button>
72 </Tooltip>
73 </ButtonGroup>
74 </BaseControl>
75 );
76 };
77