| 1 |
<script lang="ts"> |
| 2 |
import type { EntryMetadata } from "../entries"; |
| 3 |
import { _ } from "../i18n"; |
| 4 |
|
| 5 |
interface Props { |
| 6 |
meta: EntryMetadata; |
| 7 |
} |
| 8 |
|
| 9 |
let { meta = $bindable() }: Props = $props(); |
| 10 |
|
| 11 |
let meta_entries = $derived(meta.entries()); |
| 12 |
</script> |
| 13 |
|
| 14 |
{#each meta_entries as [key, value], index (key)} |
| 15 |
<div class="flex-row"> |
| 16 |
<button |
| 17 |
type="button" |
| 18 |
class="muted round remove-row" |
| 19 |
onclick={() => { |
| 20 |
meta = meta.delete(key); |
| 21 |
}} |
| 22 |
tabindex={-1} |
| 23 |
> |
| 24 |
× |
| 25 |
</button> |
| 26 |
<input |
| 27 |
type="text" |
| 28 |
class="key" |
| 29 |
placeholder={_("Key")} |
| 30 |
value={key} |
| 31 |
onchange={(event) => { |
| 32 |
meta = meta.update_key(key, event.currentTarget.value); |
| 33 |
}} |
| 34 |
required |
| 35 |
/> |
| 36 |
<input |
| 37 |
type="text" |
| 38 |
class="value" |
| 39 |
placeholder={_("Value")} |
| 40 |
{value} |
| 41 |
onchange={(event) => { |
| 42 |
meta = meta.set_string(key, event.currentTarget.value); |
| 43 |
}} |
| 44 |
/> |
| 45 |
{#if index === meta_entries.length - 1 && key} |
| 46 |
<button |
| 47 |
type="button" |
| 48 |
class="muted round" |
| 49 |
onclick={() => { |
| 50 |
meta = meta.add(); |
| 51 |
}} |
| 52 |
title={_("Add metadata")} |
| 53 |
> |
| 54 |
+ |
| 55 |
</button> |
| 56 |
{/if} |
| 57 |
</div> |
| 58 |
{/each} |
| 59 |
|
| 60 |
<style> |
| 61 |
div { |
| 62 |
padding-left: 56px; |
| 63 |
font-size: 0.8em; |
| 64 |
} |
| 65 |
|
| 66 |
input.key { |
| 67 |
width: 10em; |
| 68 |
} |
| 69 |
|
| 70 |
input.value { |
| 71 |
flex-grow: 1; |
| 72 |
max-width: 15em; |
| 73 |
} |
| 74 |
|
| 75 |
@media (width <= 767px) { |
| 76 |
div { |
| 77 |
padding-left: 0; |
| 78 |
} |
| 79 |
} |
| 80 |
</style> |