mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 22:22:50 +00:00
refactor(web): visibility handling
This commit is contained in:
1 parent
e06c61d292
commit
fb78adec43
6 files changed
+32
-18
No files matched your search
+22
-10
@@ -5,6 +5,8 @@
|
||||
import { useNuiEvent } from './utils/useNuiEvent';
|
||||
import { resources, generalData } from './store';
|
||||
import { debugData } from './utils/debugData';
|
||||
import { visible } from './store';
|
||||
import { scale } from 'svelte/transition';
|
||||
|
||||
interface OpenData {
|
||||
resources: string[];
|
||||
@@ -22,6 +24,7 @@
|
||||
router.goto('/');
|
||||
|
||||
useNuiEvent('openUI', (data: OpenData) => {
|
||||
$visible = true;
|
||||
$resources = data.resources;
|
||||
$generalData = {
|
||||
queries: data.totalQueries,
|
||||
@@ -46,15 +49,24 @@
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const handleESC = (e: KeyboardEvent) => e.key === 'Escape' && ($visible = false);
|
||||
|
||||
$: $visible ? window.addEventListener('keydown', handleESC) : window.removeEventListener('keydown', handleESC);
|
||||
</script>
|
||||
|
||||
<main class="w-full h-full flex justify-center items-center font-main">
|
||||
<div class="bg-dark-800 text-white w-[1000px] h-[600px] flex rounded-md">
|
||||
<Route path="/">
|
||||
<Root />
|
||||
</Route>
|
||||
<Route path="/:resource">
|
||||
<Resource />
|
||||
</Route>
|
||||
</div>
|
||||
</main>
|
||||
{#if $visible}
|
||||
<main
|
||||
transition:scale={{ start: 0.95, duration: 150 }}
|
||||
class="w-full h-full flex justify-center items-center font-main"
|
||||
>
|
||||
<div class="bg-dark-800 text-white w-[1000px] h-[600px] flex rounded-md">
|
||||
<Route path="/">
|
||||
<Root />
|
||||
</Route>
|
||||
<Route path="/:resource">
|
||||
<Resource />
|
||||
</Route>
|
||||
</div>
|
||||
</main>
|
||||
{/if}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { derived, writable } from 'svelte/store';
|
||||
|
||||
export const visible = writable(false)
|
||||
|
||||
export const search = writable('');
|
||||
let timeout: NodeJS.Timeout;
|
||||
export const debouncedSearch = derived(search, (value, set: (value: string) => void) => {
|
||||
|
||||
Reference in new issue
Block a user