refactor: move page header to own component

This commit is contained in:
mae taylor 2025-07-14 18:16:40 +01:00
parent 6f446fd871
commit 00277741a8
Signed by: mae
GPG key ID: 3C80D76BA7A3B9BD
3 changed files with 12 additions and 51 deletions

View file

@ -4,7 +4,9 @@
<header>
<h1>{title}</h1>
<slot name="icon" />
<div class="header-items">
<slot/>
</div>
</header>
<style>
@ -24,7 +26,7 @@
font-size: 1.5em;
}
nav {
header .header-items {
margin-left: auto;
display: flex;
flex-direction: row;

View file

@ -7,6 +7,7 @@
import LoginForm from '$lib/ui/LoginForm.svelte';
import Button from '$lib/ui/Button.svelte';
import Post from '$lib/ui/post/Post.svelte';
import PageHeader from '../lib/ui/core/PageHeader.svelte';
const lang = Lang('en_GB');
@ -23,14 +24,11 @@
</script>
{#if $account}
<header>
<h1>{lang.string('timeline.home')}</h1>
<nav>
<PageHeader title={lang.string('timeline.home')}>
<Button centered active>{lang.string('timeline.home')}</Button>
<Button centered disabled>{lang.string('timeline.local')}</Button>
<Button centered disabled>{lang.string('timeline.federated')}</Button>
</nav>
</header>
</PageHeader>
<div id="feed" role="feed">
{#if $timeline.length <= 0}
@ -47,30 +45,6 @@
{/if}
<style>
header {
width: 100%;
height: 64px;
margin: 16px 0;
padding: 0 8px;
display: flex;
flex-direction: row;
user-select: none;
box-sizing: border-box;
}
header h1 {
font-size: 1.5em;
}
nav {
margin-left: auto;
display: flex;
flex-direction: row;
align-items: center;
gap: 8px;
}
#feed {
margin-bottom: 20vh;
}

View file

@ -4,6 +4,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import Notification from '$lib/ui/Notification.svelte';
import PageHeader from '../../lib/ui/core/PageHeader.svelte';
import Lang from '$lib/lang';
const lang = Lang('en_GB');
@ -33,9 +34,7 @@
});
</script>
<header>
<h1>{lang.string('navigation.notifications')}</h1>
</header>
<PageHeader title={lang.string('navigation.notifications')}/>
<div class="notifications">
{#if $notifications.length === 0}
@ -50,20 +49,6 @@
</div>
<style>
header {
width: 100%;
height: 64px;
margin: 16px 0 8px 0;
padding: 0 8px;
display: flex;
flex-direction: row;
box-sizing: border-box;
}
h1 {
font-size: 1.5em;
}
.loading {
width: 100%;
height: 80vh;