vue-notifyr 0.1.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/LICENCE +21 -0
- package/README.md +226 -0
- package/dist/index.cjs +355 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.js +281 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +245 -0
- package/package.json +71 -0
- package/src/adapters/inertia/index.ts +2 -0
- package/src/adapters/nuxt/index.ts +24 -0
- package/src/adapters/vue/NotificationContainer.vue +78 -0
- package/src/adapters/vue/index.ts +70 -0
- package/src/composables/useNotification.ts +11 -0
- package/src/core/notification-manager.ts +151 -0
- package/src/env.d.ts +5 -0
- package/src/index.ts +27 -0
- package/src/styles/style.css +245 -0
- package/src/types/index.ts +23 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
@import url(https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap);
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--notification-info: #385bbb;
|
|
5
|
+
--notification-info-rgb: 56, 91, 187;
|
|
6
|
+
--notification-info-darker: hsl(224, 54%, 35%);
|
|
7
|
+
--notification-warning: #f3950d;
|
|
8
|
+
--notification-warning-rgb: 243, 149, 13;
|
|
9
|
+
--notification-warning-darker: hsl(35, 91%, 40%);
|
|
10
|
+
--notification-error: #d32f2f;
|
|
11
|
+
--notification-error-rgb: 211, 47, 47;
|
|
12
|
+
--notification-error-darker: hsl(0, 68%, 43%);
|
|
13
|
+
--notification-success: #388e3c;
|
|
14
|
+
--notification-success-rgb: 56, 142, 60;
|
|
15
|
+
--notification-success-darker: hsl(120, 54%, 35%);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@keyframes notificationSlideFromTop {
|
|
19
|
+
0% {
|
|
20
|
+
opacity: 0;
|
|
21
|
+
translate: 0 calc(-100% - 24px);
|
|
22
|
+
}
|
|
23
|
+
100% {
|
|
24
|
+
opacity: 1;
|
|
25
|
+
translate: 0 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@keyframes notificationSlideFromBottom {
|
|
30
|
+
0% {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
translate: 0 calc(100% + 24px);
|
|
33
|
+
}
|
|
34
|
+
100% {
|
|
35
|
+
opacity: 1;
|
|
36
|
+
translate: 0 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@keyframes notificationFadeOut {
|
|
41
|
+
0% {
|
|
42
|
+
opacity: 1;
|
|
43
|
+
}
|
|
44
|
+
100% {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@keyframes progressBar {
|
|
50
|
+
0% {
|
|
51
|
+
transform: scaleX(1);
|
|
52
|
+
}
|
|
53
|
+
100% {
|
|
54
|
+
transform: scaleX(0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.notification-list {
|
|
59
|
+
position: fixed;
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
gap: 16px;
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
z-index: 99999;
|
|
65
|
+
width: max-content;
|
|
66
|
+
max-width: calc(100vw - 48px);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.notification-list > * {
|
|
70
|
+
pointer-events: auto;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.notification-list[data-position^='top'] {
|
|
74
|
+
top: 24px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.notification-list[data-position^='bottom'] {
|
|
78
|
+
bottom: 24px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.notification-list[data-position$='left'] {
|
|
82
|
+
left: 24px;
|
|
83
|
+
right: auto;
|
|
84
|
+
transform: none;
|
|
85
|
+
align-items: flex-start;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.notification-list[data-position$='center'] {
|
|
89
|
+
left: 50%;
|
|
90
|
+
right: auto;
|
|
91
|
+
transform: translateX(-50%);
|
|
92
|
+
align-items: center;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.notification-list[data-position$='right'] {
|
|
96
|
+
right: 24px;
|
|
97
|
+
left: auto;
|
|
98
|
+
transform: none;
|
|
99
|
+
align-items: flex-end;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.notification {
|
|
103
|
+
position: relative;
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 12px;
|
|
107
|
+
padding: 16px 20px;
|
|
108
|
+
padding-right: 50px;
|
|
109
|
+
min-width: 280px;
|
|
110
|
+
max-width: 400px;
|
|
111
|
+
background-color: #fff;
|
|
112
|
+
border-radius: 8px;
|
|
113
|
+
border: 2px solid transparent;
|
|
114
|
+
font-family: 'Nunito Sans', system-ui, helvetica, sans-serif;
|
|
115
|
+
font-size: 15px;
|
|
116
|
+
font-weight: 600;
|
|
117
|
+
line-height: 1.4;
|
|
118
|
+
box-shadow:
|
|
119
|
+
0 2px 4px -1px rgba(0, 0, 0, 0.2),
|
|
120
|
+
0 4px 5px 0 rgba(0, 0, 0, 0.14),
|
|
121
|
+
0 1px 10px 0 rgba(0, 0, 0, 0.12);
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
color: var(--notification-info-darker);
|
|
124
|
+
background-clip: padding-box;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.notification-list[data-position^='top'] .notification {
|
|
128
|
+
animation: notificationSlideFromTop 0.5s ease-out forwards;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.notification-list[data-position^='bottom'] .notification {
|
|
132
|
+
animation: notificationSlideFromBottom 0.5s ease-out forwards;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.notification.notification-success {
|
|
136
|
+
color: var(--notification-success);
|
|
137
|
+
border-color: var(--notification-success);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.notification.notification-error {
|
|
141
|
+
color: var(--notification-error);
|
|
142
|
+
border-color: var(--notification-error);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.notification.notification-warning {
|
|
146
|
+
color: var(--notification-warning);
|
|
147
|
+
border-color: var(--notification-warning);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.notification.notification-info {
|
|
151
|
+
color: var(--notification-info);
|
|
152
|
+
border-color: var(--notification-info);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.notification-content {
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
flex: 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.notification-title {
|
|
162
|
+
font-weight: 600;
|
|
163
|
+
font-size: 15px;
|
|
164
|
+
line-height: 1.4;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.notification-progress {
|
|
168
|
+
position: absolute;
|
|
169
|
+
left: 0;
|
|
170
|
+
right: 0;
|
|
171
|
+
bottom: 0;
|
|
172
|
+
height: 3px;
|
|
173
|
+
border-radius: 50px;
|
|
174
|
+
transform-origin: left;
|
|
175
|
+
background-color: currentColor;
|
|
176
|
+
animation: progressBar linear forwards;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.notification-close {
|
|
180
|
+
display: flex;
|
|
181
|
+
align-items: center;
|
|
182
|
+
justify-content: center;
|
|
183
|
+
position: absolute;
|
|
184
|
+
right: 8px;
|
|
185
|
+
top: 50%;
|
|
186
|
+
transform: translateY(-50%);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.notification-close button {
|
|
190
|
+
padding: 8px;
|
|
191
|
+
margin: 0;
|
|
192
|
+
border: none;
|
|
193
|
+
background-color: transparent;
|
|
194
|
+
display: flex;
|
|
195
|
+
align-items: center;
|
|
196
|
+
justify-content: center;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
border-radius: 4px;
|
|
199
|
+
transition: background-color 0.2s ease;
|
|
200
|
+
color: inherit;
|
|
201
|
+
font-size: 16px;
|
|
202
|
+
line-height: 1;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.notification-close button:focus-visible {
|
|
206
|
+
outline: 2px solid currentColor;
|
|
207
|
+
outline-offset: 2px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.notification-close button:hover {
|
|
211
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.notification-enter-active,
|
|
215
|
+
.notification-leave-active {
|
|
216
|
+
transition:
|
|
217
|
+
opacity 0.2s ease,
|
|
218
|
+
transform 0.2s ease;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.notification-enter-from,
|
|
222
|
+
.notification-leave-to {
|
|
223
|
+
opacity: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.notification-list[data-position^='top'] .notification-enter-from,
|
|
227
|
+
.notification-list[data-position^='top'] .notification-leave-to {
|
|
228
|
+
transform: translateY(-16px);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.notification-list[data-position^='bottom'] .notification-enter-from,
|
|
232
|
+
.notification-list[data-position^='bottom'] .notification-leave-to {
|
|
233
|
+
transform: translateY(16px);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.notification-move {
|
|
237
|
+
transition: transform 0.2s ease;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@media (max-width: 480px) {
|
|
241
|
+
.notification {
|
|
242
|
+
min-width: calc(100vw - 48px);
|
|
243
|
+
max-width: calc(100vw - 48px);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type NotificationType = 'success' | 'error' | 'warning' | 'info';
|
|
2
|
+
|
|
3
|
+
export type NotificationPosition =
|
|
4
|
+
| 'top-left'
|
|
5
|
+
| 'top-center'
|
|
6
|
+
| 'top-right'
|
|
7
|
+
| 'bottom-left'
|
|
8
|
+
| 'bottom-center'
|
|
9
|
+
| 'bottom-right';
|
|
10
|
+
|
|
11
|
+
export interface NotificationOptions {
|
|
12
|
+
position?: NotificationPosition;
|
|
13
|
+
autoClose?: number | false;
|
|
14
|
+
progress?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface NotificationItem {
|
|
18
|
+
id: number;
|
|
19
|
+
type: NotificationType;
|
|
20
|
+
title: string;
|
|
21
|
+
options: Required<NotificationOptions>;
|
|
22
|
+
createdAt: number;
|
|
23
|
+
}
|