File size: 1,578 Bytes
2025640
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import gradio as gr

# Color options with their hex codes
COLORS = {
    "red": "#FF0000",
    "yellow": "#FFD700",
    "green": "#00FF00",
    "blue": "#0000FF",
    "indigo": "#4B0082",
    "purple": "#800080",
    "pink": "#FFC0CB",
    "gray": "#808080"
}

def create_gradient(color_from, color_to):
    # Create HTML with gradient background
    html = f"""
    <div style="
        width: 200px;
        height: 200px;
        background: linear-gradient(45deg, {COLORS[color_from]}, {COLORS[color_to]});
        border-radius: 8px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    "></div>
    """
    return html

# Create the Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("# Gradient Color Preview")
    gr.Markdown("Select colors to preview how they would look in your space's thumbnail.")
    
    with gr.Row():
        color_from = gr.Dropdown(
            choices=list(COLORS.keys()),
            value="blue",
            label="Color From"
        )
        color_to = gr.Dropdown(
            choices=list(COLORS.keys()),
            value="purple",
            label="Color To"
        )
    
    preview = gr.HTML(label="Preview")
    
    # Update preview when colors change
    color_from.change(
        fn=create_gradient,
        inputs=[color_from, color_to],
        outputs=preview
    )
    color_to.change(
        fn=create_gradient,
        inputs=[color_from, color_to],
        outputs=preview
    )
    
    # Initial preview
    preview.value = create_gradient("blue", "purple")

if __name__ == "__main__":
    demo.launch()