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 / MenuButton.jsx

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

65 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from "react";
2
3 /**
4 * Button types.
5 *
6 * @type {Object}
7 */
8 export const BUTTON_TYPES = {
9 NEGATIVE: "negative",
10 POSITIVE: "positive",
11 };
12
13 /**
14 * Menu button component.
15 *
16 * @param {Object} props component properties
17 * @param {string} props.title button title
18 * @param {Function} [props.onClickHandler=()=>{}] click callback
19 * @param {boolean} [props.status=false] enabled status
20 * @param {string} [props.type='negative'] button type
21 * @class
22 */
23 function MenuButton({
24 title,
25 onClickHandler = () => {},
26 status = false,
27 type = BUTTON_TYPES.NEGATIVE,
28 }) {
29 const typeClass = () => {
30 let buttonClass = "";
31
32 switch (type) {
33 case BUTTON_TYPES.NEGATIVE: {
34 buttonClass = "tableberg-negative-bg";
35 break;
36 }
37 case BUTTON_TYPES.POSITIVE: {
38 buttonClass = "tableberg-positive-bg";
39 break;
40 }
41 }
42
43 return buttonClass;
44 };
45
46 return (
47 <div
48 onClick={() => {
49 if (status) {
50 onClickHandler();
51 }
52 }}
53 className={`tableberg-menu-button ${typeClass()}`}
54 data-enabled={JSON.stringify(status)}
55 >
56 {title}
57 </div>
58 );
59 }
60
61 /**
62 * @module MenuButton
63 */
64 export default MenuButton;
65