-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy path+layout.svelte
78 lines (66 loc) · 1.55 KB
/
+layout.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<script>
import Header from '$lib/header/Header.svelte';
import SideMenu from '$lib/sidemenu/SideMenu.svelte';
import Footer from '$lib/footer/Footer.svelte';
import '../app.css';
import '../site.css';
import { tocStore } from '$lib/utils';
/** @type {import('./$types').PageData */
export let data;
$: ({ moduleData } = data);
$: frontmatter = moduleData.frontmatter;
$: fileInfo = moduleData.fileInfo;
$: {
const toc = moduleData.toc;
$tocStore = toc;
}
let sidebarOpen = false;
function handleToggleSidebar() {
sidebarOpen = !sidebarOpen;
}
function resetSidebarOpen() {
sidebarOpen = false;
}
</script>
<svelte:window on:resize={sidebarOpen ? resetSidebarOpen : null} />
<Header on:toggleSidebarOpen={handleToggleSidebar} />
<SideMenu {sidebarOpen} hiddenMenu={frontmatter.hiddenMenu} />
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<main
class:hidden-menu={frontmatter.hiddenMenu}
on:click={sidebarOpen ? resetSidebarOpen : null}
on:keydown={sidebarOpen ? resetSidebarOpen : null}
>
<div class="main-content">
<slot />
</div>
</main>
<Footer {frontmatter} {fileInfo} />
<style>
main {
margin-top: 64px;
}
main:not(.hidden-menu) {
padding-left: 20rem;
}
@media (max-width: 959px) {
main:not(.hidden-menu) {
padding-left: 16.4rem;
}
}
@media (max-width: 719px) {
main:not(.hidden-menu) {
padding-left: 0;
}
}
main .main-content {
flex: 1;
display: flex;
flex-direction: column;
padding: 1rem;
width: 100%;
max-width: 1024px;
margin: 0 auto;
box-sizing: border-box;
}
</style>