Skip to content

Commit 4a48ac9

Browse files
author
Diyor Khaydarov
committedFeb 16, 2025·
feat: enable button on text input
1 parent 88ecf76 commit 4a48ac9

File tree

3 files changed

+88
-34
lines changed

3 files changed

+88
-34
lines changed
 

‎modules/website/presentation/assets/js/aichat.js

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ class AiChatWidget extends HTMLElement {
1212
const html = await response.text();
1313

1414
this.shadowRoot.innerHTML = html;
15+
16+
const textarea = this.shadowRoot.getElementById("message-textarea");
17+
const sendButton = this.shadowRoot.getElementById("send-button");
18+
19+
textarea.addEventListener("input", () => {
20+
sendButton.disabled = !textarea.value;
21+
});
22+
23+
sendButton.addEventListener("click", async () => {
24+
console.log("Send button clicked");
25+
});
1526
}
1627
}
1728

‎modules/website/presentation/templates/pages/aichat/aichat.templ

+12-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Props struct {
3636
Starters []string
3737
}
3838

39-
templ Chat(props Props) {
39+
templ chatCSS() {
4040
<style type="text/css">
4141
.wrapper {
4242
--primary-color: #2E67B4;
@@ -107,6 +107,7 @@ templ Chat(props Props) {
107107
}
108108

109109
.wrapper .btn {
110+
all: unset;
110111
display: flex;
111112
justify-content: center;
112113
border-radius: var(--btn-radius);
@@ -130,6 +131,10 @@ templ Chat(props Props) {
130131
color: var(--primary-color);
131132
}
132133
</style>
134+
}
135+
136+
templ Chat(props Props) {
137+
@chatCSS()
133138
<div class="wrapper">
134139
<div class="header">
135140
@ChatIcon()
@@ -149,6 +154,7 @@ templ Chat(props Props) {
149154
</div>
150155
<div class="body">
151156
<textarea
157+
id="message-textarea"
152158
rows="7"
153159
placeholder="Введите вопрос"
154160
class="textarea"
@@ -157,12 +163,16 @@ templ Chat(props Props) {
157163
<slot></slot>
158164
</div>
159165
<button
166+
id="send-button"
160167
class="btn btn-primary"
161168
disabled
162169
>
163170
Отправить
164171
</button>
165-
<button class="btn btn-secondary">
172+
<button
173+
id="callback-button"
174+
class="btn btn-secondary"
175+
>
166176
Запрос обратного звонка
167177
</button>
168178
</div>

‎modules/website/presentation/templates/pages/aichat/aichat_templ.go

+65-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.