| | import streamlit as st |
| | import streamlit.components.v1 as components |
| |
|
| | |
| | confetti_animation_script = """ |
| | <script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.9.2/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> |
| | """ |
| |
|
| | |
| | components.html(confetti_animation_script, height=0) |
| |
|
| | |
| | confetti_button = st.button("Click for Confetti", on_click="triggerConfetti()") |
| |
|
| | if confetti_button: |
| | st.empty() |
| | st.write("Confetti time!") |