Question formatting

This commit is contained in:
Ian Gulliver
2026-10-16 07:04:24 -07:00
parent 2967fa086a
commit b0b433bc6c
28 changed files with 468 additions and 496 deletions
+8 -5
View File
@@ -74,12 +74,12 @@ function reconcile(parent, nodes) {
}
function clickable(el, go) {
el.onclick = (e) => {
if (!e.target.closest("a")) {
if (!e.target.closest("a, button")) {
go();
}
};
el.onkeydown = (e) => {
if (e.key === "Enter" || e.key === " ") {
if (e.target === el && (e.key === "Enter" || e.key === " ")) {
e.preventDefault();
go();
}
@@ -127,9 +127,12 @@ function card(item) {
return null;
}
seen.add(text);
const tag = recommended.includes(text) && h("span", { class: "recommended" }, "recommended");
const rec = recommended.includes(text);
const tag = rec && h("span", { class: "recommended" }, "recommended");
const name = h("span", { class: "choice-name" }, inlineMarkdown(text));
if (!multiple) {
return clickable(h("div", { class: "pick", role: "button", tabIndex: 0 }, inlineMarkdown(text), tag), () => {
const head = h("div", { class: "choice-head" }, name, tag);
return clickable(h("div", { class: rec ? "pick choice-box rec" : "pick choice-box", role: "button", tabIndex: 0 }, head), () => {
void submit({ item_id: item.id, type: "option", options: [text] });
});
}
@@ -142,7 +145,7 @@ function card(item) {
checked.set(item.id, options.filter((o) => now.includes(o)));
renderActions();
};
return h("label", { class: "option" }, input, " ", inlineMarkdown(text), tag);
return h("label", { class: rec ? "option choice-box rec" : "option choice-box" }, h("div", { class: "choice-head" }, input, name, tag));
};
const textEntry = (label, placeholder, shared) => {
const open = texts.has(item.id);