This repository was archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathApp.svelte
148 lines (135 loc) · 3.36 KB
/
App.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<main class:modalUp>
<FullscreenAnim />
<Topbar />
<ErrorPanel />
{#if !disableAll}
<TopSettings />
{/if}
<Board
on:changeok="{(_) => {
boardMode = !boardMode
}}"
bind:this="{board}"
/>
{#if !disableAll}
<div
id="switchBtn"
class="stylizedBtn nonBaseBtn"
on:click="{(_) => {
board.toggleBoard()
}}"
on:keypress="{(_) => {
board.toggleBoard()
}}"
tabIndex="0"
>
{#if boardMode}{$_('Back')}{:else}{$_('Music board')}{/if}
</div>
{/if}
<BottomBar />
</main>
{#if modalUp}
<ShortcutPanel
payload="{b64Payload}"
status="{b64MsgStat}"
on:close="{() => (modalUp = false)}"
/>
{/if}
<script lang="ts">
import { onMount } from 'svelte'
import FullscreenAnim from './components/FullscreenAnim.svelte'
import ErrorPanel from './components/ErrorPanel.svelte'
import TopSettings from './components/TopSettings.svelte'
import BottomBar from './components/BottomBar.svelte'
import Board from './components/Board.svelte'
import Topbar from './components/Topbar.svelte'
import ShortcutPanel from './components/ShortcutPanel.svelte'
import type { ButtonItem, SiteConfig } from './types'
import { MsgStatus } from './types'
import { format, _ } from 'svelte-i18n'
// @ts-ignore
import './styles/fontface.scss'
import { initGlobalContext } from './globalCtx'
export let siteConfig: SiteConfig
export let testingConfig: SiteConfig
let boardMode = false
let board: any
let disableAll = false
let modalUp = false
let b64Payload: ButtonItem = {
title: '',
audios: [],
}
let b64MsgStat: MsgStatus = MsgStatus.RESOLVED
function updateLocalizedTitle() {
document.title = $format('Starbuttons')
}
onMount(() => {
if (new URL(String(window.location)).searchParams.get('testing') === '1') {
board.load(testingConfig)
} else {
board.load(siteConfig)
}
updateLocalizedTitle()
window.addEventListener('languagechange', updateLocalizedTitle)
window.addEventListener('loadfailed', () => {
disableAll = true
})
window.addEventListener('showb64window', async (evt: CustomEventInit) => {
b64MsgStat = MsgStatus.PENDING
modalUp = true
try {
b64Payload = JSON.parse(await evt.detail)
b64MsgStat = MsgStatus.RESOLVED
} catch (e) {
b64MsgStat = MsgStatus.REJECTED
throw e
}
})
})
initGlobalContext()
</script>
<style lang="scss">
@import './styles/variables';
@import './styles/common';
:global(body) {
height: 100vh;
width: 100vw;
overflow: hidden;
}
main {
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
/* what the hell */
margin: 0;
position: absolute;
left: 0;
top: 0;
background: $main-background;
color: $color-font;
&.modalUp {
filter: blur(10px);
transition: all ease-in-out 0.3s;
}
}
#switchBtn {
height: 6vh;
line-height: 6vh;
width: $option-button-width;
margin: 3vh 0;
font-size: 1.6rem;
@media screen and (max-height: 750px) {
font-size: 1rem !important;
}
@media screen and (max-width: 1340px) {
font-size: 1rem !important;
}
@media screen and (max-width: 300px) {
font-size: 0 !important;
}
}
</style>