Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bottom Nav fixes for external control #2469

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/lib/components/bottom-nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,28 @@
let viewNamespaces = writable(false);
let viewSettings = false;

function escapeHandler(e: KeyboardEvent) {
if (
e.key === 'Escape' &&
[viewLinks, viewNamespaces, viewSettings].some((isOpen) => isOpen)
) {
closeMenu();
}
}

beforeNavigate(() => {
closeMenu();
});

$: namespace = $page.params.namespace || $lastUsedNamespace;
$: namespaceExists = namespaceList.some(
(namespaceListItem) => namespaceListItem.namespace === namespace,
);

const onLinksClick = () => {
viewSettings = false;
$viewNamespaces = false;
viewLinks = !viewLinks;
$viewNamespaces = false;
viewSettings = false;
};

const onNamespaceClick = () => {
Expand All @@ -50,11 +63,11 @@
viewSettings = !viewSettings;
};

beforeNavigate(() => {
function closeMenu() {
viewLinks = false;
viewSettings = false;
$viewNamespaces = false;
});
viewSettings = false;
}

$: menuIsOpen = viewLinks || $viewNamespaces || viewSettings;

Expand All @@ -66,6 +79,8 @@
};
</script>

<svelte:window on:keypress={escapeHandler} />

{#if menuIsOpen}
<div
class="group surface-primary fixed top-0 z-50 h-[calc(100%-64px)] w-full overflow-auto md:hidden"
Expand All @@ -74,7 +89,7 @@
out:slide={{ duration: 200, delay: 0 }}
>
<BottomNavLinks open={viewLinks} {linkList} />
<slot name="nsPicker" open={$viewNamespaces}>
<slot name="nsPicker" open={$viewNamespaces} {closeMenu}>
<BottomNavNamespaces open={$viewNamespaces} {namespaceList} />
</slot>
<BottomNavSettings open={viewSettings}>
Expand Down
Loading