1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-24 04:26:19 +02:00
parent c01fa3bb74
commit 2ccf477c6c
49 changed files with 6 additions and 2 deletions

View file

@ -0,0 +1,62 @@
import { writable, Writable } from "svelte/store";
import type { side } from '../types/types';
import fetchNUI from '../utils/fetch';
import CivilianSVG from '../components/atoms/svgs/CivilianSVG.svelte';
import WhiteListSVG from '../components/atoms/svgs/WhitelistSVG.svelte';
interface panel {
name: string;
icon: any;
}
interface PanelState {
show: Writable<boolean>;
panelActive: Writable<string>;
panels: Writable<Array<panel>>;
side: Writable<side>;
}
const panels: Array<panel> = [
{
name: "whitelist",
icon: WhiteListSVG,
},
{
name: "civilian",
icon: CivilianSVG,
}
]
const store = () => {
const PanelStore: PanelState = {
panelActive: writable(""),
panels: writable(panels),
show: writable(false),
side: writable("right"),
}
const methods = {
handleKeyUp(event: KeyboardEvent) {
if (event.key == "Escape") {
methods.setShow(false);
fetchNUI("closemenu", null);
}
},
setActive(name: string) {
PanelStore.panelActive.set(name);
},
setShow(show: boolean) {
PanelStore.show.set(show);
},
setSide(side: side) {
PanelStore.side.set(side);
}
}
return {
...PanelStore,
...methods
}
}
export default store();