Skip to content

Commit

Permalink
Make animations slightly nicer on edit button
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Jan 28, 2025
1 parent 1770728 commit 74c1b1d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/navbar/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@
document.documentElement.dataset.scroll =
window.scrollY < 20 ? 'top' : 'page';
}
function editButtonClick() {
if (editing) {
onEditFinish?.();
} else {
onEditBegin?.();
}
}
</script>

<svelte:window {onscroll} />
Expand All @@ -148,11 +156,13 @@
<span id="control-buttons">
{#if loggedIn}
{#if editable}
{#if editing}
<Button onclick={onEditFinish} mode="confirm">Finish editing</Button>
{:else}
<Button onclick={onEditBegin}>Edit</Button>
{/if}
<!-- Use the one button so that animations persist between states -->
<Button
onclick={editButtonClick}
mode={editing ? 'confirm' : 'default'}
>
{editing ? 'Finish editing' : 'Edit'}
</Button>
{/if}
<Button onclick={() => goto('/admin')}>Admin</Button>
<Button onclick={logOut}>Log out</Button>
Expand Down

0 comments on commit 74c1b1d

Please sign in to comment.