-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
183 lines (174 loc) Β· 8.8 KB
/
demo.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alpine Confetti Demo</title>
<script src="https://cdn.tailwindcss.com"></script>
<script defer src="dist/browser.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
</head>
<body x-init="{}" class="h-screen flex flex-col justify-center bg-gradient-to-t from-slate-900 to-blue-200">
<div class="bg-cover mix-blend-multiply bg-no-repeat bg-center h-full w-full absolute z-0 select-none pointer-events-none z-0"
style="background-image: url('assets/bg1.png');">
</div>
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 z-10">
<div class="mx-auto max-w-3xl space-y-5">
<div class="sm:rounded-lg bg-amber-50/70 backdrop-blur-md shadow-lg">
<div class="px-4 py-5 sm:p-6">
<h3 class="text-lg font-semibold leading-6 text-gray-900">
Confetti
</h3>
<div class="mt-2 max-w-xl text-base text-slate-600">
<p>
Use <span class="font-mono">$confetti</span> to celebrate an interaction with your Alpine component.
By default it creates a burst of confetti originating from the target element, but you can create
custom effects by passing an object with options.
</p>
</div>
<div class="mt-5 flex justify-evenly items-center">
<button type="button"
x-on:click="$confetti()"
class="transition-all inline-flex items-center rounded-md bg-white px-3 py-2 text-base font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-blue-50 active:bg-blue-100">
<span class="mr-2">π</span> Click Me!
</button>
<button type="button"
x-data="{
isHovering: false,
volcano() {
if (this.isHovering) {
$confetti({
particleCount: Math.floor(Math.random() * 10),
colors: ['#1c1917', '#262626', '#09090b', '#57534e'],
angle: 75 + (Math.random() * 30),
gravity: 0.1 + (Math.random() * 0.2),
drift: Math.random() * (Math.random() > 0.5 ? 1 : -1),
ticks: 10 + (Math.random() * 200),
spread: (Math.random() * 50),
startVelocity: 10 + (Math.random() * 10)
});
}
this.schedule();
},
schedule () {
setTimeout(() => this.volcano(), 250 * (Math.random() * 3));
}
}"
x-init="schedule"
x-on:mouseenter="isHovering = true"
x-on:mouseleave="isHovering = false"
x-on:click="$confetti({
particleCount: 100 + Math.floor(Math.random() * 200),
scalar: 1.5,
angle: 75 + (Math.random() * 30),
gravity: 0.2 + (Math.random() * 0.3),
drift: Math.random() * (Math.random() > 0.5 ? 1 : -1),
ticks: 50 + (Math.random() * 250),
spread: 10 + (Math.random() * 50),
colors: ['#b91c1c', '#9a3412', '#f59e0b', '#fcd34d', '#292524', '#450a0a'],
startVelocity: 20 + (Math.random() * 10)
})"
class="transition-all inline-flex items-center rounded-md bg-white px-3 py-2 text-base font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-red-50 active:bg-red-100">
<span class="mr-2">π</span> Click Me...
</button>
<button type="button"
x-data="{ clicked: false, sneezed: false }"
x-on:click="clicked = true;"
x-on:click.debounce.750ms="
$confetti({
particleCount: Math.floor(Math.random() * 50) + 10,
angle: 270 + ((Math.random() * 30)* (Math.random() > 0.5 ? 1 : -1)),
spread: 55,
scalar: 0.75,
colors: ['#3f6212', '#16a34a', '#84cc16', '#1a2e05']
});
sneezed = true;
setTimeout(() => { sneezed = false; clicked = false; }, 1000);"
class="transition-all inline-flex items-center rounded-md bg-white px-3 py-2 text-base font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-green-50 active:bg-green-100">
<span x-text="sneezed ? 'π€§ Ahhchooo!' : clicked ? 'π« Ahh...' : 'π Click Me?'">π Click Me?</span>
</button>
</div>
<div class="mt-5 flex justify-evenly items-center">
<code class="text-sm text-gray-500">
<button x-on:click="$confetti()"> ... </button>
</code>
</div>
</div>
</div>
<div class="sm:rounded-lg bg-amber-50/70 backdrop-blur-md">
<div class="px-4 py-5 sm:p-6">
<h3 class="text-lg font-semibold leading-6 text-gray-900">
Starbust
</h3>
<div class="mt-2 max-w-xl text-base text-gray-500">
<p>
Use the <span class="font-mono">$starburst</span> preset to add a little magic to your UI.
Specify the number of stars, or pass an object for more control and customization.
</p>
</div>
<div class="mt-5 flex justify-evenly items-center">
<button type="button"
x-on:click="$starburst()"
class="transition-all inline-flex items-center rounded-md bg-white px-3 py-2 text-base font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-yellow-50 active:bg-yellow-100">
β¨ Click Me...
</button>
<button type="button"
x-on:mousemove.throttle="$starburst({
particleCount: 5,
gravity: -1,
ticks: 250,
spread: 45,
startVelocity: 10,
scalar: 1 + (Math.random() * 2.5),
drift: 0
})"
class="transition-all inline-flex items-center rounded-md bg-white px-3 py-2 text-base font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-yellow-50 active:bg-yellow-100">
π« Hover Me...
</button>
</div>
<div class="mt-5 flex justify-evenly items-center">
<code class="text-sm text-gray-500">
<button x-on:click="$starburst(10)"> ... </button>
</code>
</div>
</div>
</div>
<div class="sm:rounded-lg bg-amber-50/70 backdrop-blur-md">
<div class="px-4 py-5 sm:p-6">
<h3 class="text-lg font-semibold leading-6 text-gray-900">
Emojify
</h3>
<div class="mt-2 max-w-xl text-base text-gray-500">
<p>
Use <span class="font-mono">$emojify</span> to surprise and/or annoy your users. Pass an array of emojis
or an object to customize further. Use responsibly! (Or not... π€ͺ)
</p>
</div>
<div class="mt-5 flex justify-evenly items-center">
<button type="button"
x-on:click="$emojify(['π©', 'π'], {particleCount: 50, ticks: 250, 'gravity': 1, angle: 90, decay: 0.95, startVelocity: 30, origin: {x:0.5,y:0}})"
class="transition-all inline-flex items-center rounded-md bg-white px-3 py-2 text-base font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-red-50 active:bg-red-100">
π« Don't Click Me
</button>
<button type="button"
x-data="{wasKissed: false}"
x-on:click="
$emojify(['π', 'π', 'π', 'β€οΈ'], {'gravity': 0, angle: 180, flat: true});
wasKissed = true;
setTimeout(() => { wasKissed = false; }, 1000);
"
class="transition-all inline-flex items-center rounded-md bg-white px-3 py-2 text-base font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-red-50 active:bg-red-100">
<span x-text="wasKissed ? 'π Mwah!' : 'π Kiss Me'">π Kiss Me</span>
</button>
</div>
<div class="mt-5 flex justify-evenly items-center">
<code class="text-sm text-gray-500">
<button x-on:click="$emojify(['π', 'π'])"> ... </button>
</code>
</div>
</div>
</div>
</div>
</div>
</body>
</html>