-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTtt
82 lines (68 loc) · 2.15 KB
/
Ttt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// ... [imports and other code]
function RiskChatExplorer({chatInputText, setChatInputText}) {
// ... [Existing useState, useRef and functions]
const [areActionsEnabled, setActionsEnabled] = useState(true); // State to toggle action buttons
const actionButtons = [
// ... [Existing actionButtons array]
];
const handleActionButtonClick = (actionPrefix) => {
if (areActionsEnabled) {
// Prefix the action text to the current chat input
setChatInputText(prevText => actionPrefix + prevText);
}
}
return (
<div id="app">
{/* ... [Existing code] */}
<div className="action-toolbar">
<div className="action-buttons">
{actionButtons.map((btn, index) => (
<button key={index} type="button" disabled={!areActionsEnabled} onClick={() => handleActionButtonClick(btn.prefix)}>
<img src={btn.icon} alt={btn.alt} />
</button>
))}
</div>
<label className="toggle-actions">
<input type="checkbox" checked={areActionsEnabled} onChange={() => setActionsEnabled(!areActionsEnabled)} />
Toggle Actions
</label>
</div>
{/* ... [Existing form code] */}
</div>
);
}
.action-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #f7f7f7;
padding: 10px;
border-radius: 8px;
margin-bottom: 10px;
}
.action-buttons {
display: flex;
gap: 10px; /* Spacing between buttons */
}
.action-buttons button {
background-color: #2c3e50;
color: white;
border: none;
padding: 10px 20px;
border-radius: 20px;
transition: 0.3s;
cursor: pointer;
}
.action-buttons button:disabled {
background-color: #bdc3c7; /* Color when disabled */
cursor: not-allowed;
}
.toggle-actions {
display: flex;
align-items: center;
gap: 10px; /* Spacing between checkbox and label */
}
.toggle-actions input {
cursor: pointer;
}
default RiskChatExplorer;