import gradio as gr import json def get_theme_css(theme): themes = { "light": { "background": "#ffffff", "text": "#000000", "accent": "#2196f3" }, "dark": { "background": "#1a1a1a", "text": "#ffffff", "accent": "#64b5f6" }, "sepia": { "background": "#f4ecd8", "text": "#5c4b37", "accent": "#8b4513" } } return themes.get(theme, themes["light"]) def get_font_size(font_size): font_sizes = { "small": "14px", "medium": "16px", "large": "18px" } return font_sizes.get(font_size, "16px") with gr.Blocks() as demo: # Store theme preference and custom settings in browser state browser_state = gr.BrowserState({ #"user_preferences": "theme": "light", "font_size": "medium",}) with gr.Row(): gr.Markdown("# Theme Customization Demo") with gr.Row(): theme_dropdown = gr.Dropdown( choices=["light", "dark", "sepia"], value="light", label="Select Theme" ) font_size = gr.Radio( choices=["small", "medium", "large"], value="medium", label="Font Size" ) preview = gr.HTML() def update_preview(theme, font_size,): theme_css = get_theme_css(theme) font_size = get_font_size(font_size) # Create a preview of the selected settings preview_html = f"""
This is how your content will look with the selected theme and settings.