fixed mobile responsiveness, unit is not optional when posting

This commit is contained in:
liyunze 2026-09-09 17:33:11 +08:00
parent 11132d5e86
commit 4d7c98c521
4 changed files with 21 additions and 11 deletions

View file

@ -488,7 +488,7 @@ function notesCreate(
const user = requireAuth(db, args.token); const user = requireAuth(db, args.token);
const topicId = args.topicId?.trim() ?? ""; const topicId = args.topicId?.trim() ?? "";
const unitId = args.unitId?.trim() ?? ""; const unitId = args.unitId?.trim() ?? "";
if (!topicId && !unitId) throw new Error("Select a topic or a unit"); if (!unitId) throw new Error("Select a unit");
const id = newId(); const id = newId();
const now = Date.now(); const now = Date.now();
db.exec("BEGIN"); db.exec("BEGIN");
@ -597,7 +597,7 @@ function questionsCreate(
const user = requireAuth(db, args.token); const user = requireAuth(db, args.token);
const topicId = args.topicId?.trim() ?? ""; const topicId = args.topicId?.trim() ?? "";
const unitId = args.unitId?.trim() ?? ""; const unitId = args.unitId?.trim() ?? "";
if (!topicId && !unitId) throw new Error("Select a topic or a unit"); if (!unitId) throw new Error("Select a unit");
const id = newId(); const id = newId();
const now = Date.now(); const now = Date.now();
db.exec("BEGIN"); db.exec("BEGIN");

View file

@ -471,14 +471,18 @@
</a> </a>
{/if} {/if}
{:else} {:else}
<div class="border-rule flex items-end justify-between gap-4 border-b pb-6"> <div
class="border-rule flex flex-col gap-4 border-b pb-6 sm:flex-row sm:items-end sm:justify-between"
>
<div> <div>
<p class="kicker">Admin</p> <p class="kicker">Admin</p>
<h1 class="text-ink mt-2 font-serif text-4xl font-medium">Dashboard</h1> <h1 class="text-ink mt-2 font-serif text-4xl font-medium">Dashboard</h1>
</div> </div>
<div class="flex gap-2"> <div class="flex flex-wrap gap-2" role="tablist" aria-label="Admin sections">
<button <button
type="button" type="button"
role="tab"
aria-selected={tab === "overview"}
class="chip {tab === 'overview' ? 'chip-active' : ''}" class="chip {tab === 'overview' ? 'chip-active' : ''}"
onclick={() => (tab = "overview")} onclick={() => (tab = "overview")}
> >
@ -486,6 +490,8 @@
</button> </button>
<button <button
type="button" type="button"
role="tab"
aria-selected={tab === "units"}
class="chip {tab === 'units' ? 'chip-active' : ''}" class="chip {tab === 'units' ? 'chip-active' : ''}"
onclick={() => (tab = "units")} onclick={() => (tab = "units")}
> >
@ -493,6 +499,8 @@
</button> </button>
<button <button
type="button" type="button"
role="tab"
aria-selected={tab === "accounts"}
class="chip {tab === 'accounts' ? 'chip-active' : ''}" class="chip {tab === 'accounts' ? 'chip-active' : ''}"
onclick={() => (tab = "accounts")} onclick={() => (tab = "accounts")}
> >
@ -500,6 +508,8 @@
</button> </button>
<button <button
type="button" type="button"
role="tab"
aria-selected={tab === "notes"}
class="chip {tab === 'notes' ? 'chip-active' : ''}" class="chip {tab === 'notes' ? 'chip-active' : ''}"
onclick={() => (tab = "notes")} onclick={() => (tab = "notes")}
> >
@ -556,7 +566,7 @@
<div class="mt-6 flex items-end gap-3 overflow-x-auto pb-2"> <div class="mt-6 flex items-end gap-3 overflow-x-auto pb-2">
{#each stats.weeks as week} {#each stats.weeks as week}
<div class="flex min-w-[72px] flex-1 flex-col items-center gap-1"> <div class="flex min-w-18 flex-1 flex-col items-center gap-1">
<div class="flex h-32 w-full items-end justify-center gap-1"> <div class="flex h-32 w-full items-end justify-center gap-1">
<div <div
class="bg-primary w-1/3 max-w-6" class="bg-primary w-1/3 max-w-6"

View file

@ -78,8 +78,8 @@
return; return;
} }
const hasUnit = useCustomUnit ? !!customUnit.trim() : !!selectedUnitId; const hasUnit = useCustomUnit ? !!customUnit.trim() : !!selectedUnitId;
if (!selectedTopicId && !hasUnit) { if (!hasUnit) {
error = "Please select a topic or a unit"; error = "Please select a unit";
return; return;
} }
@ -160,7 +160,6 @@
</div> </div>
<div> <div>
<p class="text-muted mb-3 text-xs">Choose at least one topic or unit.</p>
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2"> <div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
<div> <div>
<label for="topic" class="kicker mb-2 block">Topic (optional)</label> <label for="topic" class="kicker mb-2 block">Topic (optional)</label>
@ -202,6 +201,7 @@
bind:value={customUnit} bind:value={customUnit}
placeholder="e.g., SIT384" placeholder="e.g., SIT384"
class="field mt-2" class="field mt-2"
required
/> />
{/if} {/if}
</div> </div>

View file

@ -78,8 +78,8 @@
return; return;
} }
const hasUnit = useCustomUnit ? !!customUnit.trim() : !!selectedUnitId; const hasUnit = useCustomUnit ? !!customUnit.trim() : !!selectedUnitId;
if (!selectedTopicId && !hasUnit) { if (!hasUnit) {
error = "Please select a topic or a unit"; error = "Please select a unit";
return; return;
} }
@ -162,7 +162,6 @@
</div> </div>
<div> <div>
<p class="text-muted mb-3 text-xs">Choose at least one topic or unit.</p>
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2"> <div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
<div> <div>
<label for="topic" class="kicker mb-2 block">Topic (optional)</label> <label for="topic" class="kicker mb-2 block">Topic (optional)</label>
@ -204,6 +203,7 @@
bind:value={customUnit} bind:value={customUnit}
placeholder="e.g., SIT384" placeholder="e.g., SIT384"
class="field mt-2" class="field mt-2"
required
/> />
{/if} {/if}
</div> </div>