|
13 | 13 | { text: 'Add-Ons', href: 'https://ankiweb.net/shared/addons' }, |
14 | 14 | { text: 'Shared Decks', href: 'https://ankiweb.net/shared/decks' }, |
15 | 15 | ]; |
| 16 | +
|
| 17 | + let scrollY = $state(0); |
| 18 | +
|
| 19 | + let isMenuOpen = $state(false); |
| 20 | + const toggleMenu = () => { |
| 21 | + isMenuOpen = !isMenuOpen; |
| 22 | + }; |
| 23 | + const closeMenu = () => { |
| 24 | + isMenuOpen = false; |
| 25 | + }; |
16 | 26 | </script> |
17 | 27 |
|
18 | | -<header |
19 | | - class="bg-background/90 backdrop-blur-lg sticky inset-x-0 top-0 z-10 border-b border-foreground/[13%]" |
20 | | -> |
21 | | - <div class="max-w-348 mx-auto"> |
22 | | - <div class="flex h-16 items-center justify-between gap-8 px-6"> |
| 28 | +<svelte:window bind:scrollY /> |
| 29 | + |
| 30 | +<header class="fixed top-0 left-0 right-0 z-50"> |
| 31 | + <div |
| 32 | + class="mx-auto w-full max-w-[1082px] px-6 md:px-12 flex items-center transition-all duration-500 ease-[linear(0,_0.178_4.5%,_0.336_9%,_0.477_13.6%,_0.604_18.4%,_0.713_23.3%,_0.762_25.8%,_0.806_28.3%,_0.847_30.9%,_0.884_33.5%,_0.917_36.2%,_0.946_38.9%,_0.969_41.3%,_0.989_43.8%,_1.006_46.4%,_1.02_49%,_1.032_51.7%,_1.041_54.5%,_1.048_57.3%,_1.051_60.3%,_1.053_65%,_1.048_70.2%,_1.039_75.7%,_1.008_91%,_1.002_95.7%,_1)] border-subtle/12 bg-background" |
| 33 | + class:pt-1={scrollY < 12} |
| 34 | + class:md:pt-6={scrollY < 12} |
| 35 | + class:border-b={scrollY > 6} |
| 36 | + > |
| 37 | + <div class="flex h-14 items-center justify-between w-full"> |
23 | 38 | <div class="flex gap-4"> |
24 | 39 | <a |
25 | 40 | href="#top" |
26 | | - class="flex items-center gap-2 shrink-0 [&>*]:pointer-events-none [&>*]:select-none" |
| 41 | + class="flex items-center gap-1.5 shrink-0 [&>*]:pointer-events-none [&>*]:select-none" |
27 | 42 | > |
28 | | - <img src="{base}/logo.svg" alt="Logo" class="size-7" /> |
29 | | - <span class="font-bold text-foreground text-xl leading-none tracking-widest"> Anki </span> |
| 43 | + <img src="{base}/logo.svg" alt="Logo" class="size-6" /> |
| 44 | + <span class="font-semibold text-foreground text-xl tracking-wide">Anki</span> |
30 | 45 | </a> |
31 | 46 | </div> |
32 | 47 | <div class="flex items-center h-full max-[832px]:hidden pr-8"> |
33 | 48 | {#each options as { text, href }} |
34 | 49 | <a |
35 | 50 | class="px-3 select-none transition-all duration-150 ease-out flex items-center text-foreground h-full hover:shadow-[inset_0_-2px_var(--color-primary)]" |
36 | | - target="_blank" |
37 | | - rel="noopener noreferrer" |
38 | 51 | {href} |
39 | 52 | > |
40 | 53 | {text} |
|
43 | 56 | <a |
44 | 57 | aria-label="GitHub repository" |
45 | 58 | href="https://github.com/ankitects/anki" |
46 | | - target="_blank" |
47 | | - rel="noopener noreferrer" |
48 | | - class="px-3 py-2 group" |
| 59 | + class="px-3 py-2 group pr-6" |
49 | 60 | > |
50 | 61 | <svg viewBox="0 0 20 20" class="size-5 fill-foreground group-hover:fill-primary"> |
51 | 62 | <path |
|
56 | 67 | </a> |
57 | 68 | <a |
58 | 69 | href="#downloads" |
59 | | - class="ml-3 rounded hover:opacity-80 bg-gradient-to-r from-primary-darker to-primary text-background h-12 flex items-center px-4 font-bold leading-none cursor-pointer transition-all duration-300 ease-out" |
| 70 | + class="rounded-[2rem] px-4 py-1.5 font-semibold tracking-tight transition-all duration-100 ease-out bg-gradient-to-r from-primary-darker to-primary text-background hover:opacity-80" |
60 | 71 | > |
61 | 72 | Download Anki |
62 | 73 | </a> |
|
66 | 77 | type="button" |
67 | 78 | class="relative inline-grid size-7 place-items-center rounded-md text-foreground" |
68 | 79 | aria-label="Navigation" |
69 | | - popovertarget="menu" |
| 80 | + onclick={toggleMenu} |
70 | 81 | > |
71 | 82 | <svg |
72 | 83 | xmlns="http://www.w3.org/2000/svg" |
|
81 | 92 | /> |
82 | 93 | </svg> |
83 | 94 | </button> |
84 | | - <div |
85 | | - id="menu" |
86 | | - popover="auto" |
87 | | - role="menu" |
88 | | - class="fixed top-0 left-0 size-full bg-background z-20 p-20" |
89 | | - > |
90 | | - <button |
91 | | - popovertarget="menu" |
92 | | - popovertargetaction="hide" |
93 | | - aria-label="Close menu" |
94 | | - class="text-foreground absolute top-6 right-6" |
| 95 | + {#if isMenuOpen} |
| 96 | + <div |
| 97 | + id="menu" |
| 98 | + role="menu" |
| 99 | + class="fixed top-0 left-0 size-full bg-background z-20 p-20 menu-open" |
95 | 100 | > |
96 | | - <svg |
97 | | - xmlns="http://www.w3.org/2000/svg" |
98 | | - viewBox="0 0 24 24" |
99 | | - fill="currentColor" |
100 | | - class="size-8" |
| 101 | + <button |
| 102 | + onclick={closeMenu} |
| 103 | + aria-label="Close menu" |
| 104 | + class="text-foreground absolute top-6 right-6" |
101 | 105 | > |
102 | | - <path |
103 | | - fill-rule="evenodd" |
104 | | - d="M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z" |
105 | | - clip-rule="evenodd" |
106 | | - /> |
107 | | - </svg> |
108 | | - </button> |
109 | | - <nav class="flex flex-col gap-4 h-full"> |
110 | | - {#each options as { text, href }} |
111 | | - <a |
112 | | - class="w-fit select-none transition-all gap-1 duration-150 ease-out text-3xl flex items-center text-foreground hover:shadow-[inset_0_-2px_#7EBBE5]" |
113 | | - {href} |
| 106 | + <svg |
| 107 | + xmlns="http://www.w3.org/2000/svg" |
| 108 | + viewBox="0 0 24 24" |
| 109 | + fill="currentColor" |
| 110 | + class="size-8" |
114 | 111 | > |
115 | | - {text} |
116 | | - <svg |
117 | | - xmlns="http://www.w3.org/2000/svg" |
118 | | - viewBox="0 0 16 16" |
119 | | - fill="currentColor" |
120 | | - class="size-8" |
| 112 | + <path |
| 113 | + fill-rule="evenodd" |
| 114 | + d="M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z" |
| 115 | + clip-rule="evenodd" |
| 116 | + /> |
| 117 | + </svg> |
| 118 | + </button> |
| 119 | + <nav class="flex flex-col gap-4 h-full"> |
| 120 | + {#each options as { text, href }} |
| 121 | + <a |
| 122 | + class="w-fit select-none transition-all gap-1 duration-150 ease-out text-3xl flex items-center text-foreground hover:shadow-[inset_0_-2px_#7EBBE5]" |
| 123 | + {href} |
121 | 124 | > |
122 | | - <path |
123 | | - fill-rule="evenodd" |
124 | | - d="M4.22 11.78a.75.75 0 0 1 0-1.06L9.44 5.5H5.75a.75.75 0 0 1 0-1.5h5.5a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-1.5 0V6.56l-5.22 5.22a.75.75 0 0 1-1.06 0Z" |
125 | | - clip-rule="evenodd" |
126 | | - /> |
127 | | - </svg> |
| 125 | + {text} |
| 126 | + <svg |
| 127 | + xmlns="http://www.w3.org/2000/svg" |
| 128 | + viewBox="0 0 16 16" |
| 129 | + fill="currentColor" |
| 130 | + class="size-8" |
| 131 | + > |
| 132 | + <path |
| 133 | + fill-rule="evenodd" |
| 134 | + d="M4.22 11.78a.75.75 0 0 1 0-1.06L9.44 5.5H5.75a.75.75 0 0 1 0-1.5h5.5a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-1.5 0V6.56l-5.22 5.22a.75.75 0 0 1-1.06 0Z" |
| 135 | + clip-rule="evenodd" |
| 136 | + /> |
| 137 | + </svg> |
| 138 | + </a> |
| 139 | + {/each} |
| 140 | + <a |
| 141 | + href="#downloads" |
| 142 | + onclick={closeMenu} |
| 143 | + class="text-center mt-auto rounded hover:opacity-80 bg-gradient-to-r from-primary-darker to-primary text-background py-4 text-lg flex items-center justify-center font-semibold leading-none cursor-pointer transition-all duration-300 ease-out" |
| 144 | + > |
| 145 | + Download Anki |
128 | 146 | </a> |
129 | | - {/each} |
130 | | - <a |
131 | | - href="#downloads" |
132 | | - onclick={() => { |
133 | | - document.getElementById('menu')?.hidePopover(); |
134 | | - }} |
135 | | - class="text-center mt-auto rounded hover:opacity-80 bg-gradient-to-r from-primary-darker to-primary text-background py-4 text-lg flex items-center justify-center font-semibold leading-none cursor-pointer transition-all duration-300 ease-out" |
136 | | - > |
137 | | - Download Anki |
138 | | - </a> |
139 | | - </nav> |
140 | | - </div> |
| 147 | + </nav> |
| 148 | + </div> |
| 149 | + {/if} |
141 | 150 | </div> |
142 | 151 | </div> |
143 | 152 | </div> |
|
152 | 161 | opacity: 1; |
153 | 162 | } |
154 | 163 | } |
155 | | - #menu { |
156 | | - &:popover-open { |
157 | | - animation: fadeIn 0.3s forwards ease-in; |
158 | | - } |
| 164 | + .menu-open { |
| 165 | + animation: fadeIn 0.3s forwards ease-in; |
159 | 166 | } |
160 | 167 | </style> |
0 commit comments