Skip to content

Commit

Permalink
fix move down button when there's only one editor
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Jul 30, 2024
1 parent 8c4ddf7 commit 6f1d877
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/Build.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@
on:remove={() => remove_file(i)}
on:up={() => move_file(i, -1)}
on:down={() => move_file(i, 1)}
pos={i ? (i === $files.length - 1 ? 2 : 1) : 0}
up={i > 0}
down={i < $files.length - 1}
header
rows={2}
label="INPUT"
Expand Down
7 changes: 4 additions & 3 deletions src/components/Editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
export let entry = false
export let readonly = false
export let lang = ''
export let pos = 0
export let up = false
export let down = false
const dispatch = createEventDispatcher()
Expand All @@ -36,10 +37,10 @@
<i class={entry ? 'i-mdi-checkbox-marked-outline' : 'i-mdi-checkbox-blank-outline'} />
</button>
<input placeholder="<stdin>" spellcheck="false" bind:value={name} />
<button class="move-up" title="move up" disabled={pos === 0} on:click={() => dispatch('up')}>
<button class="move-up" title="move up" disabled={!up} on:click={() => dispatch('up')}>
<i class="i-mdi-arrow-up" />
</button>
<button class="move-down" title="move down" disabled={pos === 2} on:click={() => dispatch('down')}>
<button class="move-down" title="move down" disabled={!down} on:click={() => dispatch('down')}>
<i class="i-mdi-arrow-down" />
</button>
<button class="remove" title="remove {name || 'it'}" on:click={() => dispatch('remove')}>
Expand Down

0 comments on commit 6f1d877

Please sign in to comment.