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

Nav bar II #18

Merged
merged 6 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
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
29 changes: 13 additions & 16 deletions src/lib/components/Navbar.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<script>
import Fa from 'svelte-fa';
import sucuLogo from '/src/lib/icons/sucu_logo_1.svg';
import { faBars } from '@fortawesome/free-solid-svg-icons';

let isMenuOpen = false;
const toggleMenu = () => {
isMenuOpen = !isMenuOpen;
Expand All @@ -13,30 +17,22 @@
</script>

<nav class="bg-sucu-pink-01 p-4 px-11 flex justify-between items-center">
<div class="flex items-center space-x-3 z-50">
<img src="/sucu_logo_1.svg" alt="Logo" class="h-12" />
<a href="/" class="flex items-center space-x-3 z-50">
<img alt="Logo" class="h-12" src={sucuLogo} />
<div class="hidden md:block text-white font-bold">
<p>สโมสรนิสิต</p>
<p>จุฬาลงกรณ์มหาวิทยาลัย</p>
</div>
</div>
</a>

{#if isMenuOpen}
<button class="text-white text-4xl self-end focus:outline-none z-50" on:click={toggleMenu}>
<div class="fixed inset-0 bg-gray-700 bg-opacity-40 backdrop-blur-sm" />
<button class="text-white md:hidden text-4xl focus:outline-none z-50" on:click={toggleMenu}>
&times;
</button>
{:else}
punchanabu marked this conversation as resolved.
Show resolved Hide resolved
<button class="block md:hidden text-white focus:outline-none z-50" on:click={toggleMenu}>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-8 w-8"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16m-7 6h7" />
</svg>
<Fa icon={faBars} class="text-2xl" />
</button>
{/if}

Expand All @@ -47,9 +43,9 @@
</div>

<div
class="fixed inset-0 bg-sucu-pink-01 flex flex-col items-end justify-end space-y-8 p-8 text-white transform duration-300 ease-in-out"
punchanabu marked this conversation as resolved.
Show resolved Hide resolved
class:menu-open={isMenuOpen}
class="absolute inset-0 bg-sucu-pink-01 md:hidden flex flex-col items-end h-[800px] justify-end space-y-8 p-8 text-white transform duration-300 ease-in-out"
class:menu-closed={!isMenuOpen}
class:menu-open={isMenuOpen}
>
{#each navItems as item}
<a href={item.href} class="text-white text-lg hover:underline">{item.name}</a>
Expand All @@ -61,6 +57,7 @@
.menu-open {
transform: translateY(-60%);
}

.menu-closed {
transform: translateY(-100%);
}
Expand Down
File renamed without changes
Loading