| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame^] | 1 | <html> |
| 2 | <head> |
| 3 | <title>sketch-chat-input demo</title> |
| 4 | <link rel="stylesheet" href="demo.css" /> |
| 5 | <script src="/dist/web-components/sketch-chat-input.js" type="module"></script> |
| 6 | |
| 7 | <script> |
| 8 | document.addEventListener("DOMContentLoaded", () => { |
| 9 | const chatInput = document.querySelector('sketch-chat-input'); |
| 10 | console.log("chatInput: ", chatInput); |
| 11 | chatInput.content = "hi"; |
| 12 | chatInput.addEventListener("send-chat", (evt) => { |
| 13 | console.log('send chat event: ', evt); |
| 14 | const msgDiv = document.querySelector("#chat-messages"); |
| 15 | const newDiv = document.createElement("div"); |
| 16 | newDiv.innerText = evt.detail.message; |
| 17 | msgDiv.append(newDiv); |
| 18 | chatInput.content = ''; |
| 19 | }); |
| 20 | }); |
| 21 | </script> |
| 22 | |
| 23 | </head> |
| 24 | <body> |
| 25 | <h1>sketch-chat-input demo</h1> |
| 26 | |
| 27 | <div id="chat-messages"></div> |
| 28 | |
| 29 | <sketch-chat-input></sketch-chat-input> |
| 30 | |
| 31 | </body> |
| 32 | </html> |