import gradio as gr import html from game.engine import get_myco_narrative def cute_mushroom_garden_html() -> str: """ Pure iframe srcdoc implementation of a cute mushroom garden. Generates happy, blinking mushrooms that grow, sway, and shrink. """ iframe_content = """
""" # Safely escape the HTML escaped_srcdoc = html.escape(iframe_content) # Return a clean, borderless container return f''' ''' def render_shroom_tab(): # 1. Assign the block to 'demo' so it can be returned with gr.Blocks() as demo: with gr.Tabs(): with gr.Tab("✨ Magic Mushroom Garden"): # The pure animation gr.HTML(value=cute_mushroom_garden_html()) # Subtle attribution gr.Markdown( "*Story generated by Myco AI*", elem_id="ai-attribution" ) # 2. Define the narrative component ONCE narrative = gr.Markdown( value="Myco is searching for a story hidden in the moss...", elem_id="narrative-card" ) # 3. Timer updates the ONE narrative component gr.Timer(20).tick(fn=get_myco_narrative, outputs=narrative) return demo