From fb78adec43cb852d9c1c664cab1bd9965a54ec14 Mon Sep 17 00:00:00 2001 From: Luke <39926192+LukeWasTakenn@users.noreply.github.com> Date: Fri, 24 Mar 2023 20:56:53 +0100 Subject: [PATCH] refactor(web): visibility handling --- .github/workflows/pre-release.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- fxmanifest.lua | 6 +++--- lerna.json | 2 +- web/src/App.svelte | 32 +++++++++++++++++++++---------- web/src/store/general.ts | 2 ++ 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index dd6e3ca..f386940 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -31,12 +31,12 @@ jobs: - name: Bundle files run: | mkdir -p ./temp/oxmysql - mkdir -p ./temp/oxmysql/ui/ + mkdir -p ./temp/oxmysql/web/ mkdir -p ./temp/oxmysql/lib/ cp ./{LICENSE,README.md,fxmanifest.lua,ui.lua} ./temp/oxmysql cp ./lib/{MySQL.lua,define.lua} ./temp/oxmysql/lib cp -r ./dist ./temp/oxmysql - cp -r ./ui/build ./temp/oxmysql/ui/ + cp -r ./web/build ./temp/oxmysql/web/ cd ./temp && zip -r ../oxmysql.zip ./oxmysql - name: Create Release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 554e6df..315f366 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,12 +66,12 @@ jobs: - name: Bundle files run: | mkdir -p ./temp/oxmysql - mkdir -p ./temp/oxmysql/ui/ + mkdir -p ./temp/oxmysql/web/ mkdir -p ./temp/oxmysql/lib/ cp ./{LICENSE,README.md,fxmanifest.lua,ui.lua} ./temp/oxmysql cp ./lib/{MySQL.lua,define.lua} ./temp/oxmysql/lib cp -r ./dist ./temp/oxmysql - cp -r ./ui/build ./temp/oxmysql/ui/ + cp -r ./web/build ./temp/oxmysql/web/ cd ./temp && zip -r ../oxmysql.zip ./oxmysql - name: Create Release diff --git a/fxmanifest.lua b/fxmanifest.lua index 9c6e262..ba54453 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -15,11 +15,11 @@ client_script 'ui.lua' server_script 'dist/build.js' files { - 'ui/build/index.html', - 'ui/build/**/*' + 'web/build/index.html', + 'web/build/**/*' } -ui_page 'ui/build/index.html' +ui_page 'web/build/index.html' provide 'mysql-async' provide 'ghmattimysql' diff --git a/lerna.json b/lerna.json index aa23ec2..bd1bba6 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "packages": ["ui"], + "packages": ["web"], "npmClient": "pnpm", "version": "0.0.0" } diff --git a/web/src/App.svelte b/web/src/App.svelte index 2c7efeb..b9924e4 100644 --- a/web/src/App.svelte +++ b/web/src/App.svelte @@ -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); -
-
- - - - - - -
-
+{#if $visible} +
+
+ + + + + + +
+
+{/if} diff --git a/web/src/store/general.ts b/web/src/store/general.ts index 45db51c..9cb6623 100644 --- a/web/src/store/general.ts +++ b/web/src/store/general.ts @@ -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) => {