website/src/lib/Nav.svelte
2022-08-30 20:06:58 +03:00

172 lines
3.1 KiB
Svelte

<script lang="ts">
import ThemeToggle from "./ThemeToggle.svelte";
import { page } from "$app/stores";
$: currentPage = $page.url.pathname;
const menus = [
{ name: "Services", url: "/services" },
{ name: "Projects", url: "/projects" },
{ name: "Minecraft", url: "/minecraft" },
{ name: "Donate", url: "/donate" },
{ name: "FAQ", url: "/faq" },
{ name: "Contact us", url: "/contact" },
{ name: "Our team", url: "/team" },
{ name: "Timeline", url: "/timeline" },
{ name: "Blog", url: "https://blog.projectsegfau.lt/" },
{ name: "Legal", url: "/legal" },
{ name: "Status", url: "https://status.projectsegfau.lt/" }
];
</script>
<nav>
<a class="brand" href="/">
<img src="/logo.png" alt="Project Segfault logo" />
<span>Project Segfault</span>
</a>
<input type="checkbox" id="toggle-menu" />
<label class="menu-icon" for="toggle-menu">
<div id="menu-icon" class="i-fa6-solid:bars" />
</label>
<div class="links">
{#each menus as { url, name }}
<a
data-sveltekit-prefetch
class:active={url !== "/"
? currentPage.match(url)
: url === currentPage}
href={url}>{name}</a
>
{/each}
<a href="https://matrix.to/#/#project-segfault:projectsegfau.lt/">
<div class="i-simple-icons:matrix" />
</a>
<a href="https://github.com/ProjectSegfault/">
<div class="i-simple-icons:github" />
</a>
<div class="theme-toggle">
<ThemeToggle />
</div>
</div>
</nav>
<noscript>
<style>
.theme-toggle {
display: none !important;
}
</style>
</noscript>
<style>
nav {
background-color: var(--primary);
border-bottom: 1px solid var(--grey);
display: flex;
padding: 0.5rem;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
a.brand {
display: flex;
align-items: center;
text-decoration: none;
color: var(--text);
gap: 8px;
transition: opacity 0.25s;
}
a.active {
color: var(--accent);
}
a.brand:hover {
opacity: 0.6;
}
.links {
display: flex;
gap: 0.5rem;
}
.links > * {
padding: 0.5rem;
cursor: pointer;
color: var(--text);
text-decoration: none;
transition: color 0.25s;
font-size: 13px;
font-weight: 500;
display: flex;
align-items: center;
}
.links > *:hover {
text-decoration: none;
color: var(--accent);
}
img {
height: 30px;
border-radius: 50%;
}
.menu-icon {
cursor: pointer;
display: none;
}
#toggle-menu {
display: none;
}
@media screen and (max-width: 1058px) {
.links {
display: none;
width: 100%;
padding-top: 12px;
}
nav {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.links a {
display: block;
}
.menu-icon {
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
position: absolute;
right: 1rem;
top: 0.5rem;
border: none;
border-radius: 10px;
height: 30px;
width: 30px;
cursor: pointer;
line-height: 1;
}
#menu-icon {
display: flex;
align-items: center;
color: var(--text);
}
#toggle-menu:checked ~ .links {
display: flex;
flex-direction: column;
gap: 1rem;
}
}
</style>