add placeholder to input

This commit is contained in:
Charlotte Som 2025-02-26 08:53:49 +00:00
parent b8f7ce6ad7
commit 16b38f4e98
3 changed files with 7 additions and 5 deletions

View file

@ -71,7 +71,7 @@ function conversationUI(id: string) {
const form = ( const form = (
<form> <form>
<input type="text" required /> <input type="text" placeholder="Enter a prompt…" required />
</form> </form>
); );
const input = form.querySelector("input")!; const input = form.querySelector("input")!;

View file

@ -72,7 +72,9 @@ function conversationUI(id) {
if (typeof event.data !== "string") return; if (typeof event.data !== "string") return;
const message = JSON.parse(event.data); const message = JSON.parse(event.data);
const scrolledToBottom = chatlog.scrollTop + 16 >= chatlog.scrollHeight - chatlog.clientHeight; const scrolledToBottom = chatlog.scrollTop + 16 >= chatlog.scrollHeight - chatlog.clientHeight;
if ("u" in message) { if ("i" in message) {
window.history.replaceState(null, "", "#" + message.i);
} else if ("u" in message) {
chatlog.append(/* @__PURE__ */ jsx("article", { className: "user", children: message.u })); chatlog.append(/* @__PURE__ */ jsx("article", { className: "user", children: message.u }));
} else if ("f" in message) { } else if ("f" in message) {
chatlog.append(/* @__PURE__ */ jsx("article", { className: "assistant", children: message.f })); chatlog.append(/* @__PURE__ */ jsx("article", { className: "assistant", children: message.f }));
@ -88,7 +90,7 @@ function conversationUI(id) {
} }
if (scrolledToBottom) chatlog.scrollTop = chatlog.scrollHeight - chatlog.clientHeight; if (scrolledToBottom) chatlog.scrollTop = chatlog.scrollHeight - chatlog.clientHeight;
}); });
const form = /* @__PURE__ */ jsx("form", { children: /* @__PURE__ */ jsx("input", { type: "text", required: true }) }); const form = /* @__PURE__ */ jsx("form", { children: /* @__PURE__ */ jsx("input", { type: "text", placeholder: "Enter a prompt\u2026", required: true }) });
const input = form.querySelector("input"); const input = form.querySelector("input");
form.addEventListener("submit", (e) => { form.addEventListener("submit", (e) => {
e.preventDefault(); e.preventDefault();

File diff suppressed because one or more lines are too long