@fy-/fws-vue 0.6.5 → 0.6.7

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.
@@ -0,0 +1,167 @@
1
+ <script setup lang="ts">
2
+ import {
3
+ Dialog,
4
+ DialogPanel,
5
+ DialogTitle,
6
+ TransitionRoot,
7
+ } from "@headlessui/vue";
8
+ import { ref, onMounted, onUnmounted } from "vue";
9
+ import {
10
+ ExclamationTriangleIcon,
11
+ LightBulbIcon,
12
+ CheckCircleIcon,
13
+ } from "@heroicons/vue/24/solid";
14
+ import { useEventBus } from "../../composables/event-bus";
15
+ import type { Component } from "vue";
16
+ import FadeTransition from "./transitions/FadeTransition.vue";
17
+ import { on } from "events";
18
+ interface NotifProps {
19
+ imgSrc?: string;
20
+ imgIcon?: Component;
21
+ title: string;
22
+ content?: string;
23
+ ctaText?: string;
24
+ ctaLink?: string;
25
+ ctaAction?: () => void;
26
+ type?: "info" | "warning" | "success";
27
+ time?: number;
28
+ }
29
+ const notif = ref<HTMLElement | null>(null);
30
+ const eventBus = useEventBus();
31
+ const currentNotif = ref<NotifProps | null>(null);
32
+
33
+ const onCall = (props: NotifProps) => {
34
+ if (currentNotif.value) {
35
+ hideNotif();
36
+ }
37
+ const actualIcon = ref(props.imgIcon);
38
+ if (props.imgIcon === undefined) {
39
+ if (props.type === "info") {
40
+ actualIcon.value = LightBulbIcon;
41
+ } else if (props.type === "warning") {
42
+ actualIcon.value = ExclamationTriangleIcon;
43
+ } else if (props.type === "success") {
44
+ actualIcon.value = CheckCircleIcon;
45
+ }
46
+ }
47
+ if (!props.time) {
48
+ props.time = 5000;
49
+ }
50
+
51
+ currentNotif.value = {
52
+ imgSrc: props.imgSrc,
53
+ imgIcon: actualIcon.value,
54
+ title: props.title,
55
+ content: props.content,
56
+ ctaText: props.ctaText,
57
+ ctaLink: props.ctaLink,
58
+ ctaAction: props.ctaAction,
59
+ };
60
+
61
+ showNotif();
62
+ };
63
+
64
+ const visible = ref(false);
65
+ const showNotif = () => {
66
+ visible.value = true;
67
+ setTimeout(
68
+ () => {
69
+ hideNotif();
70
+ },
71
+ currentNotif.value?.time,
72
+ );
73
+ };
74
+ const hideNotif = () => {
75
+ visible.value = false;
76
+ currentNotif.value = null;
77
+ };
78
+ onMounted(() => {
79
+ eventBus.on("main-notif", onCall);
80
+ });
81
+ onUnmounted(() => {
82
+ eventBus.off("main-notif", onCall);
83
+ });
84
+ </script>
85
+ <template>
86
+ <FadeTransition>
87
+ <div
88
+ id="mainNotif"
89
+ ref="notif"
90
+ 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]"
91
+ role="alert"
92
+ v-if="visible && currentNotif"
93
+ >
94
+ <div class="flex">
95
+ <img
96
+ class="w-8 h-8 rounded-full"
97
+ :src="currentNotif.imgSrc"
98
+ :alt="currentNotif.title"
99
+ v-if="currentNotif.imgSrc"
100
+ />
101
+ <component
102
+ :is="currentNotif.imgIcon"
103
+ class="w-8 h-8 rounded-full"
104
+ v-else
105
+ />
106
+ <div class="ms-3 text-sm font-normal">
107
+ <span
108
+ class="mb-1 text-sm font-semibold"
109
+ :class="{
110
+ 'text-fv-neutral-900 dark:text-white':
111
+ currentNotif.type === 'info',
112
+ 'text-red-900 dark:text-red-300': currentNotif.type === 'warning',
113
+ 'text-green-900 dark:text-green-300':
114
+ currentNotif.type === 'success',
115
+ }"
116
+ >
117
+ {{ currentNotif.title }}
118
+ </span>
119
+ <div class="mb-2 text-sm font-normal" v-if="currentNotif.content">
120
+ {{ currentNotif.content }}
121
+ </div>
122
+ <router-link
123
+ v-if="currentNotif.ctaText && currentNotif.ctaLink"
124
+ :to="currentNotif.ctaLink"
125
+ class="btn primary small"
126
+ >{{ currentNotif.ctaText }}</router-link
127
+ >
128
+ <button
129
+ v-else-if="currentNotif.ctaText && currentNotif.ctaAction"
130
+ @click="
131
+ () => {
132
+ // @ts-ignore
133
+ currentNotif.ctaAction();
134
+ hideNotif();
135
+ }
136
+ "
137
+ class="btn primary small"
138
+ >
139
+ {{ currentNotif.ctaText }}
140
+ </button>
141
+ </div>
142
+ <button
143
+ type="button"
144
+ class="ms-auto -mx-1.5 -my-1.5 bg-white justify-center items-center flex-shrink-0 text-fv-neutral-400 hover:text-fv-neutral-900 rounded-lg focus:ring-2 focus:ring-fv-neutral-300 p-1.5 hover:bg-fv-neutral-100 inline-flex h-8 w-8 dark:text-fv-neutral-500 dark:hover:text-white dark:bg-fv-neutral-800 dark:hover:bg-fv-neutral-700"
145
+ aria-label="Close"
146
+ >
147
+ <span class="sr-only">Close</span>
148
+ <svg
149
+ class="w-3 h-3"
150
+ aria-hidden="true"
151
+ xmlns="http://www.w3.org/2000/svg"
152
+ fill="none"
153
+ viewBox="0 0 14 14"
154
+ >
155
+ <path
156
+ stroke="currentColor"
157
+ stroke-linecap="round"
158
+ stroke-linejoin="round"
159
+ stroke-width="2"
160
+ d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"
161
+ />
162
+ </svg>
163
+ </button>
164
+ </div>
165
+ </div>
166
+ </FadeTransition>
167
+ </template>
package/index.ts CHANGED
@@ -43,6 +43,7 @@ import DefaultGallery from "./components/ui/DefaultGallery.vue";
43
43
  import DefaultDropdown from "./components/ui/DefaultDropdown.vue";
