feat: unit descriptions with tooltip action and admin textarea
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user