diff --git a/src/components/Badge.svelte b/src/components/Badge.svelte index e1f381d34..ac2dbe02c 100644 --- a/src/components/Badge.svelte +++ b/src/components/Badge.svelte @@ -3,12 +3,14 @@ | "caution" | "foreground" | "background" + | "outline" | "yellowOutline" | "neutral" | "negative" | "positive" | "primary" | "secondary"; + export let round: boolean = false; export let style: string | undefined = undefined; export let size: "tiny" | "small" | "medium" = "tiny"; export let title: string | undefined = undefined; @@ -25,7 +27,8 @@ white-space: nowrap; align-items: center; gap: 0.25rem; - max-width: 13.5rem; + /* This is aprox. a DID assignee */ + max-width: 16rem; } .background { color: currentColor; @@ -52,6 +55,13 @@ color: var(--color-foreground-yellow); background-color: transparent; } + .outline { + border: 1px solid var(--color-border-hint); + background-color: transparent; + } + .outline:hover { + border-color: var(--color-fill-secondary); + } .negative { color: var(--color-foreground-match-background); background-color: var(--color-foreground-red); @@ -80,21 +90,30 @@ font-size: var(--font-size-small); padding: 0.75rem 1rem; } + .round { + aspect-ratio: 1/1; + justify-content: center; + padding: unset; + } + (); - export let mode: "readCreate" | "readEdit" | "readOnly" = "readOnly"; export let locallyAuthenticated: boolean = false; export let assignees: string[] = []; export let submitInProgress: boolean = false; + let showInput: boolean = false; let updatedAssignees: string[] = assignees; let inputValue = ""; let validationMessage: string | undefined = undefined; let valid: boolean = false; let assignee: string | undefined = undefined; + const removeToggles: Record = {}; + $: { if (inputValue !== "") { const parsedNodeId = parseNodeId(inputValue); @@ -48,35 +50,23 @@ if (valid && assignee) { updatedAssignees = [...updatedAssignees, assignee]; inputValue = ""; - if (mode === "readCreate") { - dispatch("save", updatedAssignees); - } + dispatch("save", updatedAssignees); + showInput = false; } } function removeAssignee(assignee: string) { updatedAssignees = updatedAssignees.filter(x => x !== assignee); - if (mode === "readCreate") { - dispatch("save", updatedAssignees); - } + dispatch("save", updatedAssignees); + showInput = false; }
-
- Assignees +
Assignees
+
{#if locallyAuthenticated} -
- {#if mode === "readEdit"} + {#each updatedAssignees as assignee} + (removeToggles[assignee] = !removeToggles[assignee])}> +
+ + {formatNodeId(assignee)} + {#if removeToggles[assignee]} + + removeAssignee(assignee)} /> + + {/if} +
+
+ {/each} + {#if showInput} +
+ { - dispatch("save", updatedAssignees); - mode = "readOnly"; - }}> - - - { - updatedAssignees = assignees; inputValue = ""; - mode = "readOnly"; + showInput = false; }}> - {:else if mode !== "readCreate"} - (mode = "readEdit")}> - + + - {/if} -
- {/if} -
-
- {#if locallyAuthenticated && (mode === "readCreate" || mode === "readEdit")} - {#each updatedAssignees as assignee} - -
- - {formatNodeId(assignee)} - - removeAssignee(assignee)} /> - -
-
+
{:else} -
No assignees
- {/each} + (showInput = true)}> + + + {/if} {:else} {#each updatedAssignees as assignee} - +
{formatNodeId(assignee)} @@ -157,15 +147,4 @@ {/each} {/if}
- {#if locallyAuthenticated && (mode === "readCreate" || mode === "readEdit")} -
- -
- {/if}
diff --git a/src/views/projects/Cob/LabelInput.svelte b/src/views/projects/Cob/LabelInput.svelte index a6277c366..ec227f403 100644 --- a/src/views/projects/Cob/LabelInput.svelte +++ b/src/views/projects/Cob/LabelInput.svelte @@ -8,17 +8,19 @@ const dispatch = createEventDispatcher<{ save: string[] }>(); - export let mode: "readCreate" | "readEdit" | "readOnly" = "readOnly"; export let locallyAuthenticated: boolean = false; export let labels: string[] = []; export let submitInProgress: boolean = false; + let showInput: boolean = false; let updatedLabels: string[] = labels; let inputValue = ""; let validationMessage: string | undefined = undefined; let valid: boolean = false; let sanitizedValue: string | undefined = undefined; + const removeToggles: Record = {}; + $: { sanitizedValue = inputValue.trim(); @@ -42,110 +44,87 @@ if (valid && sanitizedValue) { updatedLabels = [...updatedLabels, sanitizedValue]; inputValue = ""; - if (mode === "readCreate") { - dispatch("save", updatedLabels); - } + dispatch("save", updatedLabels); + showInput = false; } } function removeLabel(label: string) { updatedLabels = updatedLabels.filter(x => x !== label); - if (mode === "readCreate") { - dispatch("save", updatedLabels); - } + dispatch("save", updatedLabels); + showInput = false; }
- diff --git a/src/views/projects/Issue/New.svelte b/src/views/projects/Issue/New.svelte index 22b869d71..58b125113 100644 --- a/src/views/projects/Issue/New.svelte +++ b/src/views/projects/Issue/New.svelte @@ -232,12 +232,10 @@