44
44
  import DefaultDropdownLink from "./components/ui/DefaultDropdownLink.vue";
45
45
  import DefaultTagInput from "./components/ui/DefaultTagInput.vue";
46
+ import DefaultNotif from "./components/ui/DefaultNotif.vue";
46
47
  // Components/FWS
47
48
  import UserFlow from "./components/fws/UserFlow.vue";
48
49
  import DataTable from "./components/fws/DataTable.vue";
@@ -135,6 +136,7 @@ export {
135
136
  DefaultDropdown,
136
137
  DefaultDropdownLink,
137
138
  DefaultTagInput,
139
+ DefaultNotif,
138
140
 
139
141
  // FWS
140
142
  UserFlow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,11 +33,12 @@
33
33
  "@vuelidate/core": "^2.0.x",
34
34
  "@vuelidate/validators": "^2.0.x",
35
35
  "@vueuse/core": "^10.x.x",
36
+ "flowbite": "^2.3.x",
36
37
  "mitt": "^3.0.x",
37
38
  "pinia": "2.x.x",
38
39
  "timeago.js": "^4.0.x",
39
40
  "vue": "^3.3.x",
40
41
  "vue-router": "^4.1.x",
41
- "flowbite": "^2.3.x"
42
+ "vue-picture-cropper": "^0.7.x"
42
43
  }
43
44
  }