feat: add svelte-sonner and mode-watcher dependencies, implement Toaster component
This commit is contained in:
1
src/lib/components/ui/sonner/index.ts
Normal file
1
src/lib/components/ui/sonner/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as Toaster } from "./sonner.svelte";
|
20
src/lib/components/ui/sonner/sonner.svelte
Normal file
20
src/lib/components/ui/sonner/sonner.svelte
Normal file
@@ -0,0 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { Toaster as Sonner, type ToasterProps as SonnerProps } from "svelte-sonner";
|
||||
import { mode } from "mode-watcher";
|
||||
|
||||
let { ...restProps }: SonnerProps = $props();
|
||||
</script>
|
||||
|
||||
<Sonner
|
||||
theme={mode.current}
|
||||
class="toaster group"
|
||||
toastOptions={{
|
||||
classes: {
|
||||
toast: "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
||||
description: "group-[.toast]:text-muted-foreground",
|
||||
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
||||
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
|
||||
},
|
||||
}}
|
||||
{...restProps}
|
||||
/>
|
@@ -1,27 +1,83 @@
|
||||
<script lang="ts">
|
||||
import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
|
||||
import '../app.css';
|
||||
import { current_view, first_startup, setupValues } from '@/global';
|
||||
import Titlebar from '@/components/ui/titlebar/titlebar.svelte';
|
||||
import { first_startup, setupValues } from '@/global';
|
||||
import { onMount } from 'svelte';
|
||||
import OsuCursor from '@/components/ui/osu-cursor/OsuCursor.svelte';
|
||||
import { cursorSmoothening, customCursor, reduceAnimations, userSettings } from '@/userSettings';
|
||||
import {
|
||||
cursorSmoothening,
|
||||
customCursor,
|
||||
osuInstallationPath,
|
||||
reduceAnimations,
|
||||
userSettings,
|
||||
} from '@/userSettings';
|
||||
import { Buffer } from 'buffer';
|
||||
import SetupWizard from '../pages/SetupWizard.svelte';
|
||||
import Launch from '../pages/Launch.svelte';
|
||||
import { Toaster } from '@/components/ui/sonner';
|
||||
let { children } = $props();
|
||||
|
||||
function disableReload() {
|
||||
if (window.location.hostname !== 'tauri.localhost') {
|
||||
return;
|
||||
}
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (
|
||||
event.key === 'F3' ||
|
||||
event.key === 'F5' ||
|
||||
event.key === 'F7' ||
|
||||
event.key === 'F8' ||
|
||||
event.key === 'F10' ||
|
||||
event.key === 'F12' ||
|
||||
(event.ctrlKey && event.key === 'r') ||
|
||||
(event.metaKey && event.key === 'r') ||
|
||||
(event.ctrlKey && event.key === 'f') ||
|
||||
(event.metaKey && event.key === 'f') ||
|
||||
(event.ctrlKey && event.key === 'g') ||
|
||||
(event.metaKey && event.key === 'g') ||
|
||||
(event.ctrlKey && event.key === 'j') ||
|
||||
(event.metaKey && event.key === 'j') ||
|
||||
(event.ctrlKey && event.key === 'p') ||
|
||||
(event.metaKey && event.key === 'p') ||
|
||||
(event.ctrlKey && event.key === 'u') ||
|
||||
(event.metaKey && event.key === 'u')
|
||||
) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener(
|
||||
'contextmenu',
|
||||
(e) => {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
},
|
||||
{ capture: true }
|
||||
);
|
||||
|
||||
document.addEventListener(
|
||||
'selectstart',
|
||||
(e) => {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
},
|
||||
{ capture: true }
|
||||
);
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
window.Buffer = Buffer;
|
||||
disableReload();
|
||||
setupValues();
|
||||
const firstStartup = await $userSettings.init();
|
||||
|
||||
const config_custom_cursor = $userSettings.value('custom_cursor');
|
||||
const config_cursor_smoothening = $userSettings.value('cursor_smoothening');
|
||||
const config_reduce_animations = $userSettings.value('reduce_animations');
|
||||
const config_osu_installation_path = $userSettings.value('osu_installation_path');
|
||||
|
||||
customCursor.set(config_custom_cursor.get(true));
|
||||
cursorSmoothening.set(config_cursor_smoothening.get(true));
|
||||
reduceAnimations.set(config_reduce_animations.get(false));
|
||||
osuInstallationPath.set(config_osu_installation_path.get(''));
|
||||
|
||||
customCursor.subscribe((val) => config_custom_cursor.set(val));
|
||||
cursorSmoothening.subscribe((val) => config_cursor_smoothening.set(val));
|
||||
@@ -35,6 +91,8 @@
|
||||
<OsuCursor smoothCursor={$cursorSmoothening} />
|
||||
{/if}
|
||||
|
||||
<Toaster richColors closeButton />
|
||||
|
||||
<Titlebar />
|
||||
<main>
|
||||
{@render children()}
|
||||
|
Reference in New Issue
Block a user