website/src/lib/Nav.svelte

187 lines
3.2 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-09-10 21:28:19 +05:30
{ name: "Instances", url: "/instances" },
2022-08-08 10:50:03 +05:30
{ 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-12 16:45:39 +05:30
<div id="menu-icon" class="i-fa6-solid:bars" />
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
2022-08-30 22:36:58 +05:30
data-sveltekit-prefetch
2022-08-08 10:50:03 +05:30
class:active={url !== "/"
? currentPage.match(url)
: url === currentPage}
href={url}>{name}</a
>
{/each}
2022-09-10 21:28:19 +05:30
<a href="https://matrix.to/#/#project-segfault:projectsegfau.lt/" class="icon">
2022-08-12 16:45:39 +05:30
<div class="i-simple-icons:matrix" />
2022-09-10 21:28:19 +05:30
<span>Matrix</span>
2022-08-04 21:20:02 +05:30
</a>
2022-09-10 21:28:19 +05:30
<a href="https://github.com/ProjectSegfault/" class="icon">
2022-08-17 23:14:18 +05:30
<div class="i-simple-icons:github" />
2022-09-10 21:28:19 +05:30
<span>GitHub</span>
2022-08-04 21:20:02 +05:30
</a>
2022-09-10 21:28:19 +05:30
<div class="theme-toggle icon">
<ThemeToggle />
</div>
2022-07-27 22:20:48 +05:30
</div>
</nav>
2022-08-24 21:37:30 +05:30
<noscript>
<style>
.theme-toggle {
display: none !important;
}
</style>
</noscript>
<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;
}
2022-09-10 21:28:19 +05:30
.icon > span {
display: none;
}
@media screen and (max-width: 900px) {
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-09-10 21:28:19 +05:30
.icon > span {
display: block;
}
.icon {
display: flex !important;
align-items: center;
flex-direction: row;
gap: 0.5rem;
}
}
2022-07-27 22:20:48 +05:30
</style>