Add editing to issue/patch descriptions, comments and replies

Also does some refactoring for `action`, `editable` and other variables
we were using which weren't very clear

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-10-26 16:27:54 +02:00
parent 9530af9ada
commit 5e5f7fc12f
22 changed files with 707 additions and 319 deletions
+62
View File
@@ -0,0 +1,62 @@
<script lang="ts">
import type { Embed } from "@app/lib/file";
import { createEventDispatcher } from "svelte";
import ExtendedTextarea from "@app/components/ExtendedTextarea.svelte";
const dispatch = createEventDispatcher<{
submit: {
comment: string;
embeds: Embed[];
};
}>();
export let body: string | undefined = undefined;
export let placeholder: string | undefined = undefined;
export let submitCaption: string | undefined = undefined;
export let enableAttachments: boolean = false;
export let inline: boolean = false;
export let focus: boolean = false;
export let submitInProgress: boolean = false;
let active: boolean = false;
</script>
<style>
.inactive {
box-shadow: 0 0 0 1px var(--color-border-hint);
border-radius: var(--border-radius-small);
padding: 0.5rem 0.75rem;
background-color: var(--color-background-dip);
font-size: var(--font-size-small);
color: var(--color-fill-gray);
cursor: text;
}
.inactive:hover {
box-shadow: 0 0 0 1px var(--color-border-default);
}
</style>
{#if active}
<ExtendedTextarea
{inline}
{placeholder}
{submitCaption}
{submitInProgress}
{focus}
{body}
{enableAttachments}
on:close={() => (active = false)}
on:submit={event => {
active = false;
dispatch("submit", event.detail);
}} />
{:else}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="inactive"
role="button"
tabindex="0"
on:click={() => (active = true)}>
{placeholder}
</div>
{/if}