File size: 855 Bytes
7fbaf23
c503554
7fbaf23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b521abc
 
7fbaf23
b521abc
0438968
b521abc
 
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
import streamlit as st
import streamlit.components.v1 as components

# JavaScript code for confetti animation
confetti_animation_script = """
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
<script>
    function triggerConfetti() {
        confetti({
            angle: randomInRange(55, 125),
            particleCount: randomInRange(50, 100),
            origin: { y: 0.6 },
            spread: randomInRange(50, 70),
        });
    }

    function randomInRange(min, max) {
        return Math.random() * (max - min) + min;
    }
</script>
"""

# Display the confetti animation script
components.html(confetti_animation_script, height=0)

# Button to trigger confetti
if st.button("Click for Confetti"):
    st.empty()  # Optional, clears the button after clicking
    st.write("Confetti time!")