PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / components / toggle-group / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/components/toggle-group/index.js

91 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import classnames from 'classnames/dedupe';
2
3 import {
4 __experimentalToggleGroupControl as ToggleGroupControl,
5 __experimentalToggleGroupControlOption as ToggleGroupControlOption,
6 __experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
7 BaseControl,
8 Button,
9 ButtonGroup,
10 } from '@wordpress/components';
11
12 /**
13 * Component Class
14 *
15 * @param props
16 */
17 export default function ToggleGroup(props) {
18 const {
19 label,
20 value,
21 options,
22 onChange,
23 isBlock,
24 isAdaptiveWidth,
25 isDeselectable,
26 } = props;
27
28 if (ToggleGroupControl && ToggleGroupControlOption) {
29 return (
30 <BaseControl
31 id={label}
32 label={label}
33 className={classnames(
34 'ghostkit-control-toggle-group',
35 props.className
36 )}
37 >
38 <ToggleGroupControl
39 value={value}
40 onChange={onChange}
41 isBlock={isBlock}
42 isAdaptiveWidth={isAdaptiveWidth}
43 isDeselectable={isDeselectable}
44 hideLabelFromVision
45 >
46 {options.map((option) =>
47 option.icon ? (
48 <ToggleGroupControlOptionIcon
49 key={option.value}
50 value={option.value}
51 icon={option.icon}
52 label={option.label}
53 disabled={option.disabled}
54 />
55 ) : (
56 <ToggleGroupControlOption
57 key={option.value}
58 value={option.value}
59 label={option.label}
60 disabled={option.disabled}
61 />
62 )
63 )}
64 </ToggleGroupControl>
65 </BaseControl>
66 );
67 }
68
69 // Fallback.
70 return (
71 <BaseControl id={label} label={label}>
72 <ButtonGroup className="ghostkit-control-toggle-group">
73 {options.map((option) => (
74 <Button
75 key={option.value}
76 isSmall
77 isPrimary={value === option.value}
78 isPressed={value === option.value}
79 disabled={option.disabled}
80 onClick={() => {
81 onChange(option.value);
82 }}
83 >
84 {option.label}
85 </Button>
86 ))}
87 </ButtonGroup>
88 </BaseControl>
89 );
90 }
91