add easter egg and settings menu
All checks were successful
delpoy / build-and-deploy (push) Successful in 44s
All checks were successful
delpoy / build-and-deploy (push) Successful in 44s
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
import '../app.css';
|
||||
import { env } from '$env/dynamic/public';
|
||||
import { goto } from '$app/navigation';
|
||||
import Settings from './Settings.svelte';
|
||||
import { playAudio } from '$lib/stores';
|
||||
|
||||
let navPaths = [
|
||||
{
|
||||
@ -56,9 +58,20 @@
|
||||
|
||||
let isTouch = false;
|
||||
let nav: HTMLDivElement;
|
||||
let settings: HTMLDialogElement;
|
||||
</script>
|
||||
|
||||
<svelte:body
|
||||
on:keyup={(e) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
if (settings.open) {
|
||||
settings.close();
|
||||
} else {
|
||||
settings.show();
|
||||
}
|
||||
}
|
||||
}}
|
||||
on:touchend={(e) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
@ -83,9 +96,12 @@
|
||||
let activePath = navPaths.find((path) => path.active);
|
||||
if (activePath !== undefined) {
|
||||
goto(activePath.href);
|
||||
} else {
|
||||
showMenuPermanent = !showMenuPermanent;
|
||||
} else if ($playAudio) {
|
||||
new Audio(
|
||||
`${env.PUBLIC_BASE_PATH}/aud/chest-${showMenuPermanent ? 'close' : 'open'}.mp3`
|
||||
).play();
|
||||
}
|
||||
showMenuPermanent = !showMenuPermanent;
|
||||
}
|
||||
}}
|
||||
on:touchend={() => {
|
||||
@ -147,3 +163,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<dialog class="modal" bind:this={settings}>
|
||||
<form method="dialog" class="modal-box" style="overflow: unset">
|
||||
<button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button>
|
||||
<Settings />
|
||||
</form>
|
||||
<form method="dialog" class="modal-backdrop bg-[rgba(0,0,0,.3)]">
|
||||
<button>close</button>
|
||||
</form>
|
||||
</dialog>
|
||||
|
42
src/routes/Settings.svelte
Normal file
42
src/routes/Settings.svelte
Normal file
@ -0,0 +1,42 @@
|
||||
<script lang="ts">
|
||||
import { playAudio } from '$lib/stores';
|
||||
import { get } from 'svelte/store';
|
||||
import { IconOutline } from 'svelte-heros-v2';
|
||||
|
||||
let settings = [
|
||||
{
|
||||
name: 'Sound abspielen',
|
||||
description:
|
||||
'Manche Elemente können Sounds abspielen. Aktiviere diese Option und finde raus welche',
|
||||
store: playAudio
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<h2 class="text-2xl">Einstellungen</h2>
|
||||
<div>
|
||||
<div class="divider" />
|
||||
<div class="grid grid-cols-2">
|
||||
{#each settings as setting}
|
||||
<div class="flex">
|
||||
<p>{setting.name}</p>
|
||||
<span class="tooltip ml-[0.2rem] -mt-[1px]" data-tip={setting.description}>
|
||||
<IconOutline name="question-mark-circle-outline" width="16" height="16" />
|
||||
</span>
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="toggle justify-self-end mr-6"
|
||||
checked={get(setting.store)}
|
||||
on:change={(e) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
setting.store.set(e.target.checked);
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="divider" />
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user