PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.1
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.1
1.4.21 1.4.20 1.4.19 1.4.18 1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 All 184 releases
disco / backend / views / components / Main / components / CustomNumberInput.jsx

CustomNumberInput.jsx in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.1, at backend/views/components/Main/components/CustomNumberInput.jsx

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { MinusCircleIcon } from '@heroicons/react/24/outline';
2 import { PlusCircleIcon } from '@heroicons/react/24/solid';
3 import { useState } from 'react';
4
5 const CustomNumberInput = ({
6 placeholder = 'Size',
7 initialValue = 1,
8 min = 1,
9 max = 99,
10 onChange,
11 className = '',
12 disabled = false,
13 }) => {
14 const [value, setValue] = useState(initialValue);
15
16 const handleIncrement = () => {
17 if (disabled) return;
18 if (value < max) {
19 const newValue = value + 1;
20 setValue(newValue);
21 onChange && onChange(newValue);
22 }
23 };
24
25 const handleDecrement = () => {
26 if (disabled) return;
27 if (value > min) {
28 const newValue = value - 1;
29 setValue(newValue);
30 onChange && onChange(newValue);
31 }
32 };
33
34 return (
35 <div
36 className={`disco-border disco-border-green-400 disco-bg-white disco-rounded-md disco-px-2 disco-flex disco-justify-between disco-items-center ${className} ${disabled ? 'disco-opacity-50 disco-cursor-not-allowed' : ''}`}
37 >
38 <span className="disco-text-black disco-text-sm">
39 {placeholder}
40 </span>
41 <div className="disco-flex disco-space-x-1">
42 <MinusCircleIcon
43 className="disco-w-5 disco-h-5 disco-text-primary disco-text-sm"
44 onClick={handleDecrement}
45 />
46 <span className="disco-text-sm">{initialValue}</span>
47 <PlusCircleIcon
48 className="disco-w-5 disco-h-5 disco-text-primary"
49 onClick={handleIncrement}
50 />
51 </div>
52 </div>
53 );
54 };
55
56 export default CustomNumberInput;
57