mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
popupy
This commit is contained in:
@@ -26,8 +26,10 @@ export const useMainStore = defineStore('store', {
|
||||
|
||||
chosenModalTrainId: undefined,
|
||||
|
||||
blockScroll: false,
|
||||
modalLastClickedTarget: null
|
||||
modalLastClickedTarget: null,
|
||||
|
||||
mousePos: { x: 0, y: 0 },
|
||||
popUpData: { key: null, content: '' }
|
||||
}) as StoreState,
|
||||
|
||||
getters: {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
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 PopUp | null,
|
||||
currentPopupContent: '',
|
||||
donatorPopupVisible: false
|
||||
}),
|
||||
|
||||
actions: {
|
||||
onPopUpShow(e: MouseEvent, componentKey: string, value?: string) {
|
||||
if (!isPopUp(componentKey)) return;
|
||||
|
||||
this.popupPosition.x = e.pageX;
|
||||
this.popupPosition.y = e.pageY;
|
||||
|
||||
this.currentPopupComponent = componentKey;
|
||||
this.currentPopupContent = value ?? '';
|
||||
},
|
||||
|
||||
onPopUpMove(e: MouseEvent) {
|
||||
this.popupPosition.x = e.pageX;
|
||||
this.popupPosition.y = e.pageY;
|
||||
},
|
||||
|
||||
onPopUpHide() {
|
||||
this.currentPopupComponent = null;
|
||||
this.currentPopupContent = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,9 @@
|
||||
import { API } from '../typings/api';
|
||||
import { Status } from '../typings/common';
|
||||
|
||||
export const popupKeys = ['DonatorPopUp', 'TrainCommentsPopUp', 'VehiclePreviewPopUp'] as const;
|
||||
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
||||
export type PopUpType = (typeof popupKeys)[number];
|
||||
|
||||
export interface RegionCounters {
|
||||
stationCount: number;
|
||||
@@ -19,8 +21,9 @@ export interface StoreState {
|
||||
driverStatsData?: API.DriverStats.Response;
|
||||
driverStatsStatus: Status.Data;
|
||||
chosenModalTrainId?: string;
|
||||
blockScroll: boolean;
|
||||
modalLastClickedTarget: EventTarget | null;
|
||||
mousePos: { x: number; y: number };
|
||||
popUpData: { key: PopUpType | null; content: string };
|
||||
}
|
||||
|
||||
export interface StationRoutesInfo {
|
||||
|
||||
Reference in New Issue
Block a user