webcompile/src/lib/Nav.svelte

165 lines
3.0 KiB
Svelte
Raw Normal View History

<script lang="ts">
import ThemeToggle from "./ThemeToggle.svelte";
import { page } from "$app/stores";
$: currentPage = $page.url.pathname;
const menus = [
2022-08-08 10:50:03 +05:30
{ name: "Instances", url: "/instances" },
{ 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/" }
];
2022-07-27 22:15:53 +05:30
</script>
<nav>
<a class="brand" href="/">
2022-07-03 01:23:41 +05:30
<img src="/logo.png" alt="Project Segfault logo" />
2022-08-04 20:00:24 +05:30
<span>Project Segfault</span>
</a>
2022-07-27 22:20:48 +05:30
<input type="checkbox" id="toggle-menu" />
2022-07-27 22:15:53 +05:30
<label class="menu-icon" for="toggle-menu">
2022-08-08 13:16:52 +05:30
<div id="menu-icon" class="i-fa6-solid:bars">
2022-07-28 18:52:11 +05:30
</div>
2022-07-27 22:15:53 +05:30
</label>
2022-07-27 22:20:48 +05:30
<div class="links">
{#each menus as { url, name }}
2022-08-08 10:50:03 +05:30
<a
sveltekit:prefetch
class:active={url !== "/"
? currentPage.match(url)
: url === currentPage}
href={url}>{name}</a
>
{/each}
2022-08-04 21:20:02 +05:30
<a href="https://matrix.to/#/#project-segfault:projectsegfau.lt/">
2022-08-08 13:16:52 +05:30
<div class="i-simple-icons:matrix"></div>
2022-08-04 21:20:02 +05:30
</a>
<a href="https://github.com/ProjectSegfault/">
2022-08-08 13:16:52 +05:30
<div class="i-simple-icons:github"></div>
2022-08-04 21:20:02 +05:30
</a>
<div>
<ThemeToggle />
</div>
2022-07-27 22:20:48 +05:30
</div>
</nav>
<style>
nav {
2022-08-04 20:00:24 +05:30
background-color: var(--primary);
border-bottom: 1px solid var(--grey);
display: flex;
2022-08-05 19:31:15 +05:30
padding: 0.5rem;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
a.brand {
display: flex;
align-items: center;
text-decoration: none;
2022-08-04 20:00:24 +05:30
color: var(--text);
gap: 8px;
2022-08-05 19:31:15 +05:30
transition: opacity 0.25s;
2022-08-04 20:00:24 +05:30
}
a.active {
color: var(--accent);
}
2022-08-04 20:00:24 +05:30
a.brand:hover {
2022-08-05 19:31:15 +05:30
opacity: 0.6;
}
2022-07-27 22:20:48 +05:30
2022-07-27 22:15:53 +05:30
.links {
display: flex;
2022-07-27 22:20:48 +05:30
gap: 0.5rem;
2022-07-27 22:15:53 +05:30
}
.links > * {
2022-08-05 19:31:15 +05:30
padding: 0.5rem;
cursor: pointer;
color: var(--text);
text-decoration: none;
2022-08-05 19:31:15 +05:30
transition: color 0.25s;
2022-08-04 20:00:24 +05:30
font-size: 13px;
font-weight: 500;
2022-08-04 21:20:02 +05:30
display: flex;
align-items: center;
}
2022-06-18 11:15:20 +05:30
.links > *:hover {
text-decoration: none;
color: var(--accent);
}
img {
2022-08-04 20:00:24 +05:30
height: 30px;
border-radius: 50%;
}
2022-07-27 22:15:53 +05:30
.menu-icon {
cursor: pointer;
display: none;
}
#toggle-menu {
display: none;
}
@media screen and (max-width: 1058px) {
2022-07-27 22:15:53 +05:30
.links {
display: none;
width: 100%;
2022-08-04 20:00:24 +05:30
padding-top: 12px;
2022-07-27 22:15:53 +05:30
}
nav {
2022-07-27 22:15:53 +05:30
display: flex;
flex-direction: column;
align-items: flex-start;
}
2022-07-27 22:15:53 +05:30
.links a {
display: block;
}
.menu-icon {
2022-08-04 20:00:24 +05:30
display: flex;
align-items: center;
justify-content: center;
2022-07-27 22:15:53 +05:30
z-index: 1;
position: absolute;
right: 1rem;
2022-08-05 19:31:15 +05:30
top: 0.5rem;
2022-07-27 22:15:53 +05:30
border: none;
border-radius: 10px;
2022-08-04 20:00:24 +05:30
height: 30px;
width: 30px;
2022-07-27 22:15:53 +05:30
cursor: pointer;
line-height: 1;
}
#menu-icon {
display: flex;
align-items: center;
color: var(--text);
}
#toggle-menu:checked ~ .links {
display: flex;
flex-direction: column;
2022-07-27 22:15:53 +05:30
gap: 1rem;
}
}
2022-07-27 22:20:48 +05:30
</style>