"""
AI Software Factory - Space AC: Design Variations
Enhanced Gradio UI with visual JSON display + FastAPI
"""
import gradio as gr
from fastapi import FastAPI
from agents.moodboard_analyzer import MoodboardAnalyzer
from agents.design_variation_generator import DesignVariationGenerator
from agents.flutter_screen_generator import FlutterScreenGenerator
from agents.simple_flutter_generator import SimpleFlutterGenerator
import json
import os
import requests
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Initialize agents
moodboard_analyzer = MoodboardAnalyzer()
design_variation_generator = DesignVariationGenerator()
flutter_screen_generator = FlutterScreenGenerator()
simple_flutter_generator = SimpleFlutterGenerator()
# FastAPI app for orchestrator
app = FastAPI(
title="Space AC: Design Variations",
description="Design system generation agents",
version="1.0.0"
)
@app.get("/health")
async def health():
return {
"status": "healthy",
"space": "ac-design",
"agents": ["moodboard_analyzer", "design_variation_generator", "flutter_screen_generator"]
}
@app.post("/api/moodboard-analyzer")
async def moodboard_analyzer_endpoint(data: dict):
"""
API endpoint for Moodboard Analyzer
Input:
reference_images: List of image URLs/descriptions
mood_keywords: List of mood keywords
Output:
analysis: Color palettes, typography, UI patterns, insights
"""
try:
result = moodboard_analyzer.process(data)
return {
"success": True,
"agent": "moodboard_analyzer",
"output": result
}
except Exception as e:
return {
"success": False,
"error": str(e)
}
@app.post("/api/design-variation-generator")
async def design_variation_generator_endpoint(data: dict):
"""
API endpoint for Design Variation Generator
Input:
moodboard_analysis: Output from AC1
wireframe: Wireframe description
app_context: App context info
Output:
themes: List of 4 design theme variations
"""
try:
result = design_variation_generator.process(data)
return {
"success": True,
"agent": "design_variation_generator",
"output": result
}
except Exception as e:
return {
"success": False,
"error": str(e)
}
@app.post("/api/flutter-screen-generator")
async def flutter_screen_generator_endpoint(data: dict):
"""
API endpoint for Flutter Screen Generator (AC3)
Input:
theme: Complete theme from AC2
app_type: Type of app (fitness, banking, rider, etc.)
screens: List of screen names to generate
Output:
screens: List of generated screens with Flutter/Dart code
"""
try:
result = flutter_screen_generator.process(data)
return {
"success": True,
"agent": "flutter_screen_generator",
"output": result
}
except Exception as e:
return {
"success": False,
"error": str(e)
}
def create_color_palette_html(palettes):
"""Create HTML visualization for color palettes"""
html = """
"""
for palette in palettes:
html += f"""
{palette['mood']}
"""
for color in palette['colors']:
html += f"""
"""
html += """
"""
html += """
"""
return html
def create_typography_html(typography_trends):
"""Create HTML visualization for typography"""
html = """
"""
for typo in typography_trends:
html += f"""
✍️ {typo['font_family']}
{typo['usage']}
{typo['characteristics']}
"""
html += """
"""
return html
def create_ui_patterns_html(ui_patterns):
"""Create HTML visualization for UI patterns"""
html = """
"""
for pattern in ui_patterns:
freq_class = pattern.get('frequency', 'common').replace(' ', '-').lower()
freq_label = pattern.get('frequency', 'common')
html += f"""
🧩 {pattern['pattern']}
{freq_label}
"""
if 'examples' in pattern:
examples_text = ', '.join(pattern['examples'][:3])
html += f"""
Examples: {examples_text}
"""
html += """
"""
html += """
"""
return html
def create_theme_card_html(theme: dict, theme_number: int) -> str:
"""Create HTML card for a single design theme"""
html = f"""
{theme.get('mood', '')}
Colors
"""
# Add color swatches
palette = theme.get('palette', {})
for color_name, color_value in list(palette.items())[:6]: # Show first 6 colors
html += f'
'
html += f"""
Typography
Display: {theme.get('typography', {}).get('display', {}).get('font_family', 'System')}
Body: {theme.get('typography', {}).get('body', {}).get('font_family', 'System')}
Components
{theme.get('component_style', {}).get('buttons', 'Standard buttons')}
Animations
{theme.get('animations', {}).get('style', 'Standard animations')}
Speed: {theme.get('animations', {}).get('speed', 'Medium')}
Select This Theme →
"""
return html
def create_themes_grid_html(themes: list) -> str:
"""Create grid of all 4 themes"""
html = """
"""
for idx, theme in enumerate(themes, 1):
html += create_theme_card_html(theme, idx)
html += """
"""
return html
def create_preview_gallery_html(previews: list) -> str:
"""Create HTML gallery for screen previews"""
html = """
"""
for preview in previews:
screen = preview.get("screen", "Screen")
image_url = preview.get("image_url", "")
status = preview.get("status", "generated")
message = preview.get("message", "")
# Status badge
status_class = {
"generated": "status-generated",
"placeholder": "status-placeholder",
"error": "status-error",
"timeout": "status-error"
}.get(status, "status-placeholder")
status_text = {
"generated": "✅ GENERATED",
"placeholder": "⚠️ PLACEHOLDER",
"error": "❌ ERROR",
"timeout": "⏱️ TIMEOUT"
}.get(status, "UNKNOWN")
html += f"""
"""
if image_url and status == "generated":
html += f'
'
else:
html += f'
📱 {screen.upper()}
'
html += f"""
📱 {screen}
{status_text}
"""
if message:
html += f'
{message}
'
html += """
"""
html += """
"""
return html
# Gradio UI functions
def analyze_moodboard(
image_descriptions: str,
mood_keywords: str
):
"""
Gradio interface function for Moodboard Analyzer with enhanced visual output
"""
# Parse inputs
descriptions = [d.strip() for d in image_descriptions.split('\n') if d.strip()]
keywords = [k.strip() for k in mood_keywords.split(',') if k.strip()]
# Prepare input data
reference_images = [
{"description": desc, "url": ""} for desc in descriptions
]
input_data = {
"reference_images": reference_images,
"mood_keywords": keywords
}
# Process
result = moodboard_analyzer.process(input_data)
# Format output
analysis = result.get("analysis", {})
# Create visual HTML components
color_palette_html = create_color_palette_html(analysis.get("color_palettes", []))
typography_html = create_typography_html(analysis.get("typography_trends", []))
ui_patterns_html = create_ui_patterns_html(analysis.get("ui_patterns", []))
# Layout styles markdown
layout_md = "## 📐 Layout Styles\n\n"
for style in analysis.get("layout_styles", []):
layout_md += f"- {style}\n"
# Insights markdown
insights_md = "## 💡 Design Insights\n\n"
insights_md += "```\n" + analysis.get("insights", "") + "\n```"
# JSON output
json_output = json.dumps(analysis, indent=2)
return (
color_palette_html,
typography_html,
ui_patterns_html,
layout_md,
insights_md,
json_output,
analysis # Return raw data for state
)
def generate_design_themes(
moodboard_analysis_json: str,
wireframe_description: str
):
"""
Generate 4 design theme variations from moodboard analysis
"""
try:
# Parse moodboard analysis
moodboard_analysis = json.loads(moodboard_analysis_json)
except:
return (
"Error: Invalid moodboard analysis. Please run AC1 first.
",
"{}"
)
# Prepare input for AC2
input_data = {
"moodboard_analysis": moodboard_analysis,
"wireframe": wireframe_description,
"app_context": {
"type": "mobile_app"
}
}
# Generate themes
result = design_variation_generator.process(input_data)
themes = result.get("themes", [])
if not themes:
return (
"No themes generated
",
"{}"
)
# Create visual grid
themes_grid_html = create_themes_grid_html(themes)
# JSON output
json_output = json.dumps(result, indent=2)
return (
themes_grid_html,
json_output,
result # Return raw data for state
)
def create_anonymous_gist(code: str, description: str = "Flutter code from AI Software Factory") -> str:
"""
Create a GitHub Gist with the generated code
Returns the Gist ID for use with DartPad
Requires GITHUB_TOKEN environment variable for authentication
"""
try:
# Get GitHub token from environment
github_token = os.getenv("GITHUB_TOKEN", "").strip()
if not github_token:
print("❌ GITHUB_TOKEN not configured - Gist creation requires authentication")
print(" Add GITHUB_TOKEN to HuggingFace Space Secrets")
return None
url = "https://api.github.com/gists"
payload = {
"description": description,
"public": True,
"files": {
"main.dart": {
"content": code
}
}
}
headers = {
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {github_token}",
"X-GitHub-Api-Version": "2022-11-28"
}
print(f"📤 Creating Gist with GitHub API (authenticated)...")
response = requests.post(url, json=payload, headers=headers, timeout=10)
response.raise_for_status()
gist_data = response.json()
gist_id = gist_data["id"]
gist_url = gist_data.get("html_url", f"https://gist.github.com/{gist_id}")
print(f"✅ Created Gist: {gist_id}")
print(f" URL: {gist_url}")
return gist_id
except requests.exceptions.HTTPError as e:
print(f"❌ Gist creation failed (HTTP {e.response.status_code}): {e}")
if e.response.status_code == 401:
print(" Check that GITHUB_TOKEN is valid and has 'gist' scope")
return None
except Exception as e:
print(f"❌ Gist creation failed: {e}")
return None
def generate_simple_flutter(prompt: str):
"""
Simple Flutter generation: prompt -> DeepSeek -> code
Automatically creates Gist and embeds in DartPad
"""
if not prompt or not prompt.strip():
return ("", "Please enter a prompt
", "")
result = simple_flutter_generator.generate(prompt)
if not result["success"]:
error_msg = result.get("error", "Unknown error")
return ("", f"❌ Error: {error_msg}
", "")
code = result["code"]
lines = result["lines"]
# Create anonymous Gist
print("📤 Creating anonymous Gist...")
gist_id = create_anonymous_gist(code, f"Flutter code: {prompt[:100]}")
if gist_id:
# Success - embed DartPad with code loaded
dartpad_url = f"https://dartpad.dev/embed-flutter.html?id={gist_id}&theme=dark"
gist_url = f"https://gist.github.com/{gist_id}"
summary_html = f"""
✅ Codice Generato e Caricato in DartPad
Prompt: {prompt}
Righe di codice: {lines}
Gist ID: {gist_id}
🎉 Il codice è già caricato nel DartPad qui sotto!
Clicca il pulsante "▶ Run" nel DartPad per eseguire l'app
📎 Link Gist: {gist_url}
"""
dartpad_html = f"""
"""
else:
# Fallback - Gist creation failed
summary_html = f"""
⚠️ Codice Generato (Auto-load DartPad non disponibile)
Prompt: {prompt}
Righe di codice: {lines}
ℹ️ Configurazione richiesta:
Per abilitare il caricamento automatico in DartPad, l'admin dello Space deve:
Creare un GitHub Personal Access Token con scope "gist"
Aggiungerlo come Secret "GITHUB_TOKEN" nelle impostazioni dello Space
Come testare manualmente:
Espandi la sezione "💻 Codice Sorgente" qui sotto
Copia tutto il codice
Apri dartpad.dev in una nuova tab
Incolla il codice e clicca "Run"
"""
dartpad_html = """
⚠️ DartPad Manuale - Incolla il codice qui
"""
return (code, summary_html, dartpad_html)
def generate_flutter_screens(
theme_json: str,
app_type: str,
custom_prompt: str,
screens_text: str
):
"""
Generate Flutter/Dart screen code from a selected theme
"""
try:
# Parse theme JSON
theme_data = json.loads(theme_json)
# Get theme from the result
if "themes" in theme_data:
# Full AC2 output - use first theme
theme = theme_data["themes"][0]
else:
# Single theme object
theme = theme_data
except:
return (
"",
"",
"",
"❌ Error: Invalid theme JSON. Please run AC2 first and paste a theme.
"
)
# Parse screens list
screens = [s.strip() for s in screens_text.split(',') if s.strip()]
if not screens:
screens = ["home", "detail", "profile"]
# Prepare input for AC3
input_data = {
"theme": theme,
"app_type": app_type,
"custom_prompt": custom_prompt, # Add custom prompt
"screens": screens[:3] # Max 3 screens
}
# Generate Flutter screens
result = flutter_screen_generator.process(input_data)
screens_data = result.get("screens", [])
# Debug logging
print(f"🔍 DEBUG: Result keys: {result.keys()}")
print(f"🔍 DEBUG: Screens count: {len(screens_data)}")
if "error" in result:
print(f"❌ DEBUG: Error in result: {result['error']}")
if not screens_data or len(screens_data) < 4:
error_msg = result.get("error", "Unknown error")
empty = "❌ Error generating backgrounds
"
return (
f"❌ No screens generated
Error: {error_msg}
",
empty, "", empty, "", empty, "", empty, ""
)
# Get theme colors
palette = theme.get("palette", {})
primary = palette.get("primary", "#FF6D00")
secondary = palette.get("secondary", "#FFE082")
accent = palette.get("accent", "#FFA726")
def create_preview(variant_data, code):
"""Create HTML preview for a complete variant (background + header + footer + cards)"""
bg_style = variant_data.get("bg_style", "gradient_linear")
header_type = variant_data.get("header_type", "minimal")
footer_type = variant_data.get("footer_type", "minimal_icons")
variant_name = variant_data.get("name", bg_style.replace('_', ' ').title())
card_ids = variant_data.get("cards", [])
# Background layer
if bg_style == "waves":
preview_bg = f"background: linear-gradient(to bottom, {primary}20, {secondary}33, {accent}20); position: relative; overflow: hidden;"
bg_layer = f"""
"""
elif bg_style == "gradient_linear":
preview_bg = f"background: linear-gradient(135deg, {primary}, {secondary}, {accent});"
bg_layer = ""
elif bg_style == "gradient_radial":
preview_bg = f"background: radial-gradient(circle, {primary}, {secondary}, {accent});"
bg_layer = ""
else: # geometric
preview_bg = f"background: linear-gradient(135deg, {primary}33, {secondary}4D);"
bg_layer = f"""
"""
# Header layer
if header_type == "avatar_search":
header_html = f"""
"""
elif header_type == "tabs":
header_html = f"""
"""
elif header_type == "stats_header":
header_html = f"""
"""
elif header_type == "collapsible":
header_html = f"""
Welcome Back!
Ready to continue your journey?
"""
else: # minimal
header_html = f"""
"""
# Footer layer
if footer_type == "floating_fab":
footer_html = f"""
"""
elif footer_type == "animated_pills":
footer_html = f"""
"""
elif footer_type == "classic_expanded":
footer_html = f"""
"""
elif footer_type == "gesture_bar":
footer_html = f"""
"""
else: # minimal_icons
footer_html = f"""
"""
# Generate cards HTML for the content area
cards_html = ""
if card_ids:
cards_html = ''
for card_id in card_ids[:4]: # Max 4 cards in preview
try:
card_html = render_card_html(card_id, primary, secondary, accent)
# Wrap card in a container with scale to fit preview
cards_html += f'
{card_html}
'
except:
# Skip cards that fail to render
pass
cards_html += '
'
return f"""
{bg_layer}
{header_html}
{cards_html}
{footer_html}
✨ {variant_name}
"""
# Extract all 4 screens
previews = []
codes = []
variant_names = []
for i, screen in enumerate(screens_data[:4]):
code = screen.get("code", "")
preview = create_preview(screen, code)
previews.append(preview)
codes.append(code)
variant_names.append(screen.get("name", f"Variant {i+1}"))
# Create summary with variant details
variant_list_html = ""
for i, screen in enumerate(screens_data[:4]):
variant_list_html += f"""
{screen.get('name', f'Variant {i+1}')}
Background: {screen.get('bg_style', 'N/A')} |
Header: {screen.get('header_type', 'N/A')} |
Footer: {screen.get('footer_type', 'N/A')}
"""
summary_html = f"""
✅ 4 AI-Generated Variants Created!
Theme: {theme.get('name', 'Unknown')}
App Type: {app_type.capitalize()}
Total Lines: {result.get('total_lines', 0)}
Variants:
{variant_list_html}
Status: Ready! 🎨 Each variant intelligently combines background, header, and footer based on your theme style.
"""
return (
summary_html,
previews[0], codes[0], # waves
previews[1], codes[1], # linear
previews[2], codes[2], # radial
previews[3], codes[3] # geometric
)
def render_background_html(bg_id: str, bg_info: dict, primary: str, secondary: str, accent: str) -> str:
"""
Generate HTML/CSS for a single background preview
Returns HTML div with the background rendered
"""
bg_name = bg_info['name']
bg_category = bg_info['category']
# Common container style
base_style = "width: 150px; height: 250px; border-radius: 12px; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15);"
# Generate background based on type
if "gradient_linear" in bg_id:
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}, {secondary}, {accent});"
bg_layer = ""
elif "gradient_radial" in bg_id:
bg_style = f"{base_style} background: radial-gradient(circle at 30% 40%, {primary}, {secondary} 50%, {accent});"
bg_layer = ""
elif "gradient_angular" in bg_id:
bg_style = f"{base_style} background: conic-gradient(from 45deg, {primary}, {secondary}, {accent}, {primary});"
bg_layer = ""
elif "gradient_sweep" in bg_id:
bg_style = f"{base_style} background: conic-gradient(from 0deg at 50% 50%, {primary}, {secondary}, {accent}, {primary});"
bg_layer = ""
elif "gradient_diagonal" in bg_id:
bg_style = f"{base_style} background: linear-gradient(45deg, {primary} 0%, {secondary} 50%, {accent} 100%);"
bg_layer = ""
elif "gradient_mesh" in bg_id:
bg_style = f"{base_style} background: radial-gradient(at 20% 30%, {primary} 0%, transparent 50%), radial-gradient(at 80% 70%, {secondary} 0%, transparent 50%), radial-gradient(at 50% 50%, {accent} 0%, transparent 50%), linear-gradient(135deg, {primary}20, {secondary}30);"
bg_layer = ""
elif "waves_smooth" in bg_id or "waves_sharp" in bg_id or "waves_layered" in bg_id or "waves_curved" in bg_id or "waves_minimal" in bg_id:
bg_style = f"{base_style} background: linear-gradient(to bottom, {primary}20, {secondary}33, {accent}20);"
bg_layer = f"""
"""
elif "geometric_circles" in bg_id:
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}33, {secondary}4D);"
bg_layer = f"""
"""
elif "geometric_triangles" in bg_id:
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}1A, {secondary}26);"
bg_layer = f"""
"""
elif "geometric_hexagons" in bg_id:
bg_style = f"{base_style} background: linear-gradient(to bottom, {primary}1A, {secondary}26);"
bg_layer = f"""
"""
elif "geometric_grid" in bg_id:
bg_style = f"{base_style} background: repeating-linear-gradient(0deg, transparent, transparent 19px, {primary}40 19px, {primary}40 20px), repeating-linear-gradient(90deg, transparent, transparent 19px, {secondary}40 19px, {secondary}40 20px), {accent}0D;"
bg_layer = ""
elif "geometric_stripes" in bg_id:
bg_style = f"{base_style} background: repeating-linear-gradient(45deg, {primary}40, {primary}40 10px, {secondary}40 10px, {secondary}40 20px, {accent}30 20px, {accent}30 30px);"
bg_layer = ""
elif "geometric_diamonds" in bg_id:
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}1A 25%, transparent 25%), linear-gradient(225deg, {secondary}1A 25%, transparent 25%), linear-gradient(45deg, {accent}1A 25%, transparent 25%), linear-gradient(315deg, {primary}26 25%, {secondary}0D 25%);"
bg_layer = ""
elif "organic_blobs" in bg_id or "organic_fluid" in bg_id:
bg_style = f"{base_style} background: {secondary}26;"
bg_layer = f"""
"""
elif "organic_noise" in bg_id:
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}33, {secondary}4D); filter: contrast(170%) brightness(1000%);"
bg_layer = f'
'
elif "organic_clouds" in bg_id:
bg_style = f"{base_style} background: linear-gradient(to bottom, {primary}40, {secondary}60, {accent}40);"
bg_layer = f"""
"""
elif "pattern_dots" in bg_id:
bg_style = f"{base_style} background: radial-gradient(circle, {primary} 2px, transparent 2px); background-size: 20px 20px; background-color: {secondary}1A;"
bg_layer = ""
elif "pattern_lines" in bg_id:
bg_style = f"{base_style} background: repeating-linear-gradient(0deg, {primary}60, {primary}60 2px, transparent 2px, transparent 10px), {secondary}1A;"
bg_layer = ""
elif "pattern_chevron" in bg_id:
bg_style = f"{base_style} background: repeating-linear-gradient(45deg, {primary}40, {primary}40 10px, {secondary}40 10px, {secondary}40 20px);"
bg_layer = ""
elif "pattern_zigzag" in bg_id:
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}40 25%, transparent 25%), linear-gradient(225deg, {secondary}40 25%, transparent 25%), linear-gradient(315deg, {accent}30 25%, transparent 25%); background-size: 20px 20px;"
bg_layer = ""
elif "abstract_crystalline" in bg_id or "abstract_voronoi" in bg_id:
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}26, {secondary}33, {accent}26);"
bg_layer = f"""
"""
elif "abstract_particles" in bg_id:
bg_style = f"{base_style} background: {secondary}1A;"
bg_layer = f"""
"""
elif "abstract_rays" in bg_id:
bg_style = f"{base_style} background: radial-gradient(circle at 50% 120%, {primary}, {secondary} 40%, {accent} 80%);"
bg_layer = ""
elif "abstract_constellation" in bg_id:
bg_style = f"{base_style} background: linear-gradient(to bottom, {primary}1A, {secondary}26, {accent}1A);"
bg_layer = f"""
"""
else:
# Fallback: simple gradient
bg_style = f"{base_style} background: linear-gradient(135deg, {primary}, {secondary});"
bg_layer = ""
return f"""
{bg_layer}
"""
def render_header_html(header_id: str, header_info: dict, primary: str, secondary: str, accent: str) -> str:
"""
Generate HTML/CSS for a single header preview (20 realistic headers)
Returns HTML div with the header rendered
"""
header_name = header_info['name']
# Common container style
base_style = "width: 300px; height: 100px; border-radius: 12px 12px 0 0; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: linear-gradient(135deg, {}, {});".format(primary, secondary)
# SOCIAL & PROFILE (5)
if header_id == "profile_avatar_menu":
content = f"""
👤
John Doe
📍 San Francisco, CA
☰
"""
elif header_id == "avatar_notification_cart":
content = f"""
"""
elif header_id == "profile_stats_share":
content = f"""
"""
elif header_id == "social_search_filter":
content = f"""
"""
elif header_id == "messenger_header":
content = f"""
"""
# LOCATION & DELIVERY (4)
elif header_id == "location_picker":
content = f"""
📍
Deliver to
1234 Market St, SF ▼
🔔
"""
elif header_id == "delivery_address_time":
content = f"""
📍
1234 Market Street
Change
⏱️
Delivery in 25-30 mins
"""
elif header_id == "map_search_location":
content = f"""
"""
elif header_id == "ride_pickup_header":
content = f"""
🟢
Home - 123 Main St
🔴
Office - 456 Market St
🔄
"""
# E-COMMERCE (3)
elif header_id == "shop_cart_wishlist":
content = f"""
🏪 ShopApp
🔍 Search products...
❤️
"""
elif header_id == "category_filter_sort":
content = f"""
Electronics ▼
🎚️ Filter
⬍ Sort
"""
elif header_id == "product_search_scan":
content = f"""
"""
# FINANCE & WALLET (3)
elif header_id == "wallet_balance_qr":
content = f"""
"""
elif header_id == "banking_accounts_menu":
content = f"""
"""
elif header_id == "crypto_portfolio_refresh":
content = f"""
"""
# HEALTH & FITNESS (2)
elif header_id == "fitness_streak_profile":
content = f"""
💪
Sarah's Fitness
🔥 7 day streak
🏆 Level 12
"""
elif header_id == "workout_timer_pause":
content = f"""
"""
# MEDIA & ENTERTAINMENT (3)
elif header_id == "video_player_controls":
content = f"""
←
How to Code in Python
TechChannel • 1.2M views
📡
⋮
"""
elif header_id == "music_player_header":
content = f"""
←
Blinding Lights
The Weeknd
❤️
"""
elif header_id == "news_category_tabs":
content = f"""
📰 NewsApp
🔖
Top
Tech
Sports
World
"""
else:
content = "Header Preview
"
return f"""
{content}
"""
def render_footer_html(footer_id: str, footer_info: dict, primary: str, secondary: str, accent: str) -> str:
"""
Generate HTML/CSS for a single footer preview (30 footer layouts)
Returns HTML div with the footer rendered
"""
footer_name = footer_info['name']
# Common container style
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: white;"
# CLASSIC TAB BARS (6)
if footer_id == "classic_4_icons":
content = f"""
"""
elif footer_id == "classic_5_icons":
content = f"""
"""
elif footer_id == "compact_icons_badge":
content = f"""
"""
elif footer_id == "labeled_vertical":
content = f"""
"""
elif footer_id == "colored_active":
content = f"""
"""
elif footer_id == "icon_label_inline":
content = f"""
"""
# FLOATING & FAB STYLES (5)
elif footer_id == "floating_rounded":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: transparent;"
content = f"""
"""
elif footer_id == "floating_fab_center":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: transparent;"
content = f"""
"""
elif footer_id == "floating_translucent":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: transparent;"
content = f"""
"""
elif footer_id == "floating_pills_bar":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: transparent;"
content = f"""
"""
elif footer_id == "dual_fab":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: transparent;"
content = f"""
"""
# CURVED & SHAPED DESIGNS (5)
elif footer_id == "curved_top":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: white;"
content = f"""
"""
elif footer_id == "notched_center":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: white;"
content = f"""
"""
elif footer_id == "wave_top":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: white;"
content = f"""
"""
elif footer_id == "island_bar":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: transparent;"
content = f"""
"""
elif footer_id == "arc_active":
base_style = "width: 300px; height: 70px; border-radius: 0 0 12px 12px; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: white;"
content = f"""
"""
# SEGMENTED & PILLS (5)
elif footer_id == "segmented_control":
content = f"""
"""
elif footer_id == "pill_buttons":
content = f"""
"""
elif footer_id == "grouped_pills":
content = f"""
"""
elif footer_id == "slider_nav":
content = f"""
"""
elif footer_id == "morphing_pills":
content = f"""
"""
# MINIMALIST & GESTURE (4)
elif footer_id == "minimal_dots":
content = f"""
"""
elif footer_id == "gesture_swipe":
content = f"""
"""
elif footer_id == "thin_bar":
content = f"""
"""
elif footer_id == "invisible_tap":
content = f"""
"""
# ADVANCED & INTERACTIVE (5)
elif footer_id == "expandable_drawer":
content = f"""
"""
elif footer_id == "grid_menu":
content = f"""
"""
elif footer_id == "carousel_nav":
content = f"""
🏠 Home
🔍 Search
❤️ Saved
👤 Profile
"""
elif footer_id == "context_aware":
content = f"""
"""
elif footer_id == "nested_menu":
content = f"""
"""
else:
content = "Footer Preview
"
return f"""
{content}
"""
def render_card_html(card_id: str, card_info: dict, primary: str, secondary: str, accent: str) -> str:
"""
Generate HTML/CSS for a single card preview (30 card types)
Returns HTML div with the card rendered
"""
card_name = card_info['name']
# Common container style - responsive with max-width
base_style = "width: 100%; max-width: 180px; min-height: 240px; border-radius: 12px; position: relative; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex; flex-direction: column;"
# PRODUCT & SHOPPING (6)
if card_id == "product_vertical":
content = f"""
📱
Product Name
Short description
$99.00
"""
elif card_id == "product_horizontal":
base_style = "width: 100%; max-width: 280px; height: 100px; border-radius: 12px; position: relative; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex;"
content = f"""
📱
"""
elif card_id == "product_badge":
content = f"""
"""
elif card_id == "product_rating":
content = f"""
📱
Product Name
⭐⭐⭐⭐⭐
(245)
$99.00
"""
elif card_id == "product_grid_compact":
base_style = "width: 100%; max-width: 140px; min-height: 180px; border-radius: 12px; position: relative; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex; flex-direction: column;"
content = f"""
📱
"""
elif card_id == "product_featured":
base_style = "width: 100%; max-width: 280px; height: 200px; border-radius: 12px; position: relative; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: linear-gradient(135deg, {primary}, {secondary});"
content = f"""
FEATURED
Premium Product
$199.00
"""
# PROFILE & SOCIAL (5)
elif card_id == "profile_user_card":
content = f"""
👤
Creative designer & developer passionate about UI/UX
Follow
"""
elif card_id == "profile_stats_card":
content = f"""
👤
Sarah Smith
Product Designer
"""
elif card_id == "social_post_card":
base_style = "width: 100%; max-width: 280px; min-height: 280px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
Just launched my new project! 🚀 Check it out!
🎨
❤️ 245
💬 32
📤 12
"""
elif card_id == "social_story_card":
base_style = "width: 100%; max-width: 100px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); position: relative;"
content = f"""
👤
Sarah
"""
elif card_id == "contact_card":
content = f"""
👤
Mike Johnson
Software Engineer
📧
mike@email.com
📱
+1 234 567 8900
Message
Call
"""
# CONTENT & MEDIA (5)
elif card_id == "article_card":
base_style = "width: 100%; max-width: 280px; min-height: 260px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
📰
TECHNOLOGY
The Future of AI in Design
Discover how artificial intelligence is revolutionizing the creative industry...
⏱️ 5 min read
"""
elif card_id == "video_card":
base_style = "width: 100%; max-width: 280px; height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); position: relative;"
content = f"""
▶️
12:45
How to Build Apps
12K views • 2 days ago
"""
elif card_id == "podcast_card":
base_style = "width: 100%; max-width: 280px; height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex;"
content = f"""
🎙️
Tech Talk #42
The Future of Web3
"""
elif card_id == "news_headline":
base_style = "width: 100%; max-width: 280px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex; gap: 12px; padding: 10px;"
content = f"""
📰
Breaking: Major Tech Announcement Today
2 hours ago • Tech News
"""
elif card_id == "blog_featured":
base_style = "width: 100%; max-width: 280px; height: 240px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); position: relative;"
content = f"""
FEATURED
DESIGN
Creating Beautiful User Experiences
by Sarah Johnson • 8 min read
"""
# STATS & ANALYTICS (4)
elif card_id == "stats_metric":
base_style = "width: 100%; max-width: 160px; height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; justify-content: space-between;"
content = f"""
📊
2,458
Total Sales
↗ +12.5%
"""
elif card_id == "stats_comparison":
base_style = "width: 100%; max-width: 240px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; gap: 16px;"
content = f"""
"""
elif card_id == "stats_progress":
base_style = "width: 100%; max-width: 200px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; justify-content: space-between;"
content = f"""
"""
elif card_id == "stats_chart":
base_style = "width: 100%; max-width: 200px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Weekly Stats
Last 7 days
"""
# MESSAGING & NOTIFICATIONS (4)
elif card_id == "message_preview":
base_style = "width: 100%; max-width: 280px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex; align-items: center; gap: 12px; padding: 12px;"
content = f"""
👤
Hey! Did you see the new design?
"""
elif card_id == "notification_card":
content = f"""
🔔
You have a new message from the support team
5 minutes ago
"""
elif card_id == "alert_card":
base_style = "width: 100%; max-width: 280px; min-height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: #FFF3CD; border: 1px solid #FFE69C;"
content = f"""
⚠️
Warning
Your storage is almost full. Please free up some space.
×
"""
elif card_id == "chat_bubble":
base_style = "width: 100%; max-width: 220px; min-height: 60px; border-radius: 16px 16px 16px 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: {primary}; padding: 12px; position: relative;"
content = f"""
Hey! How are you doing? I wanted to check in about the project.
2:45 PM
"""
# SPECIAL CARDS (6)
elif card_id == "pricing_plan":
base_style = "width: 100%; max-width: 200px; min-height: 280px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; border: 2px solid #eee;"
content = f"""
✓ 100 Projects
✓ Unlimited Storage
✓ Priority Support
✓ Analytics
Get Started
"""
elif card_id == "review_card":
content = f"""
"Amazing product! Exceeded all my expectations. Highly recommend to anyone looking for quality."
2 days ago
"""
elif card_id == "event_card":
base_style = "width: 100%; max-width: 280px; height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex;"
content = f"""
Tech Conference 2024
📍 San Francisco, CA
👥 245 attending
"""
elif card_id == "offer_coupon":
base_style = "width: 100%; max-width: 260px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; border: 2px dashed {primary}; position: relative;"
content = f"""
SPECIAL OFFER
25% OFF
On your next purchase
Expires in 3 days
"""
elif card_id == "weather_card":
base_style = "width: 100%; max-width: 200px; height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: linear-gradient(135deg, {primary}, {secondary}); color: white; padding: 20px;"
content = f"""
San Francisco
☀️
72°
Sunny
"""
elif card_id == "ticket_card":
base_style = "width: 100%; max-width: 280px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; position: relative;"
content = f"""
Concert Night 2024
📅 Dec 25, 2024 • 8:00 PM
📍 Madison Square Garden
Seat: A-12 | Row: 5
"""
# E-COMMERCE EXTENDED (15)
elif card_id == "cart_item":
base_style = "width: 100%; max-width: 300px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; display: flex; gap: 12px; padding: 12px;"
content = f"""
👟
Running Shoes
Size: 42, Color: Blue
"""
elif card_id == "wishlist_item":
base_style = "width: 100%; max-width: 200px; min-height: 260px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
"""
elif card_id == "checkout_step":
base_style = "width: 100%; max-width: 300px; min-height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
"""
elif card_id == "shipping_option":
base_style = "width: 100%; max-width: 280px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; align-items: center; gap: 12px;"
content = f"""
Express Delivery
Arrives tomorrow
$9.99
"""
elif card_id == "product_review":
content = f"""
👤
John Doe ✓ Verified
⭐⭐⭐⭐⭐
Great product! Exactly as described. Fast shipping too.
👍 45 people found this helpful
"""
elif card_id == "category_grid":
base_style = "width: 100%; max-width: 120px; height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;"
content = f"""
👕
Clothing
245 items
"""
elif card_id == "filter_chip":
base_style = "width: 100%; max-width: 100px; height: 36px; border-radius: 18px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: {primary}; color: white; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 6px;"
content = f"""
On Sale
×
"""
elif card_id == "order_summary":
base_style = "width: 100%; max-width: 280px; min-height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Order Summary
Subtotal (3 items)
$237.00
Shipping
$9.99
Discount
-$20.00
Total
$226.99
"""
elif card_id == "payment_method":
base_style = "width: 100%; max-width: 280px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; align-items: center; gap: 12px;"
content = f"""
VISA
DEFAULT
"""
elif card_id == "order_tracking":
base_style = "width: 100%; max-width: 300px; min-height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Order #12345
✓
Order Placed
Dec 15, 2:30 PM
3
Delivered
Estimated: Dec 18
"""
elif card_id == "brand_showcase":
base_style = "width: 100%; max-width: 200px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;"
content = f"""
🏷️
Nike
1,234 products
Follow
"""
elif card_id == "size_selector":
base_style = "width: 100%; max-width: 240px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Select Size
"""
elif card_id == "color_picker":
base_style = "width: 100%; max-width: 200px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Color: Ocean Blue
"""
elif card_id == "flash_sale":
base_style = "width: 100%; max-width: 240px; min-height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: linear-gradient(135deg, #FF3B30, #FF9500);"
content = f"""
📱
"""
elif card_id == "related_products":
base_style = "width: 100%; max-width: 120px; min-height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
📱
"""
# SOCIAL EXTENDED (10)
elif card_id == "comment_thread":
base_style = "width: 100%; max-width: 300px; min-height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px;"
content = f"""
👤
Alex Kim • 2h ago
This is amazing! Can't wait to try it out.
👍 12
💬 Reply
"""
elif card_id == "reaction_bar":
base_style = "width: 100%; max-width: 200px; height: 48px; border-radius: 24px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 8px 16px; display: flex; align-items: center; justify-content: space-around; gap: 8px;"
content = f"""
👍
❤️
😂
😮
😢
"""
elif card_id == "share_sheet":
base_style = "width: 100%; max-width: 280px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Share
"""
elif card_id == "follower_item":
base_style = "width: 100%; max-width: 280px; height: 72px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
👤
Emma Watson
Followed by john_doe + 12 others
Follow
"""
elif card_id == "story_ring":
base_style = "width: 100%; max-width: 80px; height: 100px; display: flex; flex-direction: column; align-items: center; gap: 6px;"
content = f"""
John
"""
elif card_id == "reel_preview":
base_style = "width: 100%; max-width: 160px; height: 280px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); position: relative;"
content = f"""
▶️
0:45
"""
elif card_id == "live_streaming":
base_style = "width: 100%; max-width: 260px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); position: relative;"
content = f"""
🔴 LIVE
👁️ 2.3K
Tech Talk Live
with @johndoe
"""
elif card_id == "poll_card":
base_style = "width: 100%; max-width: 280px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Which feature do you want next?
1,234 votes • 2 days left
"""
elif card_id == "mention_tag":
base_style = "width: 100%; max-width: 120px; height: 36px; border-radius: 18px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.1); background: {primary}10; color: {primary}; padding: 0 14px; display: flex; align-items: center; justify-content: center;"
content = f"""
@johndoe
"""
elif card_id == "group_member":
base_style = "width: 100%; max-width: 280px; height: 72px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
👤
Sarah Johnson ADMIN
Joined 3 months ago
⋮
"""
# FINANCE & BANKING (10)
elif card_id == "account_balance":
base_style = "width: 100%; max-width: 280px; min-height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: linear-gradient(135deg, {primary}, {secondary}); padding: 16px; color: white;"
content = f"""
Checking Account
$12,459.32
**** 4242
"""
elif card_id == "transaction_item":
base_style = "width: 100%; max-width: 300px; height: 72px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
🏪
Amazon
Shopping • Today at 2:30 PM
-$49.99
"""
elif card_id == "credit_card":
base_style = "width: 100%; max-width: 320px; height: 200px; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,0.2); background: linear-gradient(135deg, {primary}, {secondary}); padding: 20px; color: white; position: relative;"
content = f"""
💳
**** **** **** 4242
"""
elif card_id == "transfer_form":
base_style = "width: 100%; max-width: 280px; min-height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Transfer Money
Confirm Transfer
"""
elif card_id == "investment_item":
base_style = "width: 100%; max-width: 280px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px;"
content = f"""
"""
elif card_id == "crypto_wallet":
base_style = "width: 100%; max-width: 260px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
"""
elif card_id == "bill_payment":
base_style = "width: 100%; max-width: 280px; height: 90px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; align-items: center; gap: 12px;"
content = f"""
⚡
Electricity Bill
Due: Dec 25, 2024
$124.50
Pay
"""
elif card_id == "budget_category":
base_style = "width: 100%; max-width: 260px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
🍔
Food & Dining
$450 of $600
$150 remaining
"""
elif card_id == "loan_summary":
base_style = "width: 100%; max-width: 280px; min-height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Home Loan
Outstanding
$245,000
Monthly EMI
$1,850
Next Payment
Jan 1, 2025
"""
elif card_id == "statement_month":
base_style = "width: 100%; max-width: 240px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; align-items: center; justify-content: space-between;"
content = f"""
December 2024
Total Spent
$3,245.80
📄
"""
# HEALTH & FITNESS (10)
elif card_id == "workout_exercise":
base_style = "width: 100%; max-width: 280px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px;"
content = f"""
"""
elif card_id == "nutrition_log":
base_style = "width: 100%; max-width: 300px; height: 90px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; gap: 12px;"
content = f"""
🥗
Grilled Chicken Salad
245 cal
P: 32g • C: 12g • F: 8g
"""
elif card_id == "step_counter":
base_style = "width: 100%; max-width: 160px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;"
content = f"""
Goal: 10,000
"""
elif card_id == "heart_rate":
base_style = "width: 100%; max-width: 240px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
"""
elif card_id == "sleep_tracker":
base_style = "width: 100%; max-width: 280px; min-height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
7h 32m
Deep: 2h 15m
Light: 4h 45m
REM: 32m
"""
elif card_id == "water_intake":
base_style = "width: 100%; max-width: 200px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; justify-content: space-between;"
content = f"""
Water Intake
6 of 8 glasses
+ Add Glass
"""
elif card_id == "bmi_calculator":
base_style = "width: 100%; max-width: 220px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;"
content = f"""
Body Mass Index
22.5
Normal Weight
Height: 175cm • Weight: 69kg
"""
elif card_id == "calorie_goal":
base_style = "width: 100%; max-width: 240px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Daily Calories
"""
elif card_id == "meditation_session":
base_style = "width: 100%; max-width: 260px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: linear-gradient(135deg, {primary}, {secondary}); padding: 20px; color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;"
content = f"""
🧘
Mindful Breathing
10 minutes
▶️
"""
elif card_id == "weight_progress":
base_style = "width: 100%; max-width: 280px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Weight Progress
"""
# EDUCATION & LEARNING (8)
elif card_id == "course_card":
base_style = "width: 100%; max-width: 280px; min-height: 280px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
📚
Complete Web Development Bootcamp
by Dr. Angela Yu
"""
elif card_id == "lesson_item":
base_style = "width: 100%; max-width: 300px; height: 72px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
5
Introduction to React Hooks
⏱️ 18 min • 📹 Video
✓
"""
elif card_id == "quiz_question":
base_style = "width: 100%; max-width: 300px; min-height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Question 3 of 10
What is the correct way to create a useState hook in React?
A) const [state, setState] = useState()
B) const [state, setState] = useState(initialValue)
C) useState(state, setState)
D) const state = useState()
"""
elif card_id == "certificate_card":
base_style = "width: 100%; max-width: 320px; height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: linear-gradient(135deg, #f5f5f5, #e0e0e0); padding: 20px; position: relative; border: 4px solid {primary};"
content = f"""
CERTIFICATE OF COMPLETION
Web Development Bootcamp
Awarded to John Doe
Completed on December 15, 2024
🏆
"""
elif card_id == "learning_progress":
base_style = "width: 100%; max-width: 260px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
JavaScript Masterclass
"""
elif card_id == "assignment_card":
base_style = "width: 100%; max-width: 280px; min-height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px;"
content = f"""
Build a React Todo App
Due: Dec 20, 2024
PENDING
📎 Upload Submission
"""
elif card_id == "grade_item":
base_style = "width: 100%; max-width: 260px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; align-items: center; justify-content: space-between;"
content = f"""
Mathematics
Final Exam • 85/100 points
A
"""
elif card_id == "study_streak":
base_style = "width: 100%; max-width: 180px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;"
content = f"""
🔥
15
Day Streak
Keep it up!
"""
# TRAVEL & TOURISM (8) - FOOD & RESTAURANT (8) - REAL ESTATE (7) - MUSIC & AUDIO (7) - GAMING (6) - PRODUCTIVITY (6) - DASHBOARD WIDGETS (8)
elif card_id == "flight_card":
base_style = "width: 100%; max-width: 320px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
"""
elif card_id == "hotel_listing":
base_style = "width: 100%; max-width: 280px; min-height: 240px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
🏨
Grand Hotel Downtown
⭐⭐⭐⭐⭐
📍 Times Square, New York • WiFi, Pool, Gym
"""
elif card_id == "booking_confirm":
base_style = "width: 100%; max-width: 300px; min-height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Booking Confirmed
ID: BK-12345678
Grand Hotel
Check-in: Dec 20, 2024
Check-out: Dec 22, 2024
2 Guests • 1 Room
"""
elif card_id == "destination_card":
base_style = "width: 100%; max-width: 240px; height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); position: relative;"
content = f"""
HOT DEAL
🗼
Paris
France • From $599
"""
elif card_id == "itinerary_day":
base_style = "width: 100%; max-width: 300px; min-height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Day 2 - Paris
09:00
Eiffel Tower
📍 Champ de Mars
13:00
Louvre Museum
📍 Rue de Rivoli
19:00
Seine River Cruise
📍 Port de la Bourdonnais
"""
elif card_id == "map_location":
base_style = "width: 100%; max-width: 280px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; gap: 12px;"
content = f"""
📍
Central Park
5th Ave, New York, NY
2.5 km away
→
"""
elif card_id == "travel_review":
base_style = "width: 100%; max-width: 280px; min-height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px;"
content = f"""
"Amazing experience! The hotel was perfect and the location was great."
📷 3 photos • 👍 24 helpful • 2 weeks ago
"""
elif card_id == "passport_info":
base_style = "width: 100%; max-width: 280px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px;"
content = f"""
Number: A12345678
Nationality: United States
Expires: Mar 15, 2025
"""
elif card_id == "menu_item":
base_style = "width: 100%; max-width: 280px; min-height: 240px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
🍔
Classic Burger
Beef patty, lettuce, tomato, cheese, special sauce
"""
elif card_id == "recipe_card":
base_style = "width: 100%; max-width: 280px; min-height: 260px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
🍝
Spaghetti Carbonara
⏱️ 25 min
👨🍳 Medium
🍽️ 4 servings
"""
elif card_id == "order_item":
base_style = "width: 100%; max-width: 300px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; gap: 12px;"
content = f"""
🍕
Margherita Pizza
x2 • Large • Extra cheese
$28.00
"""
elif card_id == "reservation_slot":
base_style = "width: 100%; max-width: 240px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; align-items: center; justify-content: space-between;"
content = f"""
7:30 PM
4 seats available
Book
"""
elif card_id == "delivery_tracker":
base_style = "width: 100%; max-width: 300px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Order #5678
🚗 Out for Delivery
Your order will arrive in 15-20 minutes
👤
John Driver
⭐ 4.9 • 245 deliveries
"""
elif card_id == "restaurant_rating":
base_style = "width: 100%; max-width: 260px; height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
4.5
⭐⭐⭐⭐⭐
Based on 1,234 reviews
"""
elif card_id == "ingredient_list":
base_style = "width: 100%; max-width: 260px; height: 60px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
"""
elif card_id == "dietary_tag":
base_style = "width: 100%; max-width: 100px; height: 32px; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.1); background: #34C759; color: white; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 4px;"
content = f"""
🌱
Vegan
"""
elif card_id == "property_listing":
base_style = "width: 100%; max-width: 300px; min-height: 280px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
🏠
$425,000
Modern Downtown Apartment
📍 123 Main St, New York
🛏️ 2 beds
🚿 2 baths
📐 1,200 sqft
"""
elif card_id == "agent_card":
base_style = "width: 100%; max-width: 240px; min-height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;"
content = f"""
👤
Sarah Johnson
Real Estate Agent
245 properties sold • ⭐ 4.9
Contact
"""
elif card_id == "virtual_tour":
base_style = "width: 100%; max-width: 240px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: linear-gradient(135deg, {primary}, {secondary}); padding: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: white;"
content = f"""
🔄
360° Virtual Tour
Living Room
View Tour
"""
elif card_id == "mortgage_calc":
base_style = "width: 100%; max-width: 280px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Mortgage Calculator
Loan Amount
$340,000
Interest Rate
6.5%
Term
30 years
"""
elif card_id == "property_compare":
base_style = "width: 100%; max-width: 320px; min-height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Property Comparison
Property A
$425,000
2 beds • 2 baths
1,200 sqft
Property B
$399,000
2 beds • 1 bath
1,100 sqft
"""
elif card_id == "favorite_property":
base_style = "width: 100%; max-width: 280px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; gap: 12px;"
content = f"""
🏠
$425,000
123 Main St, NY
2 beds • 2 baths
❤️
"""
elif card_id == "open_house":
base_style = "width: 100%; max-width: 260px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px;"
content = f"""
Open House
Saturday, Dec 21
10:00 AM - 2:00 PM
🏠
📍 123 Oak Street, Brooklyn
"""
elif card_id == "playlist_card":
base_style = "width: 100%; max-width: 200px; min-height: 240px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
🎵
Chill Vibes
Created by Spotify • 50 songs
▶️ Play
"""
elif card_id == "song_item":
base_style = "width: 100%; max-width: 300px; height: 72px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
🎵
Blinding Lights
The Weeknd
3:20
⋮
"""
elif card_id == "album_cover":
base_style = "width: 100%; max-width: 200px; height: 240px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; flex-direction: column; gap: 10px;"
content = f"""
💿
After Hours
The Weeknd • 2020
"""
elif card_id == "artist_profile":
base_style = "width: 100%; max-width: 240px; min-height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;"
content = f"""
🎤
The Weeknd
85M monthly listeners
Follow
"""
elif card_id == "podcast_episode":
base_style = "width: 100%; max-width: 300px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; gap: 12px;"
content = f"""
🎙️
Episode 42: Future of AI
Dec 15, 2024 • 45 min
▶️ Play
"""
elif card_id == "radio_station":
base_style = "width: 100%; max-width: 200px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;"
content = f"""
📻
Pop Hits Radio
Now: Blinding Lights
Tune In
"""
elif card_id == "equalizer_preset":
base_style = "width: 100%; max-width: 240px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Bass Boost
Apply
"""
elif card_id == "achievement_badge":
base_style = "width: 100%; max-width: 160px; height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;"
content = f"""
🏆
Unlocked: Dec 15, 2024
"""
elif card_id == "leaderboard_entry":
base_style = "width: 100%; max-width: 300px; height: 72px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
1
👤
12,458
↗ +2
"""
elif card_id == "character_card":
base_style = "width: 100%; max-width: 200px; min-height: 280px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white;"
content = f"""
⚔️
Warrior
Level 24 • Epic
⚡ Attack: 85
🛡️ Defense: 72
❤️ Health: 450
"""
elif card_id == "game_item":
base_style = "width: 100%; max-width: 140px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px;"
content = f"""
⚔️
Legendary Sword
LEGENDARY
Quantity: 1
"""
elif card_id == "quest_card":
base_style = "width: 100%; max-width: 280px; min-height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px;"
content = f"""
Defeat the Dragon
Slay the ancient dragon in the Dark Cave
🐉
Reward: 500 Gold, Epic Armor
"""
elif card_id == "player_stats":
base_style = "width: 100%; max-width: 260px; min-height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Player Stats
"""
elif card_id == "task_item":
base_style = "width: 100%; max-width: 280px; height: 60px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
Finish project proposal
Due: Tomorrow • High priority
"""
elif card_id == "note_card":
base_style = "width: 100%; max-width: 220px; min-height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: #FFF9C4; padding: 14px;"
content = f"""
Meeting Notes
Discussed Q4 strategy and team goals. Follow up with marketing...
Dec 15, 2024
"""
elif card_id == "reminder_alert":
base_style = "width: 100%; max-width: 280px; height: 80px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; display: flex; align-items: center; gap: 12px;"
content = f"""
🔔
Team Meeting
in 15 minutes
Snooze
OK
"""
elif card_id == "timer_widget":
base_style = "width: 100%; max-width: 180px; height: 180px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;"
content = f"""
▶️
⟳
"""
elif card_id == "calendar_event":
base_style = "width: 100%; max-width: 280px; height: 90px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 14px; border-left: 4px solid {primary};"
content = f"""
Product Launch Meeting
⏱️ 2:00 PM - 3:30 PM
📍 Conference Room A • 👥 8 attendees
"""
elif card_id == "project_card":
base_style = "width: 100%; max-width: 280px; min-height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Website Redesign
Deadline: Dec 31, 2024
"""
elif card_id == "kpi_card":
base_style = "width: 100%; max-width: 200px; height: 120px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px; display: flex; flex-direction: column; justify-content: space-between;"
content = f"""
Revenue
$124K
"""
elif card_id == "pie_chart":
base_style = "width: 100%; max-width: 240px; height: 200px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Sales by Category
"""
elif card_id == "line_graph":
base_style = "width: 100%; max-width: 300px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Monthly Revenue
Jan
Feb
Mar
Apr
May
Jun
"""
elif card_id == "bar_chart":
base_style = "width: 100%; max-width: 260px; height: 160px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Weekly Activity
"""
elif card_id == "metric_alert":
base_style = "width: 100%; max-width: 280px; height: 100px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: #FFF3CD; border: 1px solid #FFE69C; padding: 14px; display: flex; align-items: center; gap: 12px;"
content = f"""
⚠️
High CPU Usage
Server load at 92% - exceeds threshold
View
"""
elif card_id == "summary_widget":
base_style = "width: 100%; max-width: 300px; min-height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Summary • Last 7 days
"""
elif card_id == "activity_feed":
base_style = "width: 100%; max-width: 300px; height: 72px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 12px; display: flex; align-items: center; gap: 12px;"
content = f"""
✓
John Doe completed task "Design Review"
2 hours ago
"""
elif card_id == "heatmap_widget":
base_style = "width: 100%; max-width: 300px; height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: white; padding: 16px;"
content = f"""
Activity Heatmap
Less activity ← → More activity
"""
else:
content = "Card Preview
"
return f"""
{content}
"""
def generate_background_gallery(theme_json: str = ""):
"""
Generate HTML gallery of all 30 backgrounds organized by category
Backgrounds are rendered directly with HTML/CSS using theme colors
"""
from agents.flutter_screen_generator import FlutterScreenGenerator
agent = FlutterScreenGenerator()
catalog = agent.BACKGROUND_CATALOG
# Parse theme or use defaults
if theme_json and theme_json.strip():
try:
theme = json.loads(theme_json)
palette = theme.get("palette", {})
primary = palette.get("primary", "#007AFF")
secondary = palette.get("secondary", "#5856D6")
accent = palette.get("accent", "#FF9500")
theme_name = theme.get("name", "Custom Theme")
using_theme = True
except:
primary = "#007AFF"
secondary = "#5856D6"
accent = "#FF9500"
theme_name = "Default"
using_theme = False
else:
primary = "#007AFF"
secondary = "#5856D6"
accent = "#FF9500"
theme_name = "Default"
using_theme = False
# Organize by category
categories = {}
for bg_id, info in catalog.items():
cat = info['category']
if cat not in categories:
categories[cat] = []
categories[cat].append((bg_id, info))
theme_indicator = f"""
🎨 Tema applicato: {theme_name}
""" if using_theme else """
⚠️ Tema non applicato
Inserisci un tema JSON sopra e clicca "Aggiorna con Tema Corrente" per vedere i background con i tuoi colori!
"""
html_parts = [f"""
🎨 Background Knowledge Base (30 Backgrounds)
Esplora tutti i background disponibili con i colori del tuo tema applicati automaticamente!
{theme_indicator}
"""]
# Category order and icons
category_config = {
"gradients": {"icon": "🌈", "name": "Gradients", "desc": "Clean, modern backgrounds with color transitions"},
"waves": {"icon": "🌊", "name": "Waves", "desc": "Dynamic, flowing backgrounds with movement"},
"geometric": {"icon": "◼️", "name": "Geometric", "desc": "Modern patterns with shapes and structure"},
"organic": {"icon": "🎨", "name": "Organic", "desc": "Creative, natural flowing shapes"},
"patterns": {"icon": "📐", "name": "Patterns", "desc": "Structured, repeating design elements"},
"abstract": {"icon": "✨", "name": "Abstract", "desc": "Premium, artistic compositions"}
}
for cat_key in ["gradients", "waves", "geometric", "organic", "patterns", "abstract"]:
if cat_key not in categories:
continue
config = category_config.get(cat_key, {"icon": "•", "name": cat_key.title(), "desc": ""})
items = categories[cat_key]
html_parts.append(f"""
{config['icon']} {config['name']} ({len(items)})
{config['desc']}
""")
for bg_id, info in sorted(items, key=lambda x: x[0]):
complexity_colors = {
"simple": "#28a745",
"medium": "#ffc107",
"complex": "#dc3545"
}
complexity_color = complexity_colors.get(info['complexity'], "#6c757d")
# Render background preview
bg_preview = render_background_html(bg_id, info, primary, secondary, accent)
html_parts.append(f"""
{bg_preview}
{info['name']}
{bg_id}
{info['complexity'].upper()}
""")
html_parts.append("
")
html_parts.append("""
💡 Anteprima Live: Tutti i 30 background sono renderizzati direttamente con i colori del tuo tema!
Ogni preview mostra esattamente come apparirà il background nell'app con il tema selezionato.
📋 Per testare: Usa il selettore sotto per generare il codice Flutter/Dart completo di un background specifico
e copiarlo su DartPad per vederlo in azione!
""")
return "".join(html_parts)
def generate_header_gallery(theme_json: str = ""):
"""
Generate HTML gallery of all 20 realistic headers
Headers are rendered directly with HTML/CSS using theme colors
"""
from agents.flutter_screen_generator import FlutterScreenGenerator
agent = FlutterScreenGenerator()
catalog = agent.HEADER_CATALOG
# Parse theme or use defaults
if theme_json and theme_json.strip():
try:
theme_data = json.loads(theme_json)
palette = theme_data.get("palette", {})
primary = palette.get("primary", "#2196F3")
secondary = palette.get("secondary", "#FF9800")
accent = palette.get("accent", "#4CAF50")
except:
primary = "#2196F3"
secondary = "#FF9800"
accent = "#4CAF50"
else:
primary = "#2196F3"
secondary = "#FF9800"
accent = "#4CAF50"
# Start HTML
html_parts = []
html_parts.append("""
🎯 Header Catalog (20 Headers)
20 header realistici con profilo, localizzazione, notifiche, cart e menu - renderizzati con i tuoi colori del tema
""")
# Grid container
html_parts.append("""
""")
# Render each header
for header_id, info in catalog.items():
# Render header preview
header_preview = render_header_html(header_id, info, primary, secondary, accent)
# Complexity color
complexity = info.get('complexity', 'simple')
if complexity == "simple":
complexity_color = "#28a745"
elif complexity == "medium":
complexity_color = "#ffc107"
else:
complexity_color = "#dc3545"
html_parts.append(f"""
{header_preview}
{info['name']}
{header_id}
{info['description']}
{complexity.upper()}
""")
html_parts.append("
")
return "".join(html_parts)
def generate_footer_gallery(theme_json: str = ""):
"""
Generate HTML gallery of all 30 footer layouts
Footers are rendered directly with HTML/CSS using theme colors
"""
from agents.flutter_screen_generator import FlutterScreenGenerator
agent = FlutterScreenGenerator()
catalog = agent.FOOTER_CATALOG
# Parse theme or use defaults
if theme_json and theme_json.strip():
try:
theme_data = json.loads(theme_json)
palette = theme_data.get("palette", {})
primary = palette.get("primary", "#2196F3")
secondary = palette.get("secondary", "#FF9800")
accent = palette.get("accent", "#4CAF50")
except:
primary = "#2196F3"
secondary = "#FF9800"
accent = "#4CAF50"
else:
primary = "#2196F3"
secondary = "#FF9800"
accent = "#4CAF50"
# Start HTML
html_parts = []
html_parts.append("""
🎯 Footer Catalog (30 Footer Layouts)
30 layout di footer/navigation bar diversi - classic tabs, floating bars, curved designs, pills, minimalist, advanced - renderizzati con i tuoi colori
""")
# Grid container
html_parts.append("""
""")
# Render each footer
for footer_id, info in catalog.items():
# Render footer preview
footer_preview = render_footer_html(footer_id, info, primary, secondary, accent)
# Complexity color
complexity = info.get('complexity', 'simple')
if complexity == "simple":
complexity_color = "#28a745"
elif complexity == "medium":
complexity_color = "#ffc107"
else:
complexity_color = "#dc3545"
html_parts.append(f"""
{footer_preview}
{info['name']}
{footer_id}
{info['description']}
{complexity.upper()}
""")
html_parts.append("
")
return "".join(html_parts)
def generate_card_gallery(theme_json: str = ""):
"""
Generate HTML gallery of all 30 card types
Cards are rendered directly with HTML/CSS using theme colors
"""
from agents.flutter_screen_generator import FlutterScreenGenerator
agent = FlutterScreenGenerator()
catalog = agent.CARD_CATALOG
# Parse theme or use defaults
if theme_json and theme_json.strip():
try:
theme_data = json.loads(theme_json)
palette = theme_data.get("palette", {})
primary = palette.get("primary", "#2196F3")
secondary = palette.get("secondary", "#FF9800")
accent = palette.get("accent", "#4CAF50")
except:
primary = "#2196F3"
secondary = "#FF9800"
accent = "#4CAF50"
else:
primary = "#2196F3"
secondary = "#FF9800"
accent = "#4CAF50"
# Start HTML
html_parts = []
html_parts.append("""
🎴 Card Catalog (130+ Card Types)
130+ tipologie di cards - e-commerce, social, finance, health, education, travel, food, real estate, music, gaming, productivity, dashboard - tutte renderizzate con i tuoi colori
""")
# Grid container
html_parts.append("""
""")
# Render each card
for card_id, info in catalog.items():
# Render card preview
card_preview = render_card_html(card_id, info, primary, secondary, accent)
# Complexity color
complexity = info.get('complexity', 'simple')
if complexity == "simple":
complexity_color = "#28a745"
elif complexity == "medium":
complexity_color = "#ffc107"
else:
complexity_color = "#dc3545"
html_parts.append(f"""
{card_preview}
{info['name']}
{card_id}
{info['description']}
{complexity.upper()}
""")
html_parts.append("
")
return "".join(html_parts)
def generate_single_background_preview(bg_id: str):
"""
Generate preview code for a single background
"""
if not bg_id:
return "", "Seleziona un background dalla galleria sopra
"
# Default theme for preview
theme = {
"palette": {
"primary": "#007AFF",
"secondary": "#5856D6",
"accent": "#FF9500",
"background": "#FFFFFF"
}
}
# Generate background-only code
try:
code = flutter_screen_generator._generate_background_only(theme, "generic", bg_id)
# Get background info
bg_info = flutter_screen_generator.BACKGROUND_CATALOG.get(bg_id, {})
bg_name = bg_info.get("name", bg_id)
bg_category = bg_info.get("category", "unknown")
bg_complexity = bg_info.get("complexity", "unknown")
# Create DartPad link
import urllib.parse
encoded_code = urllib.parse.quote(code)
dartpad_link = f"https://dartpad.dev/?id={encoded_code[:100]}" # Simplified
preview_html = f"""
🎨 {bg_name}
📁 {bg_category}
⚡ {bg_complexity}
ID: {bg_id}
📋 Come testare:
1. Copia il codice Dart qui sotto
2. Vai su DartPad.dev
3. Incolla e clicca "Run"
4. Vedi il background in azione! 🚀
✅ Codice generato: {len(code)} caratteri
"""
return code, preview_html
except Exception as e:
error_html = f"""
⚠️ Errore durante la generazione: {str(e)}
"""
return "", error_html
# Gradio interface
with gr.Blocks(
title="Space AC: Design Variations",
theme=gr.themes.Soft(
primary_hue="blue",
secondary_hue="purple"
)
) as demo:
gr.Markdown("""
# 🎨 Space AC: Design Variations
**AI-powered design system generation agents**
Analyze app design references and extract actionable design insights.
""")
# State components to store data between tabs
ac1_state = gr.State(value=None) # Stores AC1 output JSON
ac2_state = gr.State(value=None) # Stores AC2 output JSON (all 4 themes)
with gr.Tabs():
# Tab 0: Simple Flutter Generator (NEW!)
with gr.Tab("⚡ Simple Generator"):
gr.Markdown("""
# ⚡ Simple Flutter Generator
**Prompt → DeepSeek → Flutter Code → DartPad Automatico** 🚀
Niente preset, niente theme, niente complicazioni.
Scrivi cosa vuoi, l'AI genera il codice Flutter e lo carica automaticamente in DartPad.
✨ **Novità:** Il codice viene automaticamente caricato nel DartPad embedded - clicca "Run" e basta!
""")
with gr.Row():
with gr.Column(scale=1):
simple_prompt = gr.Textbox(
label="📝 Cosa vuoi generare?",
placeholder="Esempio:\n- Crea una schermata di login con email e password\n- Genera una home page per app fitness con statistiche\n- Fai una todo list app con checkbox e delete button",
lines=5,
value="Crea una schermata di login moderna con email, password e bottone login"
)
generate_simple_btn = gr.Button(
"🚀 Genera Codice Flutter",
variant="primary",
size="lg"
)
# Results
gr.Markdown("### 📱 Risultato")
simple_summary = gr.HTML(
value="Clicca 'Genera Codice Flutter' per iniziare...
"
)
# DartPad Embedded - PRIMO, ben visibile
simple_dartpad = gr.HTML(
value="Il DartPad embedded apparirà qui...
"
)
# Code Output - NASCOSTO in Accordion collassabile
with gr.Accordion("💻 Codice Sorgente (clicca per espandere)", open=False):
simple_code_output = gr.Code(
label="Codice Dart generato",
language="javascript",
lines=25,
value=""
)
# Examples
gr.Examples(
examples=[
["Crea una schermata di login con email, password e social login buttons"],
["Genera una home page per app fitness con cards di statistiche giornaliere"],
["Fai una todo list con checkbox, testo e bottone delete per ogni item"],
["Crea un profilo utente con avatar, nome, bio e bottoni follow/message"],
["Genera una schermata settings con switch, slider e dropdown"],
],
inputs=[simple_prompt],
label="Prova questi esempi"
)
# Connect button
generate_simple_btn.click(
fn=generate_simple_flutter,
inputs=[simple_prompt],
outputs=[simple_code_output, simple_summary, simple_dartpad]
)
# Tab 1: Moodboard Analyzer
with gr.Tab("🖼️ AC1: Moodboard Analyzer"):
gr.Markdown("""
### Analyze Reference Images
Provide descriptions of reference app screenshots or design inspirations.
The agent will extract color palettes, typography trends, and UI patterns.
""")
with gr.Row():
with gr.Column(scale=1):
image_descriptions = gr.Textbox(
label="Reference Image Descriptions",
placeholder="""Enter one description per line, for example:
Instagram home feed - dark mode, clean cards, bottom navigation
Uber driver app - dark theme, green accents, map view
Spotify player - dark background, vibrant album art, minimalist controls""",
lines=10
)
mood_keywords = gr.Textbox(
label="Mood Keywords (comma-separated)",
placeholder="energetic, gaming, modern, professional, playful",
value="modern, energetic"
)
analyze_btn = gr.Button(
"🔍 Analyze Moodboard",
variant="primary",
size="lg"
)
# Visual Results Tabs
gr.Markdown("### 📊 Analysis Results")
with gr.Tabs():
with gr.Tab("🎨 Color Palettes"):
color_palettes_html = gr.HTML(
label="Color Palettes",
value="Click 'Analyze Moodboard' to see color palettes here...
"
)
with gr.Tab("✍️ Typography"):
typography_html = gr.HTML(
label="Typography Trends",
value="Typography trends will appear here...
"
)
with gr.Tab("🧩 UI Patterns"):
ui_patterns_html = gr.HTML(
label="UI Patterns",
value="UI patterns will be displayed here...
"
)
with gr.Tab("📐 Layout & Insights"):
layout_markdown = gr.Markdown(
value="Layout styles will appear here..."
)
insights_markdown = gr.Markdown(
value="Design insights will be generated here..."
)
with gr.Tab("📄 JSON Data"):
json_output = gr.Code(
label="Complete Analysis JSON",
language="json",
lines=20,
value="{}"
)
# Quick Action Button
use_in_ac2_btn = gr.Button(
"→ Use in AC2",
variant="secondary",
size="lg"
)
# Examples
gr.Markdown("### 📝 Example Inputs")
gr.Examples(
examples=[
[
"""Instagram home feed - dark mode with white text, clean cards with photos
Spotify player - dark background, vibrant green accents, minimalist controls
Uber driver app - dark theme with green accents, map interface, bold stats""",
"gaming, energetic, modern"
],
[
"""Banking app - white background, blue accents, professional typography
LinkedIn feed - white cards, blue buttons, clean layout
Notion - minimal design, subtle shadows, organized content""",
"professional, modern, clean"
],
[
"""Duolingo - playful colors, cartoon graphics, gamified interface
TikTok - dark mode, vibrant content, engaging animations
Snapchat - bright colors, fun filters, youthful design""",
"playful, fun, youthful"
]
],
inputs=[image_descriptions, mood_keywords],
label="Try these examples"
)
# Connect button
analyze_btn.click(
fn=analyze_moodboard,
inputs=[image_descriptions, mood_keywords],
outputs=[
color_palettes_html,
typography_html,
ui_patterns_html,
layout_markdown,
insights_markdown,
json_output,
ac1_state # Store AC1 output in state
]
)
# Note: use_in_ac2_btn click handler is defined after AC2 components are created
# Tab 2: Design Variation Generator
with gr.Tab("🎨 AC2: Design Variation Generator"):
gr.Markdown("""
### Generate Design Theme Variations
Take your moodboard analysis from AC1 and generate 4 complete design theme variations.
Each theme will include colors, typography, spacing, and component styles.
""")
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("""
**Step 1:** First, run AC1 to analyze your moodboard
**Step 2:** Copy the JSON output from AC1
**Step 3:** Paste it below and add wireframe description
**Step 4:** Generate 4 design themes
""")
ac1_json_input = gr.Code(
label="Moodboard Analysis JSON (from AC1)",
language="json",
lines=10,
value='{\n "analysis": {\n "color_palettes": [],\n "typography_trends": [],\n "ui_patterns": []\n }\n}'
)
# Connect use_in_ac2 button from AC1
use_in_ac2_btn.click(
fn=lambda ac1_data: json.dumps(ac1_data, indent=2) if ac1_data else "{}",
inputs=[ac1_state],
outputs=[ac1_json_input]
)
wireframe_input = gr.Textbox(
label="Wireframe Description",
placeholder="Describe your app wireframe: e.g., 'E-commerce app with product grid, shopping cart, and checkout flow'",
lines=5,
value="Mobile app with home screen, navigation bar, and content cards"
)
generate_themes_btn = gr.Button(
"✨ Generate 4 Design Themes",
variant="primary",
size="lg"
)
# Results Section
gr.Markdown("### 🎯 Generated Design Themes")
with gr.Tabs():
with gr.Tab("🎨 Visual Themes"):
themes_grid_html = gr.HTML(
label="Design Themes",
value="Click 'Generate 4 Design Themes' to see themes here...
"
)
with gr.Tab("📄 JSON Data"):
themes_json_output = gr.Code(
label="Complete Themes JSON",
language="json",
lines=20,
value="{}"
)
# Examples
gr.Markdown("### 📝 Workflow Example")
gr.Markdown("""
**Complete Workflow:**
1. Go to AC1 tab → Analyze moodboard → Copy JSON from "JSON Data" tab
2. Come back to AC2 tab → Paste JSON in the input above
3. Describe your wireframe
4. Click "Generate 4 Design Themes"
5. View 4 different design variations with complete design systems
Each theme will include:
- **Color Palette** - Primary, secondary, accent, neutral colors
- **Typography** - Font families for display and body text
- **Spacing System** - Consistent spacing scale
- **Component Styles** - Button styles, card styles, etc.
- **Animations** - Animation style and timing
""")
# Quick Action Buttons for each theme
with gr.Row():
use_theme1_btn = gr.Button("→ Use Theme 1 in AC3", variant="secondary", size="sm")
use_theme2_btn = gr.Button("→ Use Theme 2 in AC3", variant="secondary", size="sm")
use_theme3_btn = gr.Button("→ Use Theme 3 in AC3", variant="secondary", size="sm")
use_theme4_btn = gr.Button("→ Use Theme 4 in AC3", variant="secondary", size="sm")
# Connect button
generate_themes_btn.click(
fn=generate_design_themes,
inputs=[ac1_json_input, wireframe_input],
outputs=[themes_grid_html, themes_json_output, ac2_state]
)
# Note: use_theme buttons click handlers are defined after AC3 components are created
# Tab 3: Flutter Screen Generator
with gr.Tab("💻 AC3: Flutter Screen Generator"):
gr.Markdown("""
### Generate Flutter/Dart Screen Code
Take one of your design themes from AC2 and generate complete Flutter screens
ready to run on **DartPad**! 🎨
""")
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("""
**Step 1:** Run AC2 to generate design themes
**Step 2:** Copy theme JSON from AC2
**Step 3:** Select app type
**Step 4:** Generate Flutter code
**Step 5:** Copy code to [DartPad](https://dartpad.dev)
""")
theme_json_input = gr.Code(
label="Theme JSON (from AC2)",
language="json",
lines=8,
value='{\n "name": "Bold Energy",\n "palette": {"primary": "#FF6B35"},\n "typography": {}\n}'
)
# Connect use_theme buttons from AC2
use_theme1_btn.click(
fn=lambda ac2_data: json.dumps(ac2_data["themes"][0], indent=2) if ac2_data and "themes" in ac2_data and len(ac2_data["themes"]) > 0 else "{}",
inputs=[ac2_state],
outputs=[theme_json_input]
)
use_theme2_btn.click(
fn=lambda ac2_data: json.dumps(ac2_data["themes"][1], indent=2) if ac2_data and "themes" in ac2_data and len(ac2_data["themes"]) > 1 else "{}",
inputs=[ac2_state],
outputs=[theme_json_input]
)
use_theme3_btn.click(
fn=lambda ac2_data: json.dumps(ac2_data["themes"][2], indent=2) if ac2_data and "themes" in ac2_data and len(ac2_data["themes"]) > 2 else "{}",
inputs=[ac2_state],
outputs=[theme_json_input]
)
use_theme4_btn.click(
fn=lambda ac2_data: json.dumps(ac2_data["themes"][3], indent=2) if ac2_data and "themes" in ac2_data and len(ac2_data["themes"]) > 3 else "{}",
inputs=[ac2_state],
outputs=[theme_json_input]
)
app_type_dropdown = gr.Dropdown(
label="App Type",
choices=["fitness", "banking", "rider", "ecommerce", "social", "food", "travel", "health", "education", "generic"],
value="fitness"
)
custom_prompt = gr.Textbox(
label="📝 Prompt Personalizzato (cosa vuoi generare)",
placeholder="Esempio: Genera una home page per app fitness con statistiche, Crea una schermata login moderna, etc.",
lines=3,
value="Genera una home page per l'app con cards, header e footer"
)
screens_input = gr.Textbox(
label="Screens (comma-separated, max 3)",
placeholder="home, detail, profile",
lines=1,
value="home, detail, profile"
)
generate_flutter_btn = gr.Button(
"🚀 Generate Flutter Screens",
variant="primary",
size="lg"
)
# Results Section
gr.Markdown("### 📱 Generated Flutter Screens")
summary_output = gr.HTML(
value="Click 'Generate Flutter Screens' to create code...
"
)
with gr.Tabs():
with gr.Tab("✨ Variant 1"):
preview_waves = gr.HTML(value="Generate to see AI-powered variant...
")
with gr.Accordion("💻 View Dart Code", open=False):
code_waves = gr.Code(label="Dart Code - Variant 1", language="javascript", lines=15, value="")
with gr.Tab("✨ Variant 2"):
preview_linear = gr.HTML(value="Generate to see AI-powered variant...
")
with gr.Accordion("💻 View Dart Code", open=False):
code_linear = gr.Code(label="Dart Code - Variant 2", language="javascript", lines=15, value="")
with gr.Tab("✨ Variant 3"):
preview_radial = gr.HTML(value="Generate to see AI-powered variant...
")
with gr.Accordion("💻 View Dart Code", open=False):
code_radial = gr.Code(label="Dart Code - Variant 3", language="javascript", lines=15, value="")
with gr.Tab("✨ Variant 4"):
preview_geometric = gr.HTML(value="Generate to see AI-powered variant...
")
with gr.Accordion("💻 View Dart Code", open=False):
code_geometric = gr.Code(label="Dart Code - Variant 4", language="javascript", lines=15, value="")
# Info Section
gr.Markdown("### 💡 How to Use")
gr.Markdown("""
**AI-Powered Variants:**
- 🤖 **Llama 3.1 70B** analyzes your theme + app type
- ✨ Generates **4 unique variants** combining:
- **Background** (waves/gradient_linear/gradient_radial/geometric)
- **Header** (minimal/avatar_search/tabs/collapsible/stats_header)
- **Footer** (minimal_icons/floating_fab/animated_pills/classic_expanded/gesture_bar)
- 🎨 Each variant is contextually appropriate for your design
**Generated Code:**
- ✅ Complete, runnable Dart/Flutter code
- ✅ Styled with your theme colors and typography
- ✅ App-specific headers and footers
- ✅ Mock data included
- ✅ Ready for DartPad (~500-700 lines each)
**To test:**
1. Click on a variant tab above
2. Copy the Dart code
3. Go to [dartpad.dev](https://dartpad.dev)
4. Paste and click "Run"
5. See your AI-generated screen! 🎉
**Supported App Types:**
- **Fitness:** Stats headers, progress tracking, workout cards
- **Banking:** Account balance, transaction lists, transfer buttons
- **Rider:** Delivery stats, earnings, map previews
- **E-commerce:** Product grids, cart, checkout flows
- **Social:** Feed layouts, profile headers, post cards
- **And more!**
""")
# Background Gallery Section
gr.Markdown("---")
with gr.Accordion("🎨 Background Gallery (30 Backgrounds)", open=False):
gr.Markdown("""
Esplora tutti i 30 background disponibili organizzati per categoria.
Usa questa gallery per analizzare visualmente la knowledge base e testare ogni background.
""")
# Refresh button to update with new theme
refresh_backgrounds_btn = gr.Button("🔄 Aggiorna con Tema Corrente", variant="secondary", size="sm")
# Gallery HTML (reactive to theme changes) - show immediately with default theme
default_theme_for_gallery = json.dumps({
"name": "Default Theme",
"palette": {"primary": "#2196F3", "secondary": "#FF9800", "accent": "#4CAF50"}
})
gallery_html = gr.HTML(
value=generate_background_gallery(default_theme_for_gallery)
)
# Connect refresh button
refresh_backgrounds_btn.click(
fn=generate_background_gallery,
inputs=[theme_json_input],
outputs=[gallery_html]
)
# Header Gallery Section
gr.Markdown("---")
with gr.Accordion("🎯 Header Catalog (20 Headers)", open=False):
gr.Markdown("""
Tutti i 20 header realistici disponibili con preview renderizzate in HTML/CSS.
Gli header includono profilo, localizzazione, notifiche, menu e altri elementi.
""")
# Refresh button to update with new theme
refresh_headers_btn = gr.Button("🔄 Aggiorna Header con Tema Corrente", variant="secondary", size="sm")
# Header Gallery HTML - show immediately with default theme
header_gallery_html = gr.HTML(
value=generate_header_gallery(default_theme_for_gallery)
)
# Connect refresh button
refresh_headers_btn.click(
fn=generate_header_gallery,
inputs=[theme_json_input],
outputs=[header_gallery_html]
)
# Footer Gallery Section
gr.Markdown("---")
with gr.Accordion("🎯 Footer Catalog (30 Footer Layouts)", open=False):
gr.Markdown("""
Tutti i 30 footer/navigation bar con layout diversi renderizzati in HTML/CSS.
Classic tabs, floating bars, curved designs, pills, minimalist, advanced interactive.
""")
# Refresh button to update with new theme
refresh_footers_btn = gr.Button("🔄 Aggiorna Footer con Tema Corrente", variant="secondary", size="sm")
# Footer Gallery HTML - show immediately with default theme
footer_gallery_html = gr.HTML(
value=generate_footer_gallery(default_theme_for_gallery)
)
# Connect refresh button
refresh_footers_btn.click(
fn=generate_footer_gallery,
inputs=[theme_json_input],
outputs=[footer_gallery_html]
)
# Card Gallery Section
gr.Markdown("---")
with gr.Accordion("🎴 Card Catalog (130+ Card Types)", open=False):
gr.Markdown("""
Tutte le 130+ tipologie di cards renderizzate in HTML/CSS.
E-commerce, Social, Finance, Health, Education, Travel, Food, Real Estate, Music, Gaming, Productivity, Dashboard - tutte con i tuoi colori del tema.
""")
# Refresh button to update with new theme
refresh_cards_btn = gr.Button("🔄 Aggiorna Cards con Tema Corrente", variant="secondary", size="sm")
# Card Gallery HTML - show immediately with default theme
card_gallery_html = gr.HTML(
value=generate_card_gallery(default_theme_for_gallery)
)
# Connect refresh button
refresh_cards_btn.click(
fn=generate_card_gallery,
inputs=[theme_json_input],
outputs=[card_gallery_html]
)
# Connect button
generate_flutter_btn.click(
fn=generate_flutter_screens,
inputs=[theme_json_input, app_type_dropdown, custom_prompt, screens_input],
outputs=[
summary_output,
preview_waves, code_waves,
preview_linear, code_linear,
preview_radial, code_radial,
preview_geometric, code_geometric
]
)
# Tab 4: API Documentation
with gr.Tab("📡 API Documentation"):
gr.Markdown("""
## REST API Endpoints
### POST /api/moodboard-analyzer
Analyze a moodboard to extract design insights.
**Request Body:**
```json
{
"reference_images": [
{
"url": "https://example.com/screenshot.png",
"description": "Instagram home feed - dark mode"
}
],
"mood_keywords": ["energetic", "gaming", "modern"]
}
```
**Response:**
```json
{
"success": true,
"agent": "moodboard_analyzer",
"output": {
"analysis": {
"color_palettes": [...],
"typography_trends": [...],
"ui_patterns": [...],
"layout_styles": [...],
"insights": "..."
}
}
}
```
### Example using curl:
```bash
curl -X POST https://oneweekapp-space-ac-design.hf.space/api/moodboard-analyzer \\
-H "Content-Type: application/json" \\
-d '{
"reference_images": [
{"description": "Instagram dark mode", "url": ""}
],
"mood_keywords": ["energetic", "gaming"]
}'
```
### Example using Python:
```python
import requests
response = requests.post(
"https://oneweekapp-space-ac-design.hf.space/api/moodboard-analyzer",
json={
"reference_images": [
{"description": "Instagram dark mode", "url": ""}
],
"mood_keywords": ["energetic", "gaming"]
}
)
result = response.json()
print(result["output"]["analysis"])
```
---
### POST /api/design-variation-generator
Generate 4 design theme variations from moodboard analysis.
**Request Body:**
```json
{
"moodboard_analysis": {
"color_palettes": [...],
"typography_trends": [...],
"ui_patterns": [...]
},
"wireframe": "E-commerce app with product grid and checkout",
"app_context": {
"type": "mobile_app"
}
}
```
**Response:**
```json
{
"success": true,
"agent": "design_variation_generator",
"output": {
"themes": [
{
"name": "Bold Energy",
"style": "bold",
"mood": "Energetic and gaming-focused",
"palette": {...},
"typography": {...},
"spacing": {...},
"component_style": {...},
"animations": {...}
}
]
}
}
```
### Example using curl:
```bash
curl -X POST https://oneweekapp-space-ac-design.hf.space/api/design-variation-generator \\\\
-H "Content-Type: application/json" \\\\
-d '{
"moodboard_analysis": {...},
"wireframe": "Social media app",
"app_context": {"type": "mobile_app"}
}'
```
---
### POST /api/flutter-screen-generator
Generate Flutter/Dart code from design themes using AI planning (Llama 3.1 70B).
**Request Body:**
```json
{
"theme": {
"name": "Bold Energy",
"palette": {...},
"typography": {...},
"spacing": {...}
},
"app_type": "fitness",
"screens": ["home", "profile", "settings"]
}
```
**Response:**
```json
{
"success": true,
"agent": "flutter_screen_generator",
"output": {
"screens": [
{
"name": "home",
"code": "import 'package:flutter/material.dart';\\n\\n// Full Dart code...",
"lines": 487,
"components": ["StatsCard", "HeroBanner"],
"status": "generated"
}
],
"theme_name": "Bold Energy",
"app_type": "fitness",
"total_lines": 1420
}
}
```
**Available app types:** fitness, banking, rider, ecommerce, social, etc.
**Available screens:** home, profile, settings, detail, feed, search, cart, chat, onboarding, login
**Note:** Requires `HF_TOKEN` environment variable for Llama 3.1 access. Returns fallback code if not configured.
## Health Check
### GET /health
Check if the space is healthy.
**Response:**
```json
{
"status": "healthy",
"space": "ac-design",
"agents": ["moodboard_analyzer"]
}
```
""")
# Tab 3: About
with gr.Tab("ℹ️ About"):
gr.Markdown("""
## About Space AC
**Space AC: Design Variations** is part of the AI Software Factory system.
### Agents in this Space:
1. **AC1: Moodboard Analyzer** 🖼️ ✅ LIVE
- Analyzes reference images and screenshots
- Extracts color palettes with visual previews
- Identifies UI patterns and typography trends
- Generates design insights
2. **AC2: Design Variation Generator** 🎨 ✅ LIVE
- Generates 4 complete design themes
- Defines design tokens (colors, typography, spacing)
- Creates complete design system specifications
- Visual theme cards with preview
3. **AC3: Flutter Screen Generator** 💻 ✅ LIVE
- Generates runnable Flutter/Dart code for DartPad
- AI-powered planning with Llama 3.1 70B + Jinja2 templates
- Creates 3 screens per theme with realistic components
- Supports 10 app types (fitness, banking, rider, ecommerce, etc.)
- 400-500 lines of production-ready Dart code per screen
4. **AC4: Theme Comparator** 🎯 (Coming soon)
- Compares design themes
- Generates pros/cons analysis
- Recommends best theme
### Technology Stack:
- **UI Framework:** Gradio 5.49+
- **API:** FastAPI 0.115+
- **AI Models:**
- Llama 3.2 Vision (11B) for image analysis (AC1)
- Llama 3.1 (70B) for text generation and synthesis (AC2)
- Llama 3.1 (70B) for Flutter code planning (AC3)
- Jinja2 Templates for Dart code generation (AC3)
### Part of AI Software Factory
This space is part of a larger system that generates complete Flutter applications
from Notion wireframes to GitHub PRs in 50-70 minutes.
**Learn more:** [GitHub Repository](https://github.com/sabatino81/AISoftwareFactory)
---
**🔗 Quick Links:**
- Live App: https://oneweekapp-space-ac-design.hf.space
- Space Page: https://huggingface.co/spaces/OneWeekApp/space-ac-design
- GitHub: https://github.com/sabatino81/AISoftwareFactory
""")
# Mount Gradio on FastAPI
app = gr.mount_gradio_app(app, demo, path="/")
if __name__ == "__main__":
demo.launch(ssr_mode=False) # Disable SSR for HuggingFace Spaces compatibility