mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
refactor: popups -> tooltips
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useApiStore } from '../store/apiStore';
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
apiStore: useApiStore()
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
isDonator(name: string) {
|
||||
return this.apiStore.donatorsData.includes(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
data: () => ({
|
||||
observer: null as IntersectionObserver | null,
|
||||
observerTarget: null as Element | null
|
||||
}),
|
||||
|
||||
methods: {
|
||||
mountObserver(actionFunction: () => void, target: Element) {
|
||||
this.observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (entries[0].intersectionRatio > 0.5) actionFunction();
|
||||
},
|
||||
{ threshold: 0.2 }
|
||||
);
|
||||
|
||||
this.observer.observe(target);
|
||||
},
|
||||
|
||||
unmountObserver() {
|
||||
if (!this.observerTarget) return;
|
||||
|
||||
this.observer?.unobserve(this.observerTarget);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,10 +1,12 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useMainStore } from '../store/mainStore';
|
||||
import { useTooltipStore } from '../store/tooltipStore';
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
store: useMainStore()
|
||||
store: useMainStore(),
|
||||
tooltipStore: useTooltipStore()
|
||||
};
|
||||
},
|
||||
|
||||
@@ -17,7 +19,7 @@ export default defineComponent({
|
||||
|
||||
closeModal() {
|
||||
this.store.chosenModalTrainId = undefined;
|
||||
this.store.popUpData.key = null;
|
||||
this.tooltipStore.hide();
|
||||
|
||||
setTimeout(() => {
|
||||
(this.store.modalLastClickedTarget as any)?.focus();
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useMainStore } from '../store/mainStore';
|
||||
import { PopUpType, popupKeys } from '../store/typings';
|
||||
|
||||
const isPopUp = (v: any): v is PopUpType => popupKeys.includes(v);
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
store: useMainStore()
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
showPopUp(e: MouseEvent, componentKey: string, value?: string) {
|
||||
if (!isPopUp(componentKey)) return;
|
||||
|
||||
this.store.popUpData['key'] = componentKey;
|
||||
this.store.popUpData['content'] = value ?? '';
|
||||
},
|
||||
|
||||
hidePopUp() {
|
||||
this.store.popUpData['key'] = null;
|
||||
this.store.popUpData['content'] = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user