feat: unit descriptions with tooltip action and admin textarea

This commit is contained in:
Falkan
2026-03-17 19:55:09 -04:00
parent 9a8b82eca5
commit 15b763e062
4 changed files with 49 additions and 3 deletions

View File

@@ -464,6 +464,10 @@
<small class="tobase-hint">{toBaseHint}</small>
{/if}
</label>
<label>
Description <small class="muted">(optional — shown as tooltip in converter)</small>
<textarea bind:value={unitForm.description} placeholder="e.g. A unit based on…" rows="2"></textarea>
</label>
<div class="form-actions">
<button onclick={saveUnit}>{unitFormNew ? 'Create' : 'Save'}</button>
{#if !unitFormNew}

View File

@@ -16,7 +16,7 @@ export const POST: RequestHandler = async ({ request }) => {
const body = await request.json().catch(() => null);
if (!body) return json({ error: 'Invalid JSON' }, { status: 400 });
const { id, label, labelPlural, symbol, group, toBase } = body as Partial<Unit>;
const { id, label, labelPlural, symbol, group, toBase, description } = body as Partial<Unit>;
// Validation
if (!id || !KEBAB_RE.test(id)) {
@@ -44,7 +44,8 @@ export const POST: RequestHandler = async ({ request }) => {
labelPlural,
symbol,
group: group ?? null,
toBase
toBase,
...(description ? { description } : {})
};
data.units.push(newUnit);
saveData(data);