1
- <script setup>
2
- import { h } from ' vue'
3
- import CustomToast from ' ./components/CustomToast.vue'
4
- import AdvancedToast from ' ./components/AdvancedToast.vue'
5
- import { useNuxtApp } from ' #app'
6
-
7
- const { $nt } = useNuxtApp ()
8
- let i = 0
9
-
10
- function showBasicToast () {
11
- i++
12
- $nt .show (` Hello, ${ i} world!` )
13
- }
14
-
15
- function showCustomToast () {
16
- i++
17
- $nt .show ({
18
- content : () =>
19
- h (CustomToast, {
20
- message: ` Hello ${ i} from Nuxt module playground!`
21
- }),
22
- transition: {
23
- name: ' fadeOut'
24
- },
25
- theme: {
26
- containerId: ' nt-container-bottom-right' ,
27
- containerClass: [
28
- ' absolute' ,
29
- ' inset-0' ,
30
- ' pointer-events-none' ,
31
- ' p-4' ,
32
- ' flex' ,
33
- ' flex-col-reverse' ,
34
- ' items-start' ,
35
- ' gap-2'
36
- ].join (' ' ),
37
- wrapperClass: ' pointer-events-auto cursor-pointer'
38
- }
39
- })
40
- }
41
-
42
- async function showAdvancedToast () {
43
- i++
44
- const toast = await $nt .show ({
45
- content : () =>
46
- h (AdvancedToast, {
47
- message: ` Hello ${ i} from Nuxt module playground!`
48
- }),
49
- dismissible: false ,
50
- maxToasts: 1 ,
51
- theme: {
52
- containerId: ' nt-container-top-left' ,
53
- containerClass: [
54
- ' absolute' ,
55
- ' inset-0' ,
56
- ' pointer-events-none' ,
57
- ' p-4' ,
58
- ' flex' ,
59
- ' flex-col' ,
60
- ' items-end' ,
61
- ' gap-2'
62
- ].join (' ' ),
63
- wrapperClass: [
64
- ' pointer-events-auto' ,
65
- ' rounded' ,
66
- ' outline-slate-300' ,
67
- ' outline-offset-2' ,
68
- ' focus:outline' ,
69
- ' focus:outline-2' ,
70
- ' focus-within:outline' ,
71
- ' focus-within:outline-2'
72
- ].join (' ' )
73
- },
74
- transition: {
75
- enterActiveClass: ' transition duration-300 ease-out' ,
76
- enterFromClass: ' transform translate-x-full opacity-0' ,
77
- enterToClass: ' transform translate-x-0 opacity-100' ,
78
- leaveActiveClass: ' transition duration-300 ease-in' ,
79
- leaveFromClass: ' transform translate-x-0 opacity-100' ,
80
- leaveToClass: ' transform translate-x-full opacity-0'
81
- }
82
- })
83
-
84
- toast .el .focus ()
85
- }
86
- function clearAllToast () {
87
- $nt .clearAll ()
88
- }
89
- function clearTopLeftToast () {
90
- $nt .clear (' nt-container-top-left' )
91
- }
92
- </script >
93
-
94
1
<template >
95
2
<div >
96
- <p >Nuxt module playground!</p >
97
- <button
98
- class =" m-1 rounded border border-slate-200 px-2 py-1"
99
- @click =" showBasicToast"
100
- >
101
- show basic toast
102
- </button >
103
- <button
104
- class =" m-1 rounded border border-slate-200 px-2 py-1"
105
- @click =" showCustomToast"
106
- >
107
- show custom toast
108
- </button >
109
- <button
110
- class =" m-1 rounded border border-slate-200 px-2 py-1"
111
- @click =" showAdvancedToast"
112
- >
113
- show advanced toast
114
- </button >
115
- <button
116
- class =" m-1 rounded border border-slate-200 px-2 py-1"
117
- @click =" clearTopLeftToast"
118
- >
119
- clear advanced toasts
120
- </button >
121
- <button
122
- class =" m-1 rounded border border-slate-200 px-2 py-1"
123
- @click =" clearAllToast"
124
- >
125
- clear all toast
126
- </button >
3
+ <Navigation />
4
+ <NuxtPage />
127
5
</div >
128
6
</template >
129
7
130
8
<style >
131
- // Animations are taken from animate .css
132
- // https://daneden.github .io/animate .css
133
- .fadeOut {
134
- animation-name : fadeOut;
135
- }
136
- .fadeInDown {
137
- animation-name : fadeInDown;
138
- }
139
- .fadeInUp {
140
- animation-name : fadeInUp;
141
- }
142
- .fade-enter-active {
143
- transition : opacity 300ms ease-in ;
144
- }
145
- .fade-leave-active {
146
- transition : opacity 150ms ease-out ;
147
- }
148
- .fade-enter ,
149
- .fade-leave-to {
150
- opacity : 0 ;
151
- }
152
- @-moz-keyframes fadeOut {
153
- from {
154
- opacity : 1 ;
155
- }
156
- to {
157
- opacity : 0 ;
158
- }
159
- }
160
- @-webkit-keyframes fadeOut {
161
- from {
162
- opacity : 1 ;
163
- }
164
- to {
165
- opacity : 0 ;
166
- }
167
- }
168
- @-o-keyframes fadeOut {
169
- from {
170
- opacity : 1 ;
171
- }
172
- to {
173
- opacity : 0 ;
174
- }
175
- }
176
- @keyframes fadeOut {
177
- from {
178
- opacity : 1 ;
179
- }
180
- to {
181
- opacity : 0 ;
182
- }
183
- }
184
- @-moz-keyframes fadeInDown {
185
- from {
186
- opacity : 0.5 ;
187
- transform : translate3d (0 , -100% , 0 );
188
- }
189
- to {
190
- opacity : 1 ;
191
- transform : none ;
192
- }
193
- }
194
- @-webkit-keyframes fadeInDown {
195
- from {
196
- opacity : 0.5 ;
197
- transform : translate3d (0 , -100% , 0 );
198
- }
199
- to {
200
- opacity : 1 ;
201
- transform : none ;
202
- }
203
- }
204
- @-o-keyframes fadeInDown {
205
- from {
206
- opacity : 0.5 ;
207
- transform : translate3d (0 , -100% , 0 );
208
- }
209
- to {
210
- opacity : 1 ;
211
- transform : none ;
212
- }
213
- }
214
- @keyframes fadeInDown {
215
- from {
216
- opacity : 0.5 ;
217
- transform : translate3d (0 , -100% , 0 );
218
- }
219
- to {
220
- opacity : 1 ;
221
- transform : none ;
222
- }
223
- }
224
- @-moz-keyframes fadeInUp {
225
- from {
226
- opacity : 0.5 ;
227
- transform : translate3d (0 , 100% , 0 );
228
- }
229
- to {
230
- opacity : 1 ;
231
- transform : none ;
232
- }
233
- }
234
- @-webkit-keyframes fadeInUp {
235
- from {
236
- opacity : 0.5 ;
237
- transform : translate3d (0 , 100% , 0 );
238
- }
239
- to {
240
- opacity : 1 ;
241
- transform : none ;
242
- }
243
- }
244
- @-o-keyframes fadeInUp {
245
- from {
246
- opacity : 0.5 ;
247
- transform : translate3d (0 , 100% , 0 );
248
- }
249
- to {
250
- opacity : 1 ;
251
- transform : none ;
252
- }
253
- }
254
- @keyframes fadeInUp {
255
- from {
256
- opacity : 0.5 ;
257
- transform : translate3d (0 , 100% , 0 );
258
- }
259
- to {
260
- opacity : 1 ;
261
- transform : none ;
262
- }
9
+ html ,
10
+ body {
11
+ font-family : ' Inter' , sans-serif ;
263
12
}
264
- </style >
13
+ </style >
0 commit comments