This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
bandolier-template/admin/Header.svelte

52 lines
2.3 KiB

<script>
import { logout_user } from '$/client/api.js';
import Icon from '$/client/components/Icon.svelte';
import Darkmode from '$/client/components/Darkmode.svelte';
import {link} from 'svelte-spa-router';
import { user } from "$/client/stores.js";
import { register_enabled } from "$/client/config.js";
export let fixed = false;
</script>
<header class:fixed>
<nav>
{#if $user.authenticated}
<a href="/client/#/"><Icon name="home" tooltip="Back to app." size="36" /></a>
<ul>
<li><a href="/" on:click|preventDefault={ logout_user } data-testid="logout-link"><Icon name="log-out" tooltip="Log out."/></a></li>
<li><a data-testid="user-profile-button" href="/profile/" use:link><Icon name="settings" tooltip="Settings."/></a></li>
<li><a href="/feed.rss"><Icon name="rss" tooltip="RSS Feed." tip_position="bottom-left" /></a></li>
<li><a href="https://learnjsthehardway.com/blog/"><Icon name="book" tooltip="Blog posts." /></a></li>
{#if $user.admin }
<li><a href="/admin/#/"><Icon name="keyboard" tooltip="Admin Dashboard."/></a></li>
{/if}
<li><a href="/" on:click|preventDefault={ logout_user } data-testid="logout-link"><Icon name="log-out" tooltip="Log out
."/></a></li>
<li><Darkmode /></li>
</ul>
{:else}
<!-- don't use:link because we want them to go to the landing page if they aren't logged in. -->
<a href="/"><Icon name="home" size="36" /></a>
<ul>
{#if register_enabled}
<li>
<a id="register-button" href="/register/top/">
<span class="mobile">
<Icon name="dollar-sign" tooltip="Register."/>
</span>
<span class="mobile-hide">
<button type="button">Register</button>
</span>
</a>
</li>
{/if}
<li><a href="/login/" use:link><Icon name="log-in" tooltip="Log in." /></a></li>
<li><a href="https://learnjsthehardway.com/blog/"><Icon name="book" tooltip="Blog posts." /></a></li>
<li><a href="/live/" use:link><Icon name="video" tooltip="Livestreams." /></a></li>
<li><Darkmode /></li>
</ul>
{/if}
</nav>
</header>