Cleanup Switcher code

This commit is contained in:
2021-11-17 21:41:08 +01:00
parent 873c2d94ac
commit 78cacbcd46

View File

@@ -1,14 +1,9 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher } from 'svelte'
// Components
import Icon from '$components/atoms/Icon.svelte' import Icon from '$components/atoms/Icon.svelte'
let switcherEl: HTMLElement let switcherEl: HTMLElement
let isOpen = false let isOpen = false
const dispatch = createEventDispatcher()
// Links // Links
const links = [ const links = [
{ {
@@ -44,9 +39,9 @@
* Detect outside click * Detect outside click
*/ */
const windowClick = ({ target }) => { const windowClick = ({ target }) => {
if (!switcherEl.contains(target)) { if (!switcherEl.contains(target) && isOpen) {
// Close switcher // Close switcher
isOpen = false toggleSwitcher()
} }
} }
</script> </script>