File tree 3 files changed +88
-34
lines changed
modules/website/presentation
3 files changed +88
-34
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,17 @@ class AiChatWidget extends HTMLElement {
12
12
const html = await response . text ( ) ;
13
13
14
14
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
+ } ) ;
15
26
}
16
27
}
17
28
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ type Props struct {
36
36
Starters []string
37
37
}
38
38
39
- templ Chat (props Props ) {
39
+ templ chatCSS ( ) {
40
40
<style type =" text/css" >
41
41
.wrapper {
42
42
--primary-color : #2E67B4 ;
@@ -107,6 +107,7 @@ templ Chat(props Props) {
107
107
}
108
108
109
109
.wrapper .btn {
110
+ all : unset ;
110
111
display : flex ;
111
112
justify-content : center ;
112
113
border-radius : var (--btn-radius );
@@ -130,6 +131,10 @@ templ Chat(props Props) {
130
131
color : var (--primary-color );
131
132
}
132
133
</style >
134
+ }
135
+
136
+ templ Chat (props Props ) {
137
+ @ chatCSS ()
133
138
<div class =" wrapper" >
134
139
<div class =" header" >
135
140
@ ChatIcon ()
@@ -149,6 +154,7 @@ templ Chat(props Props) {
149
154
</div >
150
155
<div class =" body" >
151
156
<textarea
157
+ id =" message-textarea"
152
158
rows =" 7"
153
159
placeholder =" Введите вопрос"
154
160
class =" textarea"
@@ -157,12 +163,16 @@ templ Chat(props Props) {
157
163
<slot ></slot >
158
164
</div >
159
165
<button
166
+ id =" send-button"
160
167
class =" btn btn-primary"
161
168
disabled
162
169
>
163
170
Отправить
164
171
</button >
165
- <button class =" btn btn-secondary" >
172
+ <button
173
+ id =" callback-button"
174
+ class =" btn btn-secondary"
175
+ >
166
176
Запрос обратного звонка
167
177
</button >
168
178
</div >
You can’t perform that action at this time.
0 commit comments