homepage/src/lib/components/Header.svelte

212 lines
4.4 KiB
Svelte
Raw Normal View History

2023-06-19 20:38:45 +02:00
<script>
import "$lib/components/nordtheme.css"
import { onMount } from "svelte";
2023-07-18 18:09:31 +02:00
import Symbol from "./Symbol.svelte"
2023-06-25 14:42:37 +02:00
function toggle_sidebar(state){
// state: force hidden state (optional)
2023-06-25 14:42:37 +02:00
const nav_el = document.querySelector("nav")
if(state === undefined) nav_el.hidden = !nav_el.hidden
else nav_el.hidden = state
2023-06-25 14:42:37 +02:00
}
onMount( () => {
const link_els = document.querySelectorAll("nav a")
link_els.forEach((el) => {
el.addEventListener("click", () => {toggle_sidebar(true)});
})
})
2023-06-19 20:38:45 +02:00
</script>
<style>
:global(*){
2023-06-19 20:38:45 +02:00
box-sizing: border-box;
font-family: sans-serif;
2023-06-19 20:38:45 +02:00
}
:global(body){
margin:0;
padding:0;
background-color: #fbf9f3;
2023-06-25 14:42:37 +02:00
overflow-x: hidden;
}
2024-01-20 00:39:53 +01:00
@media (prefers-color-scheme: dark) {
:global(body){
color: white;
background-color: var(--background-dark);
}
}
2023-06-25 14:42:37 +02:00
nav{
position: sticky;
background-color: var(--nord0);
top: 0;
z-index: 10;
2023-07-18 18:09:31 +02:00
display: flex !important;
flex-direction: row;
justify-content: space-between !important;
align-items: center;
2023-06-25 14:42:37 +02:00
}
nav[hidden]{
display:block;
}
2023-07-18 18:09:31 +02:00
:global(.site_header li),
:global(a.entry)
2023-07-18 18:09:31 +02:00
{
2023-06-19 20:38:45 +02:00
list-style-type:none;
transition: 100ms;
color: white;
2023-06-25 12:15:20 +02:00
user-select: none;
2023-06-19 20:38:45 +02:00
}
2023-07-18 18:09:31 +02:00
:global(.site_header li>a),
:global(.entry)
2023-07-18 18:09:31 +02:00
{
2023-06-19 20:38:45 +02:00
text-decoration: none;
font-family: sans-serif;
font-size: 1.2rem;
2023-06-25 12:15:20 +02:00
color: inherit;
border-radius: 1000px;
padding: 0.5rem 1rem;
2023-06-19 20:38:45 +02:00
}
:global(.site_header li:hover),
2023-07-18 18:09:31 +02:00
:global(.site_header li:focus-within),
:global(.entry:hover),
:global(.entry:focus-visible)
{
2023-06-19 20:38:45 +02:00
cursor: pointer;
color: var(--red);
transform: scale(1.1,1.1);
}
:global(.site_header) {
2023-06-25 12:15:20 +02:00
padding-block: 1.5rem;
2023-06-19 20:38:45 +02:00
display: flex;
flex-direction: row;
gap: 1rem;
justify-content: space-evenly;
max-width: 1000px;
margin: 0;
2023-06-19 20:38:45 +02:00
margin-inline: auto;
}
2023-06-25 14:42:37 +02:00
.nav_button{
display: none;
}
.button_wrapper{
display: none;
2023-10-04 22:53:03 +02:00
padding-inline: 0.5rem;
2023-06-25 14:42:37 +02:00
}
2023-07-18 18:10:57 +02:00
:global(svg.symbol){
2023-07-18 18:09:31 +02:00
height: 3.5rem;
width: 3.5rem;
border-radius: 10000px;
}
2023-07-18 18:11:47 +02:00
:global(a:has(svg.symbol)){
2023-07-18 18:09:31 +02:00
padding: 0 !important;
width: 3.5rem;
height: 3.5rem;
margin-left: 1rem;
}
@media screen and (max-width: 800px) {
2023-06-25 14:42:37 +02:00
.button_wrapper{
display: flex;
2023-07-18 18:09:31 +02:00
justify-content: space-between;
2023-06-25 14:42:37 +02:00
align-items: center;
position: sticky;
background-color: var(--nord0);
width: 100%;
height: 4rem;
top: 0;
z-index: 9999;
}
.nav_button{
border: unset;
background-color: unset;
display: block;
fill: white;
margin-inline: 1rem;
2023-10-04 22:53:03 +02:00
width: 2.5rem;
2023-06-25 14:42:37 +02:00
aspect-ratio: 1;
}
.nav_button svg{
width: 100%;
height: 100%;
transition: 100ms;
}
.nav_button:focus{
fill: var(--red);
scale: 0.9;
2023-06-25 14:42:37 +02:00
}
nav{
position: fixed;
top: 0;
right: 0;
2023-07-18 18:09:31 +02:00
height: 100vh; /* dvh does not work, breaks because of transition and only being applied after scroll ends*/
margin-bottom: 50vh;
width: min(95svw, 25em);
2023-06-25 14:42:37 +02:00
transition: 100ms;
z-index: 10;
2023-07-18 18:09:31 +02:00
flex-direction: column;
justify-content: flex-start !important;
align-items: left;
justify-content: space-between!important;
padding-inline: 0.5rem;
}
:global(nav ul){
width: 100% ;
}
nav :first-child{
display:none;
2023-06-25 14:42:37 +02:00
}
nav[hidden]{
transform: translateX(100%);
}
2023-07-23 12:48:12 +02:00
nav a:last-child{
2023-07-18 18:09:31 +02:00
margin-bottom: 2rem;
}
2023-06-25 14:42:37 +02:00
:global(.site_header){
2023-06-25 14:42:37 +02:00
flex-direction: column;
padding-top: min(10rem, 10vh);
}
2023-07-18 18:09:31 +02:00
:global(.site_header li, .site_header a){
2023-06-25 14:42:37 +02:00
font-size: 4rem;
}
2023-07-18 18:09:31 +02:00
:global(.site_header li > a, .site_header a){
2023-06-25 14:42:37 +02:00
font-size: 2rem;
}
:global(.site_header li:hover),
:global(.site_header li:focus-within){
transform: unset;
}
}
2023-06-19 20:38:45 +02:00
.wrapper{
display:flex;
flex-direction: column;
min-height: 100svh;
2023-06-19 20:38:45 +02:00
}
footer{
padding-block: 1rem;
text-align: center;
2023-06-25 10:17:12 +02:00
margin-top: auto;
2023-06-19 20:38:45 +02:00
}
</style>
2023-07-13 23:15:13 +02:00
<div class=wrapper lang=de>
2023-06-19 20:38:45 +02:00
<div>
2023-06-25 14:42:37 +02:00
<div class=button_wrapper>
2023-07-18 18:09:31 +02:00
<a href="/"><Symbol></Symbol></a>
<button class=nav_button on:click={() => {toggle_sidebar()}}><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg></button>
2023-06-25 14:42:37 +02:00
</div>
<nav hidden>
2023-07-18 18:09:31 +02:00
<a class=entry href="/"><Symbol></Symbol></a>
<slot name=links></slot>
<slot name=right_side></slot>
2023-06-19 20:38:45 +02:00
</nav>
2023-06-19 20:38:45 +02:00
<slot></slot>
</div>
<footer>
Ad maiorem Dei gloriam
</footer>
</div>