nsarrazin HF Staff commited on
Commit
4f54883
·
1 Parent(s): a4df227

feat: add animation for sidebar & move logo up a bit

Browse files
Files changed (1) hide show
  1. src/lib/components/MobileNav.svelte +20 -16
src/lib/components/MobileNav.svelte CHANGED
@@ -5,6 +5,7 @@
5
  import { page } from "$app/state";
6
  import IconNew from "$lib/components/icons/IconNew.svelte";
7
  import { createEventDispatcher } from "svelte";
 
8
  import CarbonClose from "~icons/carbon/close";
9
  import CarbonTextAlignJustify from "~icons/carbon/text-align-justify";
10
 
@@ -58,19 +59,22 @@
58
  class="-mr-3 flex size-12 shrink-0 items-center justify-center text-lg"><IconNew /></a
59
  >
60
  </nav>
61
- <nav
62
- class="fixed inset-0 z-30 grid max-h-screen grid-cols-1 grid-rows-[auto,auto,1fr,auto] bg-white dark:bg-gray-900 {isOpen
63
- ? 'block'
64
- : 'hidden'}"
65
- >
66
- <div class="flex h-12 items-center px-4">
67
- <button
68
- type="button"
69
- class="-mr-3 ml-auto flex size-12 items-center justify-center text-lg"
70
- onclick={() => dispatch("toggle", false)}
71
- aria-label="Close menu"
72
- bind:this={closeEl}><CarbonClose /></button
73
- >
74
- </div>
75
- {@render children?.()}
76
- </nav>
 
 
 
 
5
  import { page } from "$app/state";
6
  import IconNew from "$lib/components/icons/IconNew.svelte";
7
  import { createEventDispatcher } from "svelte";
8
+ import { fly } from "svelte/transition";
9
  import CarbonClose from "~icons/carbon/close";
10
  import CarbonTextAlignJustify from "~icons/carbon/text-align-justify";
11
 
 
59
  class="-mr-3 flex size-12 shrink-0 items-center justify-center text-lg"><IconNew /></a
60
  >
61
  </nav>
62
+
63
+ {#if isOpen}
64
+ <nav
65
+ class="fixed inset-0 z-30 grid max-h-screen grid-cols-1 grid-rows-[auto,auto,1fr,auto] bg-white pt-4 dark:bg-gray-900"
66
+ in:fly={{ x: -window.innerWidth, duration: 250 }}
67
+ out:fly={{ x: -window.innerWidth, duration: 250 }}
68
+ >
69
+ <div class="absolute inset-0 z-10 flex h-12 items-center px-4">
70
+ <button
71
+ type="button"
72
+ class="-mr-3 ml-auto flex size-12 items-center justify-center text-lg"
73
+ onclick={() => dispatch("toggle", false)}
74
+ aria-label="Close menu"
75
+ bind:this={closeEl}><CarbonClose /></button
76
+ >
77
+ </div>
78
+ {@render children?.()}
79
+ </nav>
80
+ {/if}