vue-toastflow 0.0.1
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/dist/toastflow.es.js +636 -0
- package/dist/toastflow.umd.js +1 -0
- package/dist/vue-toastflow.css +1 -0
- package/package.json +24 -0
- package/src/components/Toast.vue +660 -0
- package/src/components/ToastContainer.vue +350 -0
- package/src/components/ToastProgress.vue +62 -0
- package/src/components/icons/ArrowPath.vue +13 -0
- package/src/components/icons/Bell.vue +13 -0
- package/src/components/icons/CheckCircle.vue +13 -0
- package/src/components/icons/InfoCircle.vue +13 -0
- package/src/components/icons/QuestionMarkCircle.vue +13 -0
- package/src/components/icons/XCircle.vue +13 -0
- package/src/components/icons/XMark.vue +13 -0
- package/src/index.ts +17 -0
- package/src/plugin.ts +16 -0
- package/src/styles.css +180 -0
- package/src/symbols.ts +4 -0
- package/src/toast.ts +80 -0
- package/tsconfig.json +15 -0
- package/vite.config.ts +22 -0
package/src/styles.css
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* base look */
|
|
3
|
+
--tf-toast-font-family: system-ui, -apple-system, BlinkMacSystemFont,
|
|
4
|
+
"Segoe UI", sans-serif;
|
|
5
|
+
|
|
6
|
+
--tf-toast-radius: 0.75rem;
|
|
7
|
+
--tf-toast-padding: 1rem;
|
|
8
|
+
|
|
9
|
+
--normal-bg: #fff;
|
|
10
|
+
--normal-border: #e6e8eb;
|
|
11
|
+
--normal-text: #11181c;
|
|
12
|
+
|
|
13
|
+
--loading-bg: hsl(48, 100%, 96%);
|
|
14
|
+
--loading-border: hsl(46, 100%, 88%);
|
|
15
|
+
--loading-text: hsl(40, 100%, 32%);
|
|
16
|
+
|
|
17
|
+
--tf-toast-bg: var(--normal-bg);
|
|
18
|
+
--tf-toast-color: var(--normal-text);
|
|
19
|
+
--tf-toast-border-color: var(--normal-border);
|
|
20
|
+
|
|
21
|
+
--success-bg: hsl(143, 85%, 96%);
|
|
22
|
+
--success-border: hsl(145, 92%, 87%);
|
|
23
|
+
--success-text: hsl(140, 100%, 27%);
|
|
24
|
+
|
|
25
|
+
--info-bg: hsl(208, 100%, 97%);
|
|
26
|
+
--info-border: hsl(221, 91%, 93%);
|
|
27
|
+
--info-text: hsl(210, 92%, 45%);
|
|
28
|
+
|
|
29
|
+
--warning-bg: hsl(49, 100%, 97%);
|
|
30
|
+
--warning-border: hsl(49, 91%, 84%);
|
|
31
|
+
--warning-text: hsl(31, 92%, 45%);
|
|
32
|
+
|
|
33
|
+
--error-bg: hsl(359, 100%, 97%);
|
|
34
|
+
--error-border: hsl(359, 100%, 94%);
|
|
35
|
+
--error-text: hsl(360, 100%, 45%);
|
|
36
|
+
|
|
37
|
+
/* text */
|
|
38
|
+
--tf-toast-title-font-size: 0.85rem;
|
|
39
|
+
--tf-toast-title-font-weight: 600;
|
|
40
|
+
--tf-toast-description-font-size: 0.8rem;
|
|
41
|
+
--tf-toast-description-color: var(--tf-toast-color);
|
|
42
|
+
--tf-toast-created-at-font-size: 0.7rem;
|
|
43
|
+
|
|
44
|
+
/* layout inside toast */
|
|
45
|
+
--tf-toast-gap: 0.8rem;
|
|
46
|
+
|
|
47
|
+
/* accent bar */
|
|
48
|
+
--tf-toast-accent-loading: var(--loading-text);
|
|
49
|
+
--tf-toast-accent-default: var(--normal-text);
|
|
50
|
+
--tf-toast-accent-success: var(--success-text);
|
|
51
|
+
--tf-toast-accent-error: var(--error-text);
|
|
52
|
+
--tf-toast-accent-warning: var(--warning-text);
|
|
53
|
+
--tf-toast-accent-info: var(--info-text);
|
|
54
|
+
|
|
55
|
+
/* icon */
|
|
56
|
+
--tf-toast-icon-size: 24px;
|
|
57
|
+
|
|
58
|
+
--tf-toast-icon-loading: var(--loading-text);
|
|
59
|
+
--tf-toast-icon-default: var(--normal-text);
|
|
60
|
+
--tf-toast-icon-success: var(--success-text);
|
|
61
|
+
--tf-toast-icon-error: var(--error-text);
|
|
62
|
+
--tf-toast-icon-warning: var(--warning-text);
|
|
63
|
+
--tf-toast-icon-info: var(--info-text);
|
|
64
|
+
|
|
65
|
+
/* close button */
|
|
66
|
+
--tf-toast-close-size: 18px;
|
|
67
|
+
|
|
68
|
+
--tf-toast-close-border-color: var(--tf-toast-border-color);
|
|
69
|
+
--tf-toast-close-color: var(--tf-toast-color);
|
|
70
|
+
--tf-toast-close-bg: var(--tf-toast-bg);
|
|
71
|
+
--tf-toast-close-ring-color: var(--tf-toast-border-color);
|
|
72
|
+
|
|
73
|
+
/* progress bar */
|
|
74
|
+
--tf-toast-progress-height: 4px;
|
|
75
|
+
--tf-toast-progress-bg: transparent;
|
|
76
|
+
--tf-toast-progress-bar-bg: var(--tf-toast-accent-success); /* fallback; per-type je v class */
|
|
77
|
+
--tf-toast-progress-duration: 5000ms;
|
|
78
|
+
|
|
79
|
+
--tf-toast-motion-offset: 10px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.tf-toast--paused .tf-toast-progress-bar {
|
|
83
|
+
animation-play-state: paused;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.tf-toast-item[data-position^="top-"] {
|
|
87
|
+
--tf-toast-motion-offset: -10px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.tf-toast-item[data-position^="bottom-"] {
|
|
91
|
+
--tf-toast-motion-offset: 10px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.Toastflow__animation-enter-active {
|
|
95
|
+
animation: Toastflow__enter-kf 260ms cubic-bezier(0.5, 1, 0.25, 1);
|
|
96
|
+
animation-fill-mode: both;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.Toastflow__animation-leave-active {
|
|
100
|
+
animation: Toastflow__leave-kf 220ms ease;
|
|
101
|
+
animation-fill-mode: both;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.Toastflow__animation-clearAll {
|
|
105
|
+
animation: Toastflow__clearAll-kf 260ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
106
|
+
animation-fill-mode: both;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.Toastflow__animation-move {
|
|
110
|
+
transition: transform 260ms cubic-bezier(0.5, 1, 0.25, 1);
|
|
111
|
+
will-change: transform;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.Toastflow__animation-bump {
|
|
115
|
+
animation: Toastflow__bump-kf 140ms ease-out;
|
|
116
|
+
animation-fill-mode: both;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.Toastflow__animation-update {
|
|
120
|
+
animation: Toastflow__update-kf 320ms cubic-bezier(0.33, 1, 0.68, 1);
|
|
121
|
+
animation-fill-mode: both;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@keyframes Toastflow__enter-kf {
|
|
125
|
+
0% {
|
|
126
|
+
transform: translate3d(0, var(--tf-toast-motion-offset), 0) scale(0.9);
|
|
127
|
+
opacity: 0;
|
|
128
|
+
}
|
|
129
|
+
100% {
|
|
130
|
+
transform: translate3d(0, 0, 0) scale(1);
|
|
131
|
+
opacity: 1;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@keyframes Toastflow__leave-kf {
|
|
136
|
+
0% {
|
|
137
|
+
transform: translate3d(0, 0, 0) scale(1);
|
|
138
|
+
opacity: 1;
|
|
139
|
+
}
|
|
140
|
+
100% {
|
|
141
|
+
transform: translate3d(0, var(--tf-toast-motion-offset), 0) scale(0.9);
|
|
142
|
+
opacity: 0;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes Toastflow__clearAll-kf {
|
|
147
|
+
0% {
|
|
148
|
+
opacity: 1;
|
|
149
|
+
}
|
|
150
|
+
100% {
|
|
151
|
+
opacity: 0;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@keyframes Toastflow__bump-kf {
|
|
156
|
+
0% {
|
|
157
|
+
transform: scale(1);
|
|
158
|
+
}
|
|
159
|
+
40% {
|
|
160
|
+
transform: scale(1.01);
|
|
161
|
+
}
|
|
162
|
+
100% {
|
|
163
|
+
transform: scale(1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@keyframes Toastflow__update-kf {
|
|
168
|
+
0% {
|
|
169
|
+
opacity: 0.4;
|
|
170
|
+
transform: scale(0.985);
|
|
171
|
+
}
|
|
172
|
+
40% {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
transform: scale(1.01);
|
|
175
|
+
}
|
|
176
|
+
100% {
|
|
177
|
+
opacity: 1;
|
|
178
|
+
transform: scale(1);
|
|
179
|
+
}
|
|
180
|
+
}
|
package/src/symbols.ts
ADDED
package/src/toast.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ToastConfig,
|
|
3
|
+
ToastContentInput,
|
|
4
|
+
ToastEvent,
|
|
5
|
+
ToastId,
|
|
6
|
+
ToastLoadingConfig,
|
|
7
|
+
ToastLoadingInput,
|
|
8
|
+
ToastLoadingResult,
|
|
9
|
+
ToastShowInput,
|
|
10
|
+
ToastState,
|
|
11
|
+
ToastStore,
|
|
12
|
+
ToastUpdateInput,
|
|
13
|
+
} from "toastflow-core";
|
|
14
|
+
|
|
15
|
+
let globalStore: ToastStore | null = null;
|
|
16
|
+
|
|
17
|
+
export function setToastStore(store: ToastStore) {
|
|
18
|
+
globalStore = store;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getToastStore(): ToastStore {
|
|
22
|
+
if (!globalStore) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"[vue-toastflow] Toast store not initialized. Did you install the plugin?",
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return globalStore;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const toast = {
|
|
31
|
+
getState(): ToastState {
|
|
32
|
+
return getToastStore().getState();
|
|
33
|
+
},
|
|
34
|
+
subscribeEvents(listener: (event: ToastEvent) => void): () => void {
|
|
35
|
+
return getToastStore().subscribeEvents(listener);
|
|
36
|
+
},
|
|
37
|
+
show(options: ToastShowInput): ToastId {
|
|
38
|
+
return getToastStore().show(options);
|
|
39
|
+
},
|
|
40
|
+
loading<T>(
|
|
41
|
+
input: ToastLoadingInput<T>,
|
|
42
|
+
config: ToastLoadingConfig<T>,
|
|
43
|
+
): ToastLoadingResult<T> {
|
|
44
|
+
return getToastStore().loading(input, config);
|
|
45
|
+
},
|
|
46
|
+
update(id: ToastId, options: ToastUpdateInput): void {
|
|
47
|
+
return getToastStore().update(id, options);
|
|
48
|
+
},
|
|
49
|
+
dismiss(id: ToastId): void {
|
|
50
|
+
return getToastStore().dismiss(id);
|
|
51
|
+
},
|
|
52
|
+
dismissAll(): void {
|
|
53
|
+
return getToastStore().dismissAll();
|
|
54
|
+
},
|
|
55
|
+
pause(id: ToastId): void {
|
|
56
|
+
return getToastStore().pause(id);
|
|
57
|
+
},
|
|
58
|
+
resume(id: ToastId): void {
|
|
59
|
+
return getToastStore().resume(id);
|
|
60
|
+
},
|
|
61
|
+
getConfig(): ToastConfig {
|
|
62
|
+
return getToastStore().getConfig();
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
toast(options: ToastContentInput): ToastId {
|
|
66
|
+
return getToastStore().show({ ...options, type: "default" });
|
|
67
|
+
},
|
|
68
|
+
success(options: ToastContentInput): ToastId {
|
|
69
|
+
return getToastStore().show({ ...options, type: "success" });
|
|
70
|
+
},
|
|
71
|
+
error(options: ToastContentInput): ToastId {
|
|
72
|
+
return getToastStore().show({ ...options, type: "error" });
|
|
73
|
+
},
|
|
74
|
+
info(options: ToastContentInput): ToastId {
|
|
75
|
+
return getToastStore().show({ ...options, type: "info" });
|
|
76
|
+
},
|
|
77
|
+
warning(options: ToastContentInput): ToastId {
|
|
78
|
+
return getToastStore().show({ ...options, type: "warning" });
|
|
79
|
+
},
|
|
80
|
+
};
|
package/tsconfig.json
ADDED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {defineConfig} from "vite";
|
|
2
|
+
import vue from "@vitejs/plugin-vue";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [vue()],
|
|
7
|
+
build: {
|
|
8
|
+
lib: {
|
|
9
|
+
entry: path.resolve(__dirname, "src/index.ts"),
|
|
10
|
+
name: "Toastflow",
|
|
11
|
+
fileName: (format) => `toastflow.${format}.js`
|
|
12
|
+
},
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
external: ["vue", "toastflow-core"],
|
|
15
|
+
output: {
|
|
16
|
+
globals: {
|
|
17
|
+
vue: "Vue"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|