207 lines
4.2 KiB
Svelte
207 lines
4.2 KiB
Svelte
<script lang="ts">
|
|
import NavLink from "./NavLink.svelte";
|
|
import {getContext} from "svelte";
|
|
import type {Writable} from "svelte/store";
|
|
import FaHome from 'svelte-icons/fa/FaHome.svelte'
|
|
import {afterNavigate} from "$app/navigation";
|
|
import FaUser from 'svelte-icons/fa/FaUser.svelte'
|
|
import FaSignOutAlt from 'svelte-icons/fa/FaSignOutAlt.svelte'
|
|
|
|
const {isAuth, username, logout} = getContext<{ isAuth: Writable<boolean>, username: Writable<string | null> }>('auth');
|
|
let open = false
|
|
afterNavigate(() => {
|
|
open = false
|
|
})
|
|
</script>
|
|
|
|
<nav data-sveltekit-preload-data="hover" class:open>
|
|
<div class="navigate">
|
|
<NavLink href="/" exact no_hover>
|
|
<div class="icon">
|
|
<FaHome/>
|
|
</div>
|
|
</NavLink>
|
|
<NavLink href="/exercices">Exercices</NavLink>
|
|
<NavLink href="/room">Salles</NavLink>
|
|
|
|
</div>
|
|
<div class="auth">
|
|
{#if $isAuth && $username != null}
|
|
|
|
<NavLink href="/dashboard">
|
|
<div class="dashboard">
|
|
<div class="icon">
|
|
<FaUser/>
|
|
</div>
|
|
{$username}</div>
|
|
</NavLink>
|
|
<div class="icon signout" title="Se déconnecter" on:click={()=>{
|
|
logout()
|
|
}}><FaSignOutAlt /></div>
|
|
|
|
{:else}
|
|
<NavLink href="/signup" exact>S'inscrire</NavLink>
|
|
<NavLink href="/signin" exact>Se connecter</NavLink>
|
|
{/if}
|
|
<div class="burger" on:click={()=>{open=!open}}><span> </span></div>
|
|
</div>
|
|
|
|
|
|
</nav>
|
|
<style lang="scss">
|
|
@import "../mixins";
|
|
|
|
nav {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 10px;
|
|
padding: 30px 15px;
|
|
border-bottom: 1px solid $border;
|
|
width: 100%;
|
|
gap: 10px;
|
|
height: 30px;
|
|
//transition: .3s;
|
|
> div {
|
|
display: flex;
|
|
gap: 20px;
|
|
align-items: stretch;
|
|
height: 30px;
|
|
}
|
|
|
|
.icon {
|
|
width: 23px;
|
|
height: 23px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
}
|
|
|
|
.dashboard {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
|
|
.icon {
|
|
width: 15px;
|
|
height: 15px;
|
|
}
|
|
}
|
|
|
|
.signout {
|
|
cursor: pointer;
|
|
transition: .3s;
|
|
color: $primary-dark;
|
|
|
|
&:hover {
|
|
color: $primary;
|
|
}
|
|
}
|
|
|
|
.burger {
|
|
background: 0 0;
|
|
@include up(750px) {
|
|
display: none;
|
|
}
|
|
border: none;
|
|
width: 20px;
|
|
height: 20px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
cursor: pointer;
|
|
color: $primary-dark;
|
|
|
|
&:hover {
|
|
color: $primary;
|
|
}
|
|
|
|
& span {
|
|
font-size: 0;
|
|
transition: 0.2s ease-in-out;
|
|
width: 12px;
|
|
height: 2px;
|
|
background-color: currentColor;
|
|
display: block;
|
|
position: relative;
|
|
transition: 0.2s ease-in-out;
|
|
|
|
&::before,
|
|
&::after {
|
|
transition: 0.2s ease-in-out;
|
|
|
|
content: "";
|
|
display: block;
|
|
width: 12px;
|
|
height: 2px;
|
|
background-color: currentColor;
|
|
position: relative;
|
|
}
|
|
|
|
&::after {
|
|
top: -6px;
|
|
}
|
|
|
|
&::before {
|
|
bottom: -4px;
|
|
}
|
|
}
|
|
}
|
|
.navigate{
|
|
height: 30px;
|
|
overflow: hidden;
|
|
flex-wrap: wrap;
|
|
}
|
|
.open {
|
|
|
|
@include down(750px) {
|
|
.navigate {
|
|
*:first-child {
|
|
display: none
|
|
}
|
|
|
|
// Remove home icon
|
|
transition: .2s;
|
|
background: rgba($background-dark, 0.8);
|
|
height: 100%;
|
|
position: fixed;
|
|
top: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
gap: 42px;
|
|
z-index: 100;
|
|
}
|
|
|
|
.auth {
|
|
justify-content: end;
|
|
width: 100%;
|
|
z-index: 101;
|
|
|
|
}
|
|
|
|
& .burger {
|
|
|
|
& span::before {
|
|
bottom: 0;
|
|
transform: rotate(-90deg);
|
|
}
|
|
|
|
& span::after {
|
|
transform: rotate(0);
|
|
top: -2px;
|
|
}
|
|
|
|
& span {
|
|
transform: rotate(135deg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
</style> |