Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,31 @@
|
|
1 |
import streamlit as st
|
2 |
import streamlit.components.v1 as components
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
particleCount: randomInRange(50, 100),
|
15 |
-
origin: { y: 0.6 },
|
16 |
-
spread: randomInRange(50, 70),
|
17 |
-
});
|
18 |
-
}
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
1 |
import streamlit as st
|
2 |
import streamlit.components.v1 as components
|
3 |
|
4 |
+
# JavaScript code for confetti animation
|
5 |
+
confetti_animation_script = """
|
6 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
|
7 |
+
<script>
|
8 |
+
function triggerConfetti() {
|
9 |
+
confetti({
|
10 |
+
angle: randomInRange(55, 125),
|
11 |
+
particleCount: randomInRange(50, 100),
|
12 |
+
origin: { y: 0.6 },
|
13 |
+
spread: randomInRange(50, 70),
|
14 |
+
});
|
15 |
+
}
|
16 |
|
17 |
+
function randomInRange(min, max) {
|
18 |
+
return Math.random() * (max - min) + min;
|
19 |
+
}
|
20 |
+
</script>
|
21 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
# Display the confetti animation script
|
24 |
+
components.html(confetti_animation_script, height=0)
|
25 |
+
|
26 |
+
# Button to trigger confetti using onclick method
|
27 |
+
confetti_button = st.button("Click for Confetti", on_click="triggerConfetti()")
|
28 |
+
|
29 |
+
if confetti_button:
|
30 |
+
st.empty() # Optional, clears the button after clicking
|
31 |
+
st.write("Confetti time!")
|