forked from apvarun/toastify-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
113 lines (110 loc) · 3.97 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="src/toastify.css" />
<script src="https://cdn.tailwindcss.com"></script>
<script
defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"
></script>
</head>
<body class="mx-auto">
<div class="w-screen h-screen overflow-x-hidden overflow-y-auto">
<div class="flex items-center justify-center w-full h-full gap-2 px-4">
<div
class="flex flex-col gap-4"
x-data="{
text: null,
duration: null,
positionX: null,
positionY: null,
progressBar: null,
}"
>
<div class="grid grid-cols-2 gap-4">
<input
type="text"
placeholder="Toastify Text..."
class="px-2 border-2 border-black"
x-model="text"
/>
<input
type="number"
placeholder="Duration (in seconds)"
min="-1"
class="px-2 border-2 border-black"
x-model="duration"
/>
<label class="flex flex-col">
<span>Position X</span>
<select x-model="positionX" class="border-2 border-black">
<option value="">right (default)</option>
<option value="left">left</option>
<option value="center">center</option>
</select>
</label>
<label class="flex flex-col">
<span>Position Y</span>
<select x-model="positionY" class="border-2 border-black">
<option value="">bottom (default)</option>
<option value="top">top</option>
</select>
</label>
<div class="flex flex-col">
<span>Progress Bar (Default: show)</span>
<div class="flex gap-4">
<label class="flex flex-col">
<span>Show</span>
<input type="radio" value="true" x-model="progressBar" />
</label>
<label class="flex flex-col">
<span>Hide</span>
<input type="radio" value="" x-model="progressBar" />
</label>
</div>
</div>
</div>
<button
x-on:click="$dispatch('toastify', {
text: text,
duration: duration,
positionX: positionX,
positionY: positionY,
progressBar: progressBar,
})"
type="button"
class="px-4 py-2 text-white bg-black rounded-xl"
>
Show Toastify
</button>
</div>
</div>
</div>
<script>
window.addEventListener("toastify", (event) => {
Toastify({
text:
event.detail.text ??
'<div class="text-green-400">Hello World!</div>',
escapeMarkup: false,
close: true,
progressBar: event.detail.progressBar ?? true,
progressBarColor: "linear-gradient(to right, #38bdf8, #0284c7)",
duration: event.detail.duration ?? 5,
avatar:
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="fill-green-500" fill="currentColor" viewBox="0 0 16 16"><path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/></svg>',
position: event.detail.positionX ?? "right",
gravity: event.detail.positionY ?? "bottom",
style: {
background: "#262626",
},
}).showToast();
});
</script>
<script type="text/javascript" src="src/toastify.js"></script>
</body>
</html>