PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / admin / src / components / ToggleControl.jsx

ToggleControl.jsx in Tableberg – Simple Gutenberg Table Block 1.1.5, at admin/src/components/ToggleControl.jsx

44 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useEffect, useRef, useState } from "react";
2
3 /**
4 * Toggle control component.
5 *
6 * @class
7 * @param {Object} props component properties
8 * @param {boolean} props.status control status
9 * @param {boolean} props.name control name
10 * @param {boolean} props.disabled control disabled status
11 * @param {Function} props.onStatusChange status changed callback
12 */
13 function ToggleControl({
14 status,
15 name,
16 onStatusChange = () => {},
17 disabled = false,
18 }) {
19 /**
20 * Click handler for toggle component.
21 */
22 const clickHandler = () => {
23 if (!disabled) {
24 onStatusChange(!status, name);
25 }
26 };
27
28 return (
29 <div
30 onClick={clickHandler}
31 className={"tableberg-toggle-control"}
32 data-enabled={JSON.stringify(disabled || status)}
33 role={"button"}
34 >
35 <div className={"knob"}></div>
36 </div>
37 );
38 }
39
40 /**
41 * @module ToggleControl
42 */
43 export default ToggleControl;
44