poprawki do popupów

This commit is contained in:
2024-03-23 16:47:57 +01:00
parent 6b6b837dde
commit 1ec75bda70
9 changed files with 104 additions and 60 deletions
+9 -6
View File
@@ -1,19 +1,22 @@
import { defineStore } from 'pinia';
export const popupKeys = ['DonatorPopUp', 'TrainCommentsPopUp', 'VehiclePreviewPopUp'] as const;
export type PopUp = (typeof popupKeys)[number];
const isPopUp = (v: any): v is PopUp => popupKeys.includes(v);
export const usePopupStore = defineStore('popupStore', {
state: () => ({
popupPosition: { x: 0, y: 0 },
currentPopupComponent: null as
| null
| 'DonatorPopUp'
| 'TrainCommentsPopUp'
| 'VehiclePreviewPopUp',
currentPopupComponent: null as PopUp | null,
currentPopupContent: '',
donatorPopupVisible: false
}),
actions: {
onPopUpShow(e: MouseEvent, componentKey: typeof this.currentPopupComponent, value?: string) {
onPopUpShow(e: MouseEvent, componentKey: string, value?: string) {
if (!isPopUp(componentKey)) return;
this.popupPosition.x = e.pageX;
this.popupPosition.y = e.pageY;