Skip to content

Commit

Permalink
update GistDescription.svelte to 5
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Jun 25, 2024
1 parent 09e6ded commit 56c96c6
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions frontend/src/gisteditor/GistDescription.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<svelte:options runes={true} />

<script>
import { len, removeDescriptionAd } from "../util.js";
import { tooltip } from "../actions/tooltip.js";
export let gist = {};
/** @typedef { import("./EditorCodeMirror.svelte").Gist } Gist */
/**
@type {{
gist: Gist,
descriptionChanged: (s: string) => void,
}}
*/
let { gist, descriptionChanged = (s) => {} } = $props();
// function to call when description changes
export let descriptionChanged = function (s) {};
let description = $state(removeDescriptionAd(gist.description));
let description = removeDescriptionAd(gist.description);
let editingDescription = null;
let editingDescription = $state(null);
let gistType = "";
let gistType = $state("");
if (!gist.public) {
gistType = "private";
}
Expand Down Expand Up @@ -54,14 +61,14 @@
}
</script>

<!-- svelte-ignore a11y_click_events_have_key_events -->
{#if editingDescription === null}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
role="button"
tabindex=""
class="truncate"
use:tooltip={"Click to edit description"}
on:click={startEditDescription}
onclick={startEditDescription}
class:no-description={!description}
>
{description || "no description"}
Expand All @@ -75,15 +82,15 @@
{/if}
<div class="flex-grow"></div>
{:else}
<!-- svelte-ignore a11y-autofocus -->
<!-- svelte-ignore a11y_autofocus -->
<input
class="flex-grow outline-none w-full border border-gray-400"
autofocus
spellcheck={false}
bind:value={editingDescription}
on:focus={selectDescriptionInput}
on:blur={closeDescriptionEdit}
on:keydown={descriptionEditKeyDown}
onfocus={selectDescriptionInput}
onblur={closeDescriptionEdit}
onkeydown={descriptionEditKeyDown}
/>
{/if}

Expand Down

0 comments on commit 56c96c6

Please sign in to comment.