Skip to content

Commit 2342e90

Browse files
committed
Move About Us and Home to main nav, add dropdown animation and some colors
1 parent 7ed6930 commit 2342e90

File tree

4 files changed

+73
-17
lines changed

4 files changed

+73
-17
lines changed

src/components/MobileMenu.astro

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ const {
7171
>{menu.donate}</a
7272
>
7373
</li>
74-
<li>
75-
<a href={getLocalePath('/about')} class="block text-dark hover:text-coral"
76-
>{menu.aboutUs}</a
77-
>
78-
</li>
7974
<li>
8075
<a href="https://docs.zen-browser.app" class="block text-dark hover:text-coral"
8176
>{menu.documentation}</a
@@ -91,6 +86,10 @@ const {
9186
</ul>
9287
</li>
9388
<!-- Extra Links -->
89+
<li>
90+
<a href={getLocalePath('/about')} class="block text-dark hover:text-coral">{menu.aboutUs}</a
91+
>
92+
</li>
9493
<li>
9594
<a href={getLocalePath('/mods')} class="block font-bold text-dark hover:text-coral"
9695
>{menu.mods}</a

src/components/NavBar.astro

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ const {
3131
<div
3232
class="hidden items-center gap-6 place-self-center text-xs sm:text-sm lg:flex lg:text-base"
3333
>
34+
<a
35+
class={`hidden items-center hover:bg-muted rounded-lg p-3 lg:block${Astro.url.pathname === getLocalePath('/') ? ' text-coral' : ''}`}
36+
href={getLocalePath('/')}
37+
>
38+
<span>{menu.home}</span>
39+
</a>
40+
3441
<Dropdown class="group">
35-
<button class="flex items-center">
42+
<button class="flex items-center rounded-lg p-3 hover:bg-muted group-open:bg-muted">
3643
<span>{menu.gettingStarted}</span>
3744
<ChevronDownIcon
3845
class="size-4 transform transition-transform duration-200 group-open:rotate-180 md:ml-2"
@@ -66,7 +73,7 @@ const {
6673
</DropdownItems>
6774
</Dropdown>
6875
<Dropdown class="group">
69-
<button class="flex items-center">
76+
<button class="flex items-center rounded-lg p-3 hover:bg-muted group-open:bg-muted">
7077
<span>{menu.usefulLinks}</span>
7178
<ChevronDownIcon
7279
class="size-4 transform transition-transform duration-200 group-open:rotate-180 md:ml-2"
@@ -80,12 +87,6 @@ const {
8087
{menu.donateDesc}
8188
</div>
8289
</a>
83-
<a class="dropdown-item" href={getLocalePath('/about')}>
84-
<div class="dropdown-title">{menu.aboutUs}</div>
85-
<div class="dropdown-description">
86-
{menu.aboutUsDesc}
87-
</div>
88-
</a>
8990
<a class="dropdown-item" href="https://docs.zen-browser.app">
9091
<div class="dropdown-title">{menu.documentation}</div>
9192
<div class="dropdown-description">
@@ -101,7 +102,16 @@ const {
101102
</div>
102103
</DropdownItems>
103104
</Dropdown>
104-
<a class="hidden items-center lg:block" href={getLocalePath('/mods')}>
105+
<a
106+
class={`hidden items-center hover:bg-muted rounded-lg p-3 lg:block${Astro.url.pathname === getLocalePath('/about') ? ' text-coral' : ''}`}
107+
href={getLocalePath('/about')}
108+
>
109+
<span>{menu.aboutUs}</span>
110+
</a>
111+
<a
112+
class={`hidden items-center hover:bg-muted rounded-lg p-3 lg:block${Astro.url.pathname === getLocalePath('/mods') ? ' text-coral' : ''}`}
113+
href={getLocalePath('/mods')}
114+
>
105115
<span>{menu.mods}</span>
106116
</a>
107117
</div>
@@ -135,7 +145,7 @@ const {
135145

136146
<style>
137147
.navbar-dropdown {
138-
@apply absolute left-1/2 mt-2 grid !-translate-x-1/2 !transform grid-cols-2 gap-2 rounded-lg border-2 border-dark bg-paper p-3 shadow-sm;
148+
@apply absolute left-1/2 mt-2 grid !-translate-x-1/2 !transform grid-cols-2 gap-2 rounded-lg border border-dark bg-paper p-3 shadow-lg;
139149
& .dropdown-item {
140150
@apply flex cursor-pointer select-none flex-col gap-2 rounded-lg p-4 transition-colors duration-200;
141151

@@ -158,3 +168,48 @@ const {
158168
@apply text-dark;
159169
}
160170
</style>
171+
<script>
172+
import { animate, stagger } from 'animejs'
173+
174+
function animateDropdown(dropdown: Element) {
175+
animate(dropdown, {
176+
opacity: { from: 0, to: 1 },
177+
filter: { from: 'blur(4px)', to: 'blur(0px)' },
178+
duration: 300,
179+
easing: 'cubicBezier(0.25, 0.1, 0.25, 1)',
180+
})
181+
182+
const items = dropdown.querySelectorAll('.dropdown-item')
183+
if (items.length) {
184+
animate(items, {
185+
opacity: { from: 0, to: 1 },
186+
translateY: { from: 20, to: 0 },
187+
filter: { from: 'blur(4px)', to: 'blur(0px)' },
188+
duration: 300,
189+
delay: stagger(150),
190+
easing: 'cubicBezier(0.25, 0.1, 0.25, 1)',
191+
})
192+
}
193+
}
194+
195+
// Initialize dropdown animations on page load and when toggles are shown
196+
document.addEventListener('DOMContentLoaded', () => {
197+
document.querySelectorAll('.dropdown-toggle').forEach(toggle => {
198+
const dropdown = toggle.querySelector('.navbar-dropdown')
199+
if (!dropdown) return
200+
201+
if (!toggle.classList.contains('hidden')) {
202+
animateDropdown(dropdown)
203+
}
204+
205+
const observer = new MutationObserver(mutations => {
206+
mutations.forEach(mutation => {
207+
if (mutation.attributeName === 'class' && !toggle.classList.contains('hidden')) {
208+
animateDropdown(dropdown)
209+
}
210+
})
211+
})
212+
observer.observe(toggle, { attributes: true })
213+
})
214+
})
215+
</script>

src/i18n/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@
489489
"nav": {
490490
"brand": "Zen Browser",
491491
"menu": {
492+
"home": "Home",
492493
"gettingStarted": "Getting Started",
493494
"usefulLinks": "Useful Links",
494495
"mods": "Mods",
@@ -502,7 +503,7 @@
502503
"discordDesc": "Join our community on Discord to chat with other Zen users!",
503504
"donate": "Donate ❤️",
504505
"donateDesc": "Support the development of Zen with a donation.",
505-
"aboutUs": "About Us 🌟",
506+
"aboutUs": "About Us",
506507
"aboutUsDesc": "Learn more about the team behind Zen.",
507508
"documentation": "Documentation",
508509
"documentationDesc": "Learn how to use Zen with our documentation.",

src/i18n/ja/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@
494494
"nav": {
495495
"brand": "Zenブラウザー",
496496
"menu": {
497+
"home": "ホーム",
497498
"gettingStarted": "はじめに",
498499
"usefulLinks": "便利なリンク",
499500
"mods": "Mods",
@@ -507,7 +508,7 @@
507508
"discordDesc": "Discordコミュニティで他のZenユーザーと交流!",
508509
"donate": "寄付 ❤️",
509510
"donateDesc": "Zen開発を寄付で応援。",
510-
"aboutUs": "私たちについて 🌟",
511+
"aboutUs": "私たちについて",
511512
"aboutUsDesc": "Zenのチームについて知る。",
512513
"documentation": "ドキュメント",
513514
"documentationDesc": "ドキュメントでZenの使い方を学ぶ。",

0 commit comments

Comments
 (0)