PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.11.1
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.11.1
3.1.0 3.0.0 2.13.2 2.13.1 2.13.0 trunk 1.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.1 2.5.3 2.5.4 2.5.5 2.6.1 All 56 releases
slider-blocks / src / controls / alignment-control / index.js

index.js in GutSlider – All in One Slider and Carousel Blocks for Gutenberg 2.11.1, at src/controls/alignment-control/index.js

58 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { withInstanceId } from '@wordpress/compose';
2 import { FLEX_HORIZONTAL_ALIGNS, FLEX_VERTICAL_ALIGNS, TEXT_ALIGNS } from '../../constants';
3 import ButtonsGroupControl from '../buttons-group';
4 import ResLabelControl from '../res-label-control';
5
6 const AlignmentControl = ({ instanceId, label, controlName, objAttrs, flexAlign = false, flexVerticle = false }) => {
7 const { attributes, setAttributes } = objAttrs;
8 const { resMode, [`${controlName}Aligns`]: aligns } = attributes;
9
10 const id = `alignment-control-${instanceId}`;
11
12 const flexAlignOptions = flexVerticle ? FLEX_VERTICAL_ALIGNS : FLEX_HORIZONTAL_ALIGNS;
13
14 const alignmentOptions = flexAlign ? flexAlignOptions : TEXT_ALIGNS;
15
16 // Map resMode to corresponding property name
17 const resModeMap = {
18 Desktop: 'desk',
19 Tablet: 'tab',
20 Mobile: 'mob'
21 };
22
23 const currentMode = resModeMap[resMode];
24
25 return (
26 <div className="gkits-control-container">
27 <div className="gkits-mb-8">
28 <ResLabelControl
29 id={id}
30 label={label}
31 requiredProps={{
32 id,
33 resMode,
34 setAttributes
35 }}
36 />
37 </div>
38 {currentMode && (
39 <ButtonsGroupControl
40 value={aligns?.[currentMode]}
41 onChange={value =>
42 setAttributes({
43 [`${controlName}Aligns`]: {
44 ...aligns,
45 [currentMode]: value
46 }
47 })
48 }
49 options={alignmentOptions}
50 hasIcons={true}
51 />
52 )}
53 </div>
54 );
55 };
56
57 export default withInstanceId(AlignmentControl);
58