Spaces:
Running
Running
Commit
·
d33b91e
1
Parent(s):
51ea706
update
Browse files
app.py
CHANGED
|
@@ -244,7 +244,163 @@ def process_and_generate(image_input, image_path_from_state, sidebar_prompt, hea
|
|
| 244 |
return layout_preview, final_preview, final_code, layout_code, final_code, gr.update(value=package_url, visible=True)
|
| 245 |
|
| 246 |
|
| 247 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
gr.Markdown("# ScreenCoder: Screenshot to Code")
|
| 249 |
with gr.Row():
|
| 250 |
with gr.Column(scale=1):
|
|
@@ -263,28 +419,26 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 263 |
|
| 264 |
with gr.Column(scale=2):
|
| 265 |
gr.Markdown("## Preview Area")
|
| 266 |
-
gr.Markdown("**Tips**: \n- Use the sliders below to adjust the preview size and zoom level for better viewing experience. \n- Adjust the page's viewing angle by swiping up, down, left, or right. \n- Click the
|
| 267 |
-
with gr.
|
| 268 |
-
with gr.
|
| 269 |
-
with gr.
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
with gr.Column(scale=1):
|
| 287 |
-
download_button = gr.Button("Download Package", visible=False, variant="secondary", size="sm")
|
| 288 |
|
| 289 |
gr.Examples(
|
| 290 |
examples=example_rows,
|
|
|
|
| 244 |
return layout_preview, final_preview, final_code, layout_code, final_code, gr.update(value=package_url, visible=True)
|
| 245 |
|
| 246 |
|
| 247 |
+
with gr.Blocks(css="""
|
| 248 |
+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');
|
| 249 |
+
|
| 250 |
+
* {
|
| 251 |
+
font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif !important;
|
| 252 |
+
font-feature-settings: 'liga' 1, 'calt' 1 !important;
|
| 253 |
+
text-rendering: optimizeLegibility !important;
|
| 254 |
+
-webkit-font-smoothing: antialiased !important;
|
| 255 |
+
-moz-osx-font-smoothing: grayscale !important;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
h1, h2, h3, h4, h5, h6 {
|
| 259 |
+
font-weight: 600 !important;
|
| 260 |
+
color: #1f2937 !important;
|
| 261 |
+
letter-spacing: -0.02em !important;
|
| 262 |
+
line-height: 1.2 !important;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
h1 {
|
| 266 |
+
font-size: 2.5rem !important;
|
| 267 |
+
font-weight: 700 !important;
|
| 268 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 269 |
+
-webkit-background-clip: text;
|
| 270 |
+
-webkit-text-fill-color: transparent;
|
| 271 |
+
background-clip: text;
|
| 272 |
+
margin-bottom: 1.5rem !important;
|
| 273 |
+
letter-spacing: -0.03em !important;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
h2 {
|
| 277 |
+
font-size: 1.75rem !important;
|
| 278 |
+
font-weight: 600 !important;
|
| 279 |
+
color: #374151 !important;
|
| 280 |
+
margin-bottom: 1rem !important;
|
| 281 |
+
letter-spacing: -0.01em !important;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
.gr-button {
|
| 285 |
+
font-weight: 500 !important;
|
| 286 |
+
font-family: 'Poppins', sans-serif !important;
|
| 287 |
+
border-radius: 10px !important;
|
| 288 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 289 |
+
letter-spacing: 0.01em !important;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
.gr-button:hover {
|
| 293 |
+
transform: translateY(-2px) !important;
|
| 294 |
+
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.gr-textbox, .gr-slider {
|
| 298 |
+
border-radius: 10px !important;
|
| 299 |
+
font-family: 'Poppins', sans-serif !important;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
.gr-textbox input, .gr-textbox textarea {
|
| 303 |
+
font-family: 'Poppins', sans-serif !important;
|
| 304 |
+
font-size: 14px !important;
|
| 305 |
+
font-weight: 400 !important;
|
| 306 |
+
letter-spacing: 0.01em !important;
|
| 307 |
+
line-height: 1.5 !important;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.gr-slider {
|
| 311 |
+
font-family: 'Poppins', sans-serif !important;
|
| 312 |
+
font-weight: 500 !important;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
.gr-tabs {
|
| 316 |
+
border-radius: 12px !important;
|
| 317 |
+
overflow: hidden !important;
|
| 318 |
+
font-family: 'Poppins', sans-serif !important;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
.gr-tab-nav {
|
| 322 |
+
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%) !important;
|
| 323 |
+
font-family: 'Poppins', sans-serif !important;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
.gr-tab-nav button {
|
| 327 |
+
font-weight: 500 !important;
|
| 328 |
+
font-family: 'Poppins', sans-serif !important;
|
| 329 |
+
color: #64748b !important;
|
| 330 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 331 |
+
letter-spacing: 0.01em !important;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
.gr-tab-nav button.selected {
|
| 335 |
+
color: #3b82f6 !important;
|
| 336 |
+
background: white !important;
|
| 337 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
|
| 338 |
+
font-weight: 600 !important;
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
.gr-accordion {
|
| 342 |
+
border-radius: 12px !important;
|
| 343 |
+
border: 1px solid #e5e7eb !important;
|
| 344 |
+
font-family: 'Poppins', sans-serif !important;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
.gr-accordion-header {
|
| 348 |
+
font-weight: 500 !important;
|
| 349 |
+
font-family: 'Poppins', sans-serif !important;
|
| 350 |
+
color: #374151 !important;
|
| 351 |
+
letter-spacing: 0.01em !important;
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
.gr-markdown {
|
| 355 |
+
font-family: 'Poppins', sans-serif !important;
|
| 356 |
+
line-height: 1.7 !important;
|
| 357 |
+
font-weight: 400 !important;
|
| 358 |
+
letter-spacing: 0.01em !important;
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
.gr-markdown strong {
|
| 362 |
+
color: #059669 !important;
|
| 363 |
+
font-weight: 600 !important;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
.gr-examples {
|
| 367 |
+
border-radius: 12px !important;
|
| 368 |
+
border: 1px solid #e5e7eb !important;
|
| 369 |
+
background: #f9fafb !important;
|
| 370 |
+
font-family: 'Poppins', sans-serif !important;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
.gr-examples-header {
|
| 374 |
+
font-weight: 600 !important;
|
| 375 |
+
font-family: 'Poppins', sans-serif !important;
|
| 376 |
+
color: #374151 !important;
|
| 377 |
+
letter-spacing: 0.01em !important;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
.gr-code {
|
| 381 |
+
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace !important;
|
| 382 |
+
font-size: 13px !important;
|
| 383 |
+
line-height: 1.6 !important;
|
| 384 |
+
letter-spacing: 0.01em !important;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
.gr-label {
|
| 388 |
+
font-family: 'Poppins', sans-serif !important;
|
| 389 |
+
font-weight: 500 !important;
|
| 390 |
+
color: #374151 !important;
|
| 391 |
+
letter-spacing: 0.01em !important;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
.gr-dropdown {
|
| 395 |
+
font-family: 'Poppins', sans-serif !important;
|
| 396 |
+
font-weight: 400 !important;
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
.gr-checkbox {
|
| 400 |
+
font-family: 'Poppins', sans-serif !important;
|
| 401 |
+
font-weight: 400 !important;
|
| 402 |
+
}
|
| 403 |
+
""") as demo:
|
| 404 |
gr.Markdown("# ScreenCoder: Screenshot to Code")
|
| 405 |
with gr.Row():
|
| 406 |
with gr.Column(scale=1):
|
|
|
|
| 419 |
|
| 420 |
with gr.Column(scale=2):
|
| 421 |
gr.Markdown("## Preview Area")
|
| 422 |
+
gr.Markdown("**Tips**: \n- Use the sliders below to adjust the preview size and zoom level for better viewing experience. \n- Adjust the page's viewing angle by swiping up, down, left, or right. \n- Click the button at the bottom to download the generated package.")
|
| 423 |
+
with gr.Tabs():
|
| 424 |
+
with gr.TabItem("Preview With Placeholder"):
|
| 425 |
+
with gr.Row():
|
| 426 |
+
scale_slider = gr.Slider(0.2, 1.5, value=0.55, step=0.05, label="Zoom")
|
| 427 |
+
width_slider = gr.Slider(400, 2000, value=1920, step=50, label="Canvas Width (px)")
|
| 428 |
+
height_slider = gr.Slider(300, 1200, value=1080, step=50, label="Canvas Height (px)")
|
| 429 |
+
|
| 430 |
+
html_preview = gr.HTML(label="Rendered HTML", show_label=False)
|
| 431 |
+
with gr.TabItem("Preview"):
|
| 432 |
+
with gr.Row():
|
| 433 |
+
scale_slider_with_placeholder = gr.Slider(0.2, 1.5, value=0.55, step=0.05, label="Zoom")
|
| 434 |
+
width_slider_with_placeholder = gr.Slider(400, 2000, value=1920, step=100, label="Canvas Width (px)")
|
| 435 |
+
height_slider_with_placeholder = gr.Slider(300, 1200, value=1080, step=50, label="Canvas Height (px)")
|
| 436 |
+
|
| 437 |
+
html_preview_with_placeholder = gr.HTML(label="Rendered HTML", show_label=False)
|
| 438 |
+
with gr.TabItem("Code"):
|
| 439 |
+
html_code_output = gr.Code(label="Generated HTML", language="html")
|
| 440 |
+
|
| 441 |
+
download_button = gr.Button("Download Package", visible=False, variant="secondary")
|
|
|
|
|
|
|
| 442 |
|
| 443 |
gr.Examples(
|
| 444 |
examples=example_rows,
|