Debian Codegraph @

frontend/src/sidebar/AsideWithButton.svelte

raw
1 <script lang="ts">
2 import AsideContents from "./AsideContents.svelte";
3
4 /** Whether the sidebar is currently shown. */
5 let active = $state(false);
6 const toggle = () => {
7 active = !active;
8 };
9 </script>
10
11 {#if active}
12 <div class="overlay" onclick={toggle} aria-hidden="true"></div>
13 {/if}
14 <div class:active class="aside-buttons">
15 <button type="button" onclick={toggle}>☰</button>
16 <a class="button" href="#add-transaction">+</a>
17 </div>
18 <aside class:active>
19 <AsideContents />
20 </aside>
21
22 <style>
23 aside {
24 grid-area: aside;
25 padding-top: 0.5rem;
26 margin: 0;
27 overflow-y: auto;
28 color: var(--sidebar-color);
29 background-color: var(--sidebar-background);
30 border-right: 1px solid var(--sidebar-border);
31 }
32
33 .aside-buttons {
34 display: none;
35 }
36
37 @media (width <= 767px) {
38 :root {
39 --aside-width: 200px;
40 }
41
42 aside {
43 position: fixed;
44 top: 0;
45 bottom: 0;
46 z-index: var(--z-index-floating-ui);
47 width: var(--aside-width);
48 margin-left: calc(-1 * var(--aside-width));
49 transition: var(--transitions);
50 }
51
52 .overlay {
53 position: fixed;
54 inset: 0;
55 z-index: var(--z-index-floating-ui);
56 cursor: pointer;
57 background: var(--overlay-wrapper-background);
58 transition: var(--transitions);
59 }
60
61 aside.active {
62 margin-left: 0;
63 }
64
65 .aside-buttons {
66 position: fixed;
67 top: 0;
68 left: 0;
69 z-index: var(--z-index-floating-ui);
70 display: flex;
71 flex-direction: column;
72 transition: var(--transitions);
73 }
74
75 .active.aside-buttons {
76 left: var(--aside-width);
77 }
78
79 .aside-buttons > * {
80 width: 42px;
81 height: 42px;
82 color: var(--mobile-button-text);
83 text-align: center;
84 background-color: var(--sidebar-background);
85 border: 1px solid var(--sidebar-border);
86 }
87
88 .aside-buttons a {
89 font-size: 28px;
90 }
91 }
92
93 @media print {
94 aside,
95 .aside-buttons {
96 display: none;
97 }
98 }
99 </style>