From b7e39b59fd0fc7b5610ebff29035bf622079e0d8 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Wed, 5 Oct 2022 20:45:21 +0800
Subject: refactor: Change file structure

---
 .../web-shared/src/components/menu/menu.svelte     | 54 ----------------------
 1 file changed, 54 deletions(-)
 delete mode 100644 old-apps/web-shared/src/components/menu/menu.svelte

(limited to 'old-apps/web-shared/src/components/menu/menu.svelte')

diff --git a/old-apps/web-shared/src/components/menu/menu.svelte b/old-apps/web-shared/src/components/menu/menu.svelte
deleted file mode 100644
index 33517ab..0000000
--- a/old-apps/web-shared/src/components/menu/menu.svelte
+++ /dev/null
@@ -1,54 +0,0 @@
-<script lang="ts">
-    import {random_string} from "$shared/lib/helpers";
-
-    export const id = "__menu_" + random_string(3);
-    export let trigger: HTMLElement;
-    export let show = false;
-
-    let windowInnerWidth = 0;
-    let windowInnerHeight = 0;
-    let menu: HTMLMenuElement;
-
-    $: if (show && menu && trigger) {
-        const
-            selectedTriggerPosition = trigger.getBoundingClientRect(),
-            menuOnTop = (windowInnerHeight - selectedTriggerPosition.bottom) < selectedTriggerPosition.top,
-            left = selectedTriggerPosition.left,
-            right = (windowInnerWidth - selectedTriggerPosition.right),
-            isRight = (windowInnerWidth < selectedTriggerPosition.left + menu.offsetWidth),
-            vertical = menuOnTop
-                ? "bottom: " + (windowInnerHeight - selectedTriggerPosition.top) + "px;"
-                : "top: " + selectedTriggerPosition.bottom + "px;";
-
-        let horizontal = isRight ? "right: " + right + "px;" : "left: " + left + "px;";
-
-        // check right position is correct -> otherwise set left to 0
-        if (isRight && (right + menu.offsetWidth) > windowInnerWidth) horizontal = ("left: " + (windowInnerWidth - menu.offsetWidth) / 2 + "px;");
-        const maxHeight = menuOnTop ? selectedTriggerPosition.top - 20 : windowInnerHeight - selectedTriggerPosition.bottom - 20;
-        menu.setAttribute("style", horizontal + vertical + "max-height:" + Math.floor(maxHeight) + "px;");
-    }
-    
-    function on_window_click(event) {
-        if (!event.target.closest("#" + id) && !event.target.closest("[aria-controls='" + id + "']")) show = false;
-    }
-
-    function on_window_touchend(event) {
-        if (!event.target.closest("#" + id) && !event.target.closest("[aria-controls='" + id + "']")) show = false;
-    }
-</script>
-
-<svelte:window
-        on:click={on_window_click}
-        on:touchend={on_window_touchend}
-        bind:innerWidth={windowInnerWidth}
-        bind:innerHeight={windowInnerHeight}
-/>
-
-<menu class="menu"
-      id="{id}"
-      bind:this={menu}
-      class:menu--is-visible={show}
-      aria-expanded="{show}"
-      aria-haspopup="true">
-    <slot name="options"/>
-</menu>
-- 
cgit v1.3

