File size: 6,612 Bytes
c32653f
80f4262
 
 
 
c32653f
80f4262
c32653f
80f4262
 
ea5f34c
80f4262
 
 
 
 
 
 
 
 
c32653f
 
80f4262
 
 
 
ab5fac7
 
 
 
 
 
 
 
 
 
80f4262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab5fac7
 
80f4262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---
title: 🎨 Gradio Themer - Demo & MCP Server
emoji: 🎨
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.31.0
app_file: app.py
pinned: true
license: mit
short_description: User-configurable themes for Gradio + MCP server
models:
  - MasterControlAIML/DeepSeek-R1-Qwen2.5-1.5b-SFT-R1-JSON-Unstructured-To-Structured
tags:
  - mcp-server-track
  - custom-component-track
  - Agents-MCP-Hackathon
  - gradio
  - theming
  - agent-ui
---

# 🎨 Gradio Themer - Demo & MCP Server

**πŸ† Dual Track Hackathon Submission**: Custom Component + MCP Server

## πŸ“Ί Demo Videos

### 🎬 **Complete Demo Video**: [Watch on YouTube](https://youtu.be/qQ0gQQIFiBQ)

This video demonstrates:

- **Track 1 (MCP Server)**: MCP server integration with AI agents for automated theme generation
- **Track 2 (Custom Component)**: Interactive Gradio component usage and theming workflow
- **Complete workflow**: From CSS conversion to theme application using both tracks

## πŸš€ Features

- **Dynamic Theme System**: User-configurable themes via JSON
- **AI-Powered Conversion**: Convert CSS/descriptions to theme JSON using HuggingFace models
- **MCP Server Integration**: 4 practical tools for theme development
- **Production Ready**: Built and tested package

## πŸ€– MCP Tools (Production-Focused)

### 1. `generate_theme`

**Purpose**: Create complete theme JSON with intelligent color harmonies
**Parameters**:

- `theme_name`: Name of the theme
- `primary_color`: Main color (hex format, default: "#3b82f6")
- `theme_style`: "light" or "dark" (default: "light")
- `color_harmony`: "complementary", "triadic", "analogous", "monochromatic" (default: "complementary")

**Output**: Complete theme JSON with harmonious colors and accessibility considerations

### 2. `convert_css_to_theme`

**Purpose**: Convert existing CSS or natural language descriptions to theme JSON
**Parameters**:

- `css_input`: CSS code or style description
- `theme_name`: Name for the converted theme (default: "converted_theme")

**Output**: Theme JSON extracted from CSS using AI and pattern matching

### 3. `apply_theme_preview`

**Purpose**: Generate CSS code for immediate theme preview in any Gradio app
**Parameters**:

- `theme_json`: Theme JSON configuration

**Output**: Ready-to-use CSS code for instant theme application

### 4. `export_theme_package`

**Purpose**: Export complete theme package with JSON, CSS, and usage instructions
**Parameters**:

- `theme_json`: Theme JSON configuration
- `package_name`: Name for the package files (default: "my_theme")

**Output**: Complete package with files, documentation, and sample code

## 🎯 Why These Tools?

**❌ Removed**: Package management tools (not useful for theme development)
**βœ… Added**: Practical workflow tools that developers actually need:

1. **Smart Theme Generation**: Uses color theory for harmonious palettes
2. **CSS Migration**: Convert existing designs to Gradio themes
3. **Instant Preview**: Get CSS for immediate testing
4. **Complete Export**: Ready-to-use packages with documentation

## πŸ”§ Usage Examples

### Generate Theme with Color Harmony

```python
# Create complementary color scheme from blue primary
generate_theme("Ocean Theme", "#0ea5e9", "light", "complementary")
```

### Convert Existing CSS

```python
# Convert CSS variables to theme JSON
convert_css_to_theme("""
:root {
  --primary: #3b82f6;
  --background: #ffffff;
  --text: #1e293b;
}
""", "Converted Blue Theme")
```

### Get Preview CSS

```python
# Generate CSS for immediate application
apply_theme_preview('{"ocean_theme": {"colors": {...}}}')
```

### Export Complete Package

```python
# Create ready-to-use theme package
export_theme_package('{"my_theme": {...}}', "awesome_theme")
```

## πŸ† Production Benefits

1. **Workflow Efficiency**: Tools cover the complete theme development cycle
2. **Color Theory**: Automatic generation of harmonious color schemes
3. **Accessibility**: Built-in contrast considerations
4. **Migration Support**: Easy conversion from existing CSS
5. **Instant Testing**: Preview CSS for immediate application
6. **Complete Packages**: Everything needed for distribution

## πŸ›  Setup & Installation

### For HuggingFace Spaces:

This Space is ready to deploy! Just upload all files to your HF Space.

### For Local Development:

```bash
pip install gradio>=5.31.0 gradio-themer>=0.1.0 requests transformers torch
python app.py
```

### For MCP Client Integration:

Configure your MCP client (Claude Desktop, Cursor, etc.) to connect to this Space:

```json
{
  "mcpServers": {
    "gradio-themer": {
      "command": "python",
      "args": ["-m", "gradio_mcp"],
      "env": {
        "GRADIO_MCP_URL": "https://your-space-url.hf.space"
      }
    }
  }
}
```

## πŸ“‹ Hackathon Submission

**Track 1 (MCP Server)**:

- Tag: `mcp-server-track`
- 4 production-focused MCP tools
- Complete theme development workflow

**Track 2 (Custom Component)**:

- Tag: `custom-component-track`
- Published package: `gradio_themer`
- Interactive Gradio component

## 🎨 Demo Features

- **Random Theme Button**: Apply any of 13+ available themes
- **CSS to JSON Converter**: AI-powered conversion using HuggingFace models
- **Theme Showcase**: Live preview of different theme styles
- **MCP Integration**: Embedded MCP server functionality

## πŸ“¦ Package Information

- **Package**: `gradio_themer-0.1.0`
- **Class**: `GradioThemer`
- **Import**: `from gradio_themer import GradioThemer`
- **Status**: Production ready

## πŸ”— Links

- **🎨 This Demo Space**: `https://huggingface.co/spaces/eldarski/gradio-themer-demo`
- **πŸ“¦ PyPI Package**: `https://pypi.org/project/gradio-themer/`
- **πŸ“š GitHub Repository**: `[Repository URL]`
- **🎬 MCP Demo Video**: [https://youtu.be/qQ0gQQIFiBQ](https://youtu.be/qQ0gQQIFiBQ)
- **🎬 Component Demo Video**: [https://youtu.be/qQ0gQQIFiBQ](https://youtu.be/qQ0gQQIFiBQ)

---

**Built for HuggingFace Gradio Hackathon 2024**

## πŸ“Ί Demo Videos

### πŸ€– Track 1: MCP Server Demo (`mcp-server-track`)

**MCP Server in Action with Cursor AI**: [Video Demo Link - Coming Soon]

- Shows the MCP server being used with Cursor AI for automated theme generation
- Demonstrates all 4 MCP tools in a real development workflow
- Live theme creation and application via AI agent

### 🎨 Track 2: Custom Component Demo (`custom-component-track`)

**Component Usage Demo**: [Video Demo Link - Coming Soon]

- Interactive demonstration of the GradioThemer custom component
- Shows theme switching and configuration in various Gradio applications
- Demonstrates the published package in action