| 1 |
<script lang="ts"> |
| 2 |
import { keyboardShortcut } from "../keyboard-shortcuts"; |
| 3 |
import router from "../router"; |
| 4 |
import { ledger_title, ledgerData } from "../stores"; |
| 5 |
import FilterForm from "./FilterForm.svelte"; |
| 6 |
import HeaderIcon from "./HeaderIcon.svelte"; |
| 7 |
import { has_changes } from "./page-title"; |
| 8 |
import PageTitle from "./PageTitle.svelte"; |
| 9 |
|
| 10 |
let other_ledgers = $derived($ledgerData.other_ledgers); |
| 11 |
let has_dropdown = $derived(other_ledgers.length); |
| 12 |
</script> |
| 13 |
|
| 14 |
<header> |
| 15 |
<HeaderIcon /> |
| 16 |
<h1> |
| 17 |
{$ledger_title}{#if has_dropdown} ▾{/if}<PageTitle /> |
| 18 |
{#if has_dropdown} |
| 19 |
<div class="beancount-files"> |
| 20 |
<ul> |
| 21 |
{#each other_ledgers as [name, url]} |
| 22 |
<li> |
| 23 |
<a href={url} data-remote>{name}</a> |
| 24 |
</li> |
| 25 |
{/each} |
| 26 |
</ul> |
| 27 |
</div> |
| 28 |
{/if} |
| 29 |
</h1> |
| 30 |
<button |
| 31 |
type="button" |
| 32 |
hidden={!$has_changes} |
| 33 |
class="reload-page" |
| 34 |
use:keyboardShortcut={"r"} |
| 35 |
onclick={router.reload.bind(router)} |
| 36 |
> |
| 37 |
↻ |
| 38 |
</button> |
| 39 |
<span class="spacer"></span> |
| 40 |
<FilterForm /> |
| 41 |
</header> |
| 42 |
|
| 43 |
<style> |
| 44 |
.reload-page { |
| 45 |
background-color: var(--warning); |
| 46 |
} |
| 47 |
|
| 48 |
h1 { |
| 49 |
display: inline-block; |
| 50 |
padding: 0.5rem; |
| 51 |
margin: 0; |
| 52 |
overflow: hidden; |
| 53 |
font-size: 16px; |
| 54 |
font-weight: normal; |
| 55 |
} |
| 56 |
|
| 57 |
a:hover, |
| 58 |
a:link, |
| 59 |
a:visited { |
| 60 |
color: inherit; |
| 61 |
} |
| 62 |
|
| 63 |
.beancount-files { |
| 64 |
position: absolute; |
| 65 |
z-index: var(--z-index-floating-ui); |
| 66 |
display: none; |
| 67 |
width: 20em; |
| 68 |
margin-top: 0.25em; |
| 69 |
color: var(--link-color); |
| 70 |
background-color: var(--background); |
| 71 |
border: 1px solid var(--border); |
| 72 |
box-shadow: var(--box-shadow-dropdown); |
| 73 |
} |
| 74 |
|
| 75 |
.beancount-files a { |
| 76 |
display: block; |
| 77 |
padding: 8px 12px 8px 28px; |
| 78 |
cursor: pointer; |
| 79 |
} |
| 80 |
|
| 81 |
h1:hover .beancount-files { |
| 82 |
display: block; |
| 83 |
} |
| 84 |
|
| 85 |
.beancount-files ul { |
| 86 |
max-height: 400px; |
| 87 |
margin-bottom: 0; |
| 88 |
overflow-y: auto; |
| 89 |
} |
| 90 |
|
| 91 |
.beancount-files a:hover { |
| 92 |
color: var(--background); |
| 93 |
background-color: var(--link-color); |
| 94 |
} |
| 95 |
</style> |