From 3a5e961d540fdb70f2430706617801fd4c4622c3 Mon Sep 17 00:00:00 2001 From: OllyNicholass Date: Thu, 24 Oct 2024 00:28:28 +0100 Subject: [PATCH] feat(#35): add new mobile menu --- src/lib/components/CookieConsent.svelte | 7 +- src/lib/components/Dropdown.svelte | 74 ++++---- src/lib/components/Nav.svelte | 222 +++++++++++++----------- src/lib/components/NavLinkParent.svelte | 43 ++++- src/lib/components/NavLinks.svelte | 20 ++- src/routes/+layout.svelte | 99 +++++------ 6 files changed, 264 insertions(+), 201 deletions(-) diff --git a/src/lib/components/CookieConsent.svelte b/src/lib/components/CookieConsent.svelte index 09984b7..8872559 100644 --- a/src/lib/components/CookieConsent.svelte +++ b/src/lib/components/CookieConsent.svelte @@ -1,5 +1,7 @@ {#if showBanner} -
+

We use cookies to ensure you get the best experience on our website. By continuing, you agree to our use of cookies. diff --git a/src/lib/components/Dropdown.svelte b/src/lib/components/Dropdown.svelte index 3940f8a..0c3c645 100644 --- a/src/lib/components/Dropdown.svelte +++ b/src/lib/components/Dropdown.svelte @@ -1,43 +1,51 @@ -

- - -
\ No newline at end of file +
+ + {#if isOpen} + + {/if} +
diff --git a/src/lib/components/Nav.svelte b/src/lib/components/Nav.svelte index 6018b49..5879ace 100644 --- a/src/lib/components/Nav.svelte +++ b/src/lib/components/Nav.svelte @@ -1,110 +1,136 @@ - diff --git a/src/lib/components/NavLinkParent.svelte b/src/lib/components/NavLinkParent.svelte index b15005a..57ea726 100644 --- a/src/lib/components/NavLinkParent.svelte +++ b/src/lib/components/NavLinkParent.svelte @@ -1,14 +1,39 @@ - -
{text}
- {#each children ?? [] as child} -
  • {child.text}
  • - {/each} -
    \ No newline at end of file +{#if !isMobile} + +
    {text}
    + {#each children ?? [] as child} +
  • {child.text}
  • + {/each} +
    +{:else} + + {#if isOpen} + + {/if} +{/if} diff --git a/src/lib/components/NavLinks.svelte b/src/lib/components/NavLinks.svelte index b7643b1..51c657e 100644 --- a/src/lib/components/NavLinks.svelte +++ b/src/lib/components/NavLinks.svelte @@ -2,10 +2,12 @@ import { type NavLinkItem } from '$lib/types/Nav/NavLinkItem'; import NavLinkParent from './NavLinkParent.svelte'; + export let isMobile = false; + const links: NavLinkItem[] = [ { text: 'Products', - href: '/products', + href: '/products' }, { text: 'Parent', @@ -13,26 +15,26 @@ children: [ { text: 'Submenu 1', - href: '/', + href: '/' }, { text: 'Submenu 2', - href: '/', - }, - ], + href: '/' + } + ] }, { text: 'Example Product', - href: '/tools/exampleproduct', - }, + href: '/tools/exampleproduct' + } ]; -
      +
        {#each links as link}
      • {#if link.isParent} - + {:else} {link.text} {/if} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index e9471e0..600a745 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -6,13 +6,13 @@ import { invalidate } from '$app/navigation'; import CookieConsent from '$lib/components/CookieConsent.svelte'; import Nav from '$lib/components/Nav.svelte'; + import { slide } from 'svelte/transition'; + import { cubicInOut } from 'svelte/easing'; export let data; let { supabase, session } = data; $: ({ supabase, session } = data); - - let localGeneral: any; const unsubscribeToGeneralStore = general.subscribe((value) => { localGeneral = value; @@ -40,10 +40,6 @@ return () => data.subscription.unsubscribe(); }); - - - - @@ -126,52 +122,53 @@ - +{/if}