Add issue embeds

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-09-27 16:40:49 +02:00
parent 2864a0311b
commit 1ef0f9dfd1
28 changed files with 585 additions and 107 deletions
+27 -10
View File
@@ -37,9 +37,9 @@
}
}
function removeAssignee({ detail: key }: { detail: number }) {
updatedAssignees = updatedAssignees.filter((_, i) => i !== key);
if (action === "create") {
function removeAssignee(remove: string) {
updatedAssignees = updatedAssignees.filter(assignee => assignee !== remove);
if (action === "create" || action === "edit") {
dispatch("save", updatedAssignees);
}
}
@@ -62,11 +62,25 @@
margin-bottom: 1.25rem;
}
.close {
color: inherit;
border: none;
border-bottom-right-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
background-color: transparent;
line-height: 1.5;
padding: 0;
cursor: pointer;
}
.close:hover {
color: var(--color-foreground);
}
.chip-content {
display: flex;
align-items: center;
width: 100%;
gap: 0.5rem;
white-space: nowrap;
}
</style>
@@ -97,15 +111,18 @@
{/if}
</div>
<div class="body">
{#each updatedAssignees as assignee, key (assignee)}
<Chip
on:remove={removeAssignee}
removeable={editInProgress || action === "create"}
{key}>
<div aria-label="chip" class="chip-content">
{#each updatedAssignees as assignee (assignee)}
<Chip actionable={editInProgress || action === "create"}>
<div slot="content" aria-label="chip" class="txt-overflow chip-content">
<Avatar inline nodeId={assignee} />
<span>{formatNodeId(assignee)}</span>
</div>
<button
slot="icon"
class="section close"
on:click={() => removeAssignee(assignee)}>
✕
</button>
</Chip>
{:else}
<div class="txt-missing">No assignees</div>
+52
View File
@@ -0,0 +1,52 @@
<script lang="ts" strictEvents>
import Chip from "@app/components/Chip.svelte";
import Clipboard from "@app/components/Clipboard.svelte";
export let embeds: { name: string; content: string }[] = [];
</script>
<style>
.header {
display: flex;
gap: 1rem;
align-items: center;
font-size: var(--font-size-small);
margin-bottom: 0.75rem;
color: var(--color-foreground-6);
}
.body {
display: flex;
flex-wrap: wrap;
flex-direction: row;
gap: 0.5rem;
margin-bottom: 1.25rem;
}
.chip-content {
display: flex;
align-items: center;
gap: 0.5rem;
width: 100%;
}
</style>
<div>
<div class="header">
<span>Attachments</span>
</div>
<div class="body">
{#each embeds as embed}
<Chip actionable>
<div slot="content" aria-label="chip" class="chip-content">
<span class="txt-overflow">{embed.name}</span>
</div>
<Clipboard
slot="icon"
text={`![${embed.name}](${embed.content.substring(4)})`}
tiny />
</Chip>
{:else}
<div class="txt-missing">No attachments</div>
{/each}
</div>
</div>
+2 -1
View File
@@ -4,7 +4,8 @@
export let title: string;
export let subtitle: string[];
export let error: Error;
// This is more explicit than the standard error type.
export let error: { message: string; stack?: string };
</script>
<Modal {title} emoji="🚨">
+24 -14
View File
@@ -24,7 +24,7 @@
} else {
updatedLabels = [...updatedLabels, sanitizedValue];
inputValue = "";
if (action === "create") {
if (action === "create" || action === "edit") {
dispatch("save", updatedLabels);
}
}
@@ -33,9 +33,9 @@
}
}
function removeLabel({ detail: key }: { detail: number }) {
updatedLabels = updatedLabels.filter((_, i) => i !== key);
if (action === "create") {
function removeLabel(remove: string) {
updatedLabels = updatedLabels.filter(label => label !== remove);
if (action === "create" || action === "edit") {
dispatch("save", updatedLabels);
}
}
@@ -57,10 +57,18 @@
gap: 0.5rem;
margin-bottom: 1.25rem;
}
.label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.close {
color: inherit;
border: none;
border-bottom-right-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
background-color: transparent;
line-height: 1.5;
padding: 0;
cursor: pointer;
}
.close:hover {
color: var(--color-foreground);
}
</style>
@@ -91,12 +99,14 @@
{/if}
</div>
<div class="metadata-section-body">
{#each updatedLabels as label, key (label)}
<Chip
on:remove={removeLabel}
removeable={editInProgress || action === "create"}
{key}>
<div aria-label="chip" class="label">{label}</div>
{#each updatedLabels as label}
<Chip actionable={editInProgress || action === "create"}>
<div slot="content" aria-label="chip" class="txt-overflow">{label}</div>
<div slot="icon">
<button class="section close" on:click={() => removeLabel(label)}>
✕
</button>
</div>
</Chip>
{:else}
<div class="txt-missing">No labels</div>