Add page header component
This commit is contained in:
1 parent
175916162b
commit
4e281b7b83
1 file changed
+31
@@ -0,0 +1,31 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import ChevronLeft from '@lucide/svelte/icons/chevron-left';
|
||||
|
||||
let { title, subtitle = '', back = '', actions }: { title: string; subtitle?: string; back?: string; actions?: Snippet } = $props();
|
||||
</script>
|
||||
|
||||
<header class="page-header">
|
||||
{#if back}
|
||||
<a class="back" href={back}><ChevronLeft size={18} aria-hidden="true" /> Back</a>
|
||||
{/if}
|
||||
<div class="row spread">
|
||||
<div class="titles">
|
||||
<!-- tabindex lets the app move focus here on screen changes, for screen readers -->
|
||||
<h1 tabindex="-1">{title}</h1>
|
||||
{#if subtitle}<p class="muted">{subtitle}</p>{/if}
|
||||
</div>
|
||||
{#if actions}<div class="row actions">{@render actions()}</div>{/if}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<style>
|
||||
.page-header { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s5); }
|
||||
.titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
||||
h1:focus { outline: none; }
|
||||
.back {
|
||||
display: inline-flex; align-items: center; gap: 2px; align-self: flex-start;
|
||||
min-height: 44px; font-size: var(--fs-sm); font-weight: 600; text-decoration: none; color: var(--text-2);
|
||||
}
|
||||
.back:hover { color: var(--text); }
|
||||
</style>
|
||||
Reference in new issue
Block a user