"""
Animation Utility Functions
"""
import streamlit as st
import time
def fade_in(element_html, duration=0.5):
"""
Apply fade-in animation to HTML element
Args:
element_html: HTML string to animate
duration: Animation duration in seconds
"""
st.markdown(f"""
{element_html}
""", unsafe_allow_html=True)
def slide_in(element_html, direction="left", duration=0.5):
"""
Apply slide-in animation to HTML element
Args:
element_html: HTML string to animate
direction: 'left', 'right', 'up', or 'down'
duration: Animation duration in seconds
"""
transforms = {
"left": "translateX(-100%)",
"right": "translateX(100%)",
"up": "translateY(-100%)",
"down": "translateY(100%)"
}
start_transform = transforms.get(direction, "translateX(-100%)")
st.markdown(f"""
{element_html}
""", unsafe_allow_html=True)
def pulse_animation(element_html, duration=1.5):
"""
Apply pulse animation to HTML element
Args:
element_html: HTML string to animate
duration: Animation duration in seconds
"""
st.markdown(f"""
{element_html}
""", unsafe_allow_html=True)
def typing_effect(text, delay=0.05):
"""
Display text with typing effect (simulated)
Args:
text: Text to display
delay: Delay between characters in seconds
"""
placeholder = st.empty()
displayed_text = ""
for char in text:
displayed_text += char
placeholder.markdown(f"**{displayed_text}▌**")
time.sleep(delay)
placeholder.markdown(f"**{displayed_text}**")
def loading_spinner(message="Loading..."):
"""
Display a custom loading spinner
Args:
message: Loading message to display
"""
st.markdown(f"""
""", unsafe_allow_html=True)
def gradient_text(text, gradient="linear-gradient(135deg, #667eea 0%, #764ba2 100%)"):
"""
Display text with gradient color
Args:
text: Text to display
gradient: CSS gradient string
"""
st.markdown(f"""
{text}
""", unsafe_allow_html=True)
def confetti_animation():
"""Display confetti animation"""
st.balloons()
def snow_animation():
"""Display snow animation"""
st.snow()