refactor: migrate to Svelte 5
use runes ($props, $state, $derived, $effect, etc)
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
|
||||
const { settings: { switcher_links } }: any = getContext('global')
|
||||
|
||||
let switcherEl: HTMLElement
|
||||
let isOpen = false
|
||||
let switcherEl = $state<HTMLElement>()
|
||||
let isOpen = $state(false)
|
||||
|
||||
|
||||
/**
|
||||
@@ -37,9 +37,11 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:click={windowClick} />
|
||||
<svelte:window onclick={windowClick} />
|
||||
|
||||
<aside class="switcher" bind:this={switcherEl}
|
||||
<aside
|
||||
bind:this={switcherEl}
|
||||
class="switcher"
|
||||
class:is-open={isOpen}
|
||||
use:reveal={{
|
||||
animation: { y: [24, 0], opacity: [0, 1] },
|
||||
@@ -50,12 +52,15 @@
|
||||
},
|
||||
}}
|
||||
>
|
||||
<button class="switcher__button" title="{!isOpen ? 'Open' : 'Close'} menu" tabindex="0"
|
||||
on:click={toggleSwitcher}
|
||||
<button
|
||||
class="switcher__button"
|
||||
title="{!isOpen ? 'Open' : 'Close'} menu"
|
||||
tabindex="0"
|
||||
onclick={toggleSwitcher}
|
||||
>
|
||||
<span>
|
||||
{#each Array(3) as _}
|
||||
<i />
|
||||
<i></i>
|
||||
{/each}
|
||||
</span>
|
||||
</button>
|
||||
@@ -63,7 +68,7 @@
|
||||
<ul class="switcher__links" data-sveltekit-noscroll>
|
||||
{#each switcher_links as { text, url, icon, icon_label }}
|
||||
<li class:is-active={$page.url.pathname === url}>
|
||||
<a href={url} on:click={toggleSwitcher} tabindex="0">
|
||||
<a href={url} onclick={toggleSwitcher} tabindex="0">
|
||||
<Icon class="icon" icon={icon} label={icon_label} />
|
||||
<span>{text}</span>
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user