From 16b38f4e988b0976d7bdaad8e1a8d610d771af37 Mon Sep 17 00:00:00 2001 From: Charlotte Som Date: Wed, 26 Feb 2025 08:53:49 +0000 Subject: [PATCH] add placeholder to input --- client/main.tsx | 2 +- client/web/dist/main.js | 6 ++++-- client/web/dist/main.js.map | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client/main.tsx b/client/main.tsx index d813fef..a5b37e4 100644 --- a/client/main.tsx +++ b/client/main.tsx @@ -71,7 +71,7 @@ function conversationUI(id: string) { const form = (
- +
); const input = form.querySelector("input")!; diff --git a/client/web/dist/main.js b/client/web/dist/main.js index 8d9426c..733f2cd 100644 --- a/client/web/dist/main.js +++ b/client/web/dist/main.js @@ -72,7 +72,9 @@ function conversationUI(id) { if (typeof event.data !== "string") return; const message = JSON.parse(event.data); 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 })); } else if ("f" in message) { 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; }); - 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"); form.addEventListener("submit", (e) => { e.preventDefault(); diff --git a/client/web/dist/main.js.map b/client/web/dist/main.js.map index 66792dc..d2d6b79 100644 --- a/client/web/dist/main.js.map +++ b/client/web/dist/main.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["https://jsr.io/@char/aftercare/0.2.0/src/elem.ts", "https://jsr.io/@char/aftercare/0.2.0/src/jsx.ts", "../../main.tsx"], - "sourcesContent": ["type GenericElement = HTMLElement | SVGElement;\n\ntype IsNullish = [T] extends [null] ? true : [T] extends [undefined] ? true : false;\ntype IsFunctionIsh =\n IsNullish extends true\n ? false\n : // deno-lint-ignore ban-types\n T extends Function | null | undefined\n ? true\n : false;\n\nexport type ElementProps = {\n [K in keyof E as IsFunctionIsh extends true ? never : K]?: E[K];\n};\n\nexport interface ElementExtras {\n classList?: string[];\n dataset?: Partial>;\n /** extra function to run on the element */\n _tap?: (elem: E) => void;\n}\n\nexport type TagName = keyof HTMLElementTagNameMap;\nexport type CustomTagType = new () => T;\nexport type ElementType = T extends TagName\n ? HTMLElementTagNameMap[T]\n : T extends CustomTagType\n ? E\n : never;\n\nexport function elem(\n tag: T,\n attrs: ElementProps> = {},\n children: (Element | string | Text)[] = [],\n extras: ElementExtras> = {},\n): ElementType {\n const element = typeof tag === \"string\" ? document.createElement(tag) : new tag();\n\n Object.assign(\n element,\n Object.fromEntries(Object.entries(attrs).filter(([_k, v]) => v !== undefined)),\n );\n\n if (extras.classList) extras.classList.forEach(c => element.classList.add(c));\n if (extras.dataset && (element instanceof HTMLElement || element instanceof SVGElement))\n Object.entries(extras.dataset)\n .filter(([_k, v]) => v !== undefined)\n .forEach(([k, v]) => (element.dataset[k] = v));\n\n const childNodes = children.map(e =>\n typeof e === \"string\" ? document.createTextNode(e) : e,\n );\n element.append(...childNodes);\n\n if (extras._tap) extras._tap(element as ElementType);\n\n return element as ElementType;\n}\n\nexport function rewrite(element: Element, children: (Element | string | Text)[] = []) {\n element.innerHTML = \"\";\n const nodes = children.map(e => (typeof e === \"string\" ? document.createTextNode(e) : e));\n element.append(...nodes);\n}\n", "import {\n type CustomTagType,\n elem,\n type ElementExtras,\n type ElementProps,\n type ElementType,\n type TagName,\n} from \"./elem.ts\";\n\n// deno-lint-ignore no-namespace\nnamespace JSX {\n export type Element = HTMLElement | SVGElement;\n export type IntrinsicElements = {\n [K in TagName]: Omit>, \"children\"> & {\n children?: JSX.Element | JSX.Element[] | undefined;\n } & Partial>>;\n };\n}\n\nfunction Fragment(props: Record, _key?: string): never {\n return jsx(undefined, props, _key) as never;\n}\n\nfunction jsx(\n tag: T | undefined,\n props: Record,\n _key?: string,\n): ElementType {\n if (tag === undefined) {\n throw new Error(\"fragments are not supported\");\n }\n\n const { children = [], classList, dataset, _tap, ...attrs } = props;\n const childrenArray = Array.isArray(children) ? children : [children];\n const extras = { classList, dataset, _tap } as ElementExtras>;\n return elem(tag, attrs as ElementProps>, childrenArray, extras);\n}\n\nexport { Fragment, jsx, jsx as jsxDEV, jsx as jsxs };\nexport type { JSX };\n", "const main = document.querySelector(\"main\")!;\n\nasync function nav() {\n const nav =