@fy-/fws-vue 0.6.8 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ui/DefaultNotif.vue +28 -34
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "@heroicons/vue/24/solid";
|
|
14
14
|
import { useEventBus } from "../../composables/event-bus";
|
|
15
15
|
import type { Component } from "vue";
|
|
16
|
-
import
|
|
16
|
+
import ScaleTransition from "./transitions/ScaleTransition.vue";
|
|
17
17
|
interface NotifProps {
|
|
18
18
|
imgSrc?: string;
|
|
19
19
|
imgIcon?: Component;
|
|
@@ -28,67 +28,61 @@ interface NotifProps {
|
|
|
28
28
|
const notif = ref<HTMLElement | null>(null);
|
|
29
29
|
const eventBus = useEventBus();
|
|
30
30
|
const currentNotif = ref<NotifProps | null>(null);
|
|
31
|
-
|
|
32
|
-
const onCall = (
|
|
33
|
-
if (currentNotif.value) {
|
|
31
|
+
let currentTimeout: any | null = null;
|
|
32
|
+
const onCall = (data: NotifProps) => {
|
|
33
|
+
if (currentNotif.value !== null) {
|
|
34
34
|
hideNotif();
|
|
35
35
|
}
|
|
36
|
-
const actualIcon = ref(
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
36
|
+
const actualIcon = ref(data.imgIcon);
|
|
37
|
+
if (data.imgIcon === undefined) {
|
|
38
|
+
if (data.type === "info") {
|
|
39
39
|
actualIcon.value = LightBulbIcon;
|
|
40
|
-
} else if (
|
|
40
|
+
} else if (data.type === "warning") {
|
|
41
41
|
actualIcon.value = ExclamationTriangleIcon;
|
|
42
|
-
} else if (
|
|
42
|
+
} else if (data.type === "success") {
|
|
43
43
|
actualIcon.value = CheckCircleIcon;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
if (!
|
|
47
|
-
|
|
46
|
+
if (!data.time || data.time < 1000) {
|
|
47
|
+
data.time = 5000;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
currentNotif.value = {
|
|
51
|
-
imgSrc:
|
|
51
|
+
imgSrc: data.imgSrc,
|
|
52
52
|
imgIcon: actualIcon.value,
|
|
53
|
-
title:
|
|
54
|
-
content:
|
|
55
|
-
ctaText:
|
|
56
|
-
ctaLink:
|
|
57
|
-
ctaAction:
|
|
53
|
+
title: data.title,
|
|
54
|
+
content: data.content,
|
|
55
|
+
ctaText: data.ctaText,
|
|
56
|
+
ctaLink: data.ctaLink,
|
|
57
|
+
ctaAction: data.ctaAction,
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
currentTimeout = setTimeout(() => {
|
|
61
|
+
hideNotif();
|
|
62
|
+
}, currentNotif.value.time);
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
const visible = ref(false);
|
|
64
|
-
const showNotif = () => {
|
|
65
|
-
visible.value = true;
|
|
66
|
-
setTimeout(
|
|
67
|
-
() => {
|
|
68
|
-
hideNotif();
|
|
69
|
-
},
|
|
70
|
-
currentNotif.value?.time,
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
65
|
const hideNotif = () => {
|
|
74
|
-
visible.value = false;
|
|
75
66
|
currentNotif.value = null;
|
|
67
|
+
if (currentTimeout !== null) {
|
|
68
|
+
clearTimeout(currentTimeout);
|
|
69
|
+
}
|
|
76
70
|
};
|
|
77
71
|
onMounted(() => {
|
|
78
|
-
eventBus.on("
|
|
72
|
+
eventBus.on("SendNotif", onCall);
|
|
79
73
|
});
|
|
80
74
|
onUnmounted(() => {
|
|
81
|
-
eventBus.off("
|
|
75
|
+
eventBus.off("SendNotif", onCall);
|
|
82
76
|
});
|
|
83
77
|
</script>
|
|
84
78
|
<template>
|
|
85
|
-
<
|
|
79
|
+
<ScaleTransition>
|
|
86
80
|
<div
|
|
87
81
|
id="mainNotif"
|
|
88
82
|
ref="notif"
|
|
89
83
|
class="w-full max-w-xs p-4 text-fv-neutral-500 bg-white rounded-lg shadow dark:bg-fv-neutral-800 dark:text-fv-neutral-400 absolute bottom-4 right-4 z-[16]"
|
|
90
84
|
role="alert"
|
|
91
|
-
v-if="
|
|
85
|
+
v-if="currentNotif !== null"
|
|
92
86
|
>
|
|
93
87
|
<div class="flex">
|
|
94
88
|
<img
|
|
@@ -162,5 +156,5 @@ onUnmounted(() => {
|
|
|
162
156
|
</button>
|
|
163
157
|
</div>
|
|
164
158
|
</div>
|
|
165
|
-
</
|
|
159
|
+
</ScaleTransition>
|
|
166
160
|
</template>
|