Spaces:
Build error
Build error
File size: 12,087 Bytes
14ba315 4965d2c 14ba315 16e4ad5 14ba315 16e4ad5 14ba315 ca4b089 14ba315 ca4b089 14ba315 ca4b089 14ba315 ca4b089 14ba315 ca4b089 14ba315 ca4b089 14ba315 16e4ad5 14ba315 16e4ad5 14ba315 16e4ad5 14ba315 16e4ad5 14ba315 16e4ad5 14ba315 16e4ad5 14ba315 16e4ad5 14ba315 16e4ad5 | 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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | """Custom Gradio theme and CSS for the Pigeon Pea Pangenome Atlas.
Provides a premium botanical/academic visual identity with forest-green
primary color, gold accents, and clean card-based layouts.
Exports
-------
get_theme() – returns the configured ``gr.themes.Base`` instance.
build_theme() – alias kept for backward compatibility.
CUSTOM_CSS – CSS string passed to ``demo.launch(css=...)`` (Gradio 6.x).
"""
import gradio as gr
# =====================================================================
# Gradio theme
# =====================================================================
def get_theme() -> gr.themes.Base:
"""Return a Gradio theme object with the Atlas visual identity.
* Primary hue : forest green (#2E7D32)
* Secondary hue: gold (#D4A017)
* Neutral hue : warm gray
* Border radius: 12px containers, 8px buttons
* Font : system sans-serif stack
"""
theme = gr.themes.Base(
primary_hue=gr.themes.colors.green,
secondary_hue=gr.themes.colors.amber,
neutral_hue=gr.themes.Color(
name="warmgray",
c50="#FAFAF5",
c100="#F5F5F0",
c200="#E8E8E0",
c300="#D4D4CC",
c400="#A8A8A0",
c500="#787870",
c600="#5C5C55",
c700="#45453F",
c800="#2E2E28",
c900="#1A1A15",
c950="#0D0D0A",
),
font=[
"-apple-system",
"BlinkMacSystemFont",
"Segoe UI",
"Roboto",
"Helvetica Neue",
"Arial",
"sans-serif",
],
font_mono=[
"SF Mono",
"SFMono-Regular",
"ui-monospace",
"Menlo",
"monospace",
],
).set(
# Page
body_background_fill="#FAFAF5",
body_text_color="#1A1A1A",
# Containers / blocks
block_background_fill="#FFFFFF",
block_border_width="0px",
block_border_color="transparent",
block_radius="12px",
block_shadow="0 2px 8px rgba(0,0,0,0.06)",
# Buttons
button_primary_background_fill="linear-gradient(135deg, #2E7D32, #43A047)",
button_primary_background_fill_hover="linear-gradient(135deg, #256b29, #388E3C)",
button_primary_text_color="white",
button_primary_border_color="transparent",
button_secondary_background_fill="transparent",
button_secondary_border_color="#2E7D32",
button_secondary_text_color="#2E7D32",
button_large_radius="8px",
button_small_radius="8px",
# Inputs
input_radius="8px",
input_border_color="#E0E0E0",
input_background_fill="#FFFFFF",
# Spacing
layout_gap="16px",
# Shadows
shadow_spread="0px",
)
return theme
# Backward-compatible alias so existing ``from ui.theme import build_theme``
# continues to work without changes.
build_theme = get_theme
# =====================================================================
# Custom CSS
# =====================================================================
CUSTOM_CSS = """
/* =================================================================
Pigeon Pea Pangenome Atlas — Custom CSS
=================================================================
Class reference (keep in sync with Python HTML builders):
Page : body overrides
Cards : .metric-card, .gene-card-panel
Hero : .hero-header, .hero-stat, .hero-subtitle
Badges : .gene-badge-core, .gene-badge-shell, .gene-badge-cloud
Backpack : .backpack-chip, .backpack-chip-core/shell/cloud
Stepper : .progress-stepper, .step-complete, .step-current, .step-future
Buttons : .btn-primary, .btn-secondary
Legacy : .quest-badge, .badge-core/shell/cloud, .gene-card,
.presence-barcode, .stat-card, .achievement-badge
================================================================= */
/* ---- Page-level overrides ---- */
body,
.gradio-container {
background: #FAFAF5 !important;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, sans-serif;
}
/* Remove default Gradio container borders */
.gradio-container .gr-box,
.gradio-container .gr-panel {
border: none !important;
}
/* ---- Card styling ---- */
.gr-block,
.gr-panel,
.gr-group {
background: #FFFFFF;
border-radius: 16px !important;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
/* ---- Tabs — underline style ---- */
.tabs > .tab-nav {
border-bottom: 2px solid #E0E0E0 !important;
background: transparent !important;
}
.tabs > .tab-nav > button {
border: none !important;
border-radius: 0 !important;
background: transparent !important;
padding: 10px 20px !important;
font-size: 14px;
font-weight: 500;
color: #757575;
transition: color 0.2s, border-color 0.2s;
position: relative;
}
.tabs > .tab-nav > button.selected {
color: #2E7D32 !important;
font-weight: 600;
border-bottom: 3px solid #2E7D32 !important;
}
.tabs > .tab-nav > button:hover {
color: #2E7D32;
}
/* ---- Hero header ---- */
.hero-header {
background: #1a2332;
color: #FFFFFF !important;
padding: 40px 48px;
border-radius: 16px;
margin-bottom: 24px;
}
.hero-header h1 {
margin: 0 0 8px 0;
font-size: 28px;
font-weight: 700;
letter-spacing: -0.5px;
color: #FFFFFF !important;
}
.hero-subtitle {
font-size: 16px;
color: #94a3b8 !important;
margin-bottom: 28px;
line-height: 1.5;
}
.hero-stat {
display: inline-block;
text-align: center;
margin-right: 48px;
vertical-align: top;
}
.hero-stat .stat-number {
display: block;
font-size: 48px;
font-weight: 700;
color: #FFFFFF !important;
line-height: 1.1;
}
.hero-stat .stat-label {
display: block;
font-size: 12px;
font-weight: 400;
color: #94a3b8 !important;
text-transform: uppercase;
letter-spacing: 1px;
margin-top: 6px;
}
/* ---- Metric cards ---- */
.metric-card {
background: #FFFFFF;
border-radius: 16px;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
padding: 24px;
border-top: 3px solid #2E7D32;
text-align: center;
transition: box-shadow 0.2s;
}
.metric-card:hover {
box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}
.metric-card.amber {
border-top-color: #F9A825;
}
.metric-card.red {
border-top-color: #C62828;
}
.metric-card.blue {
border-top-color: #1565C0;
}
.metric-value {
font-size: 36px;
font-weight: 700;
color: #1A1A1A;
line-height: 1.1;
margin-bottom: 4px;
}
.metric-label {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1.2px;
color: #757575;
}
/* ---- Gene card side panel ---- */
.gene-card-panel {
background: #FFFFFF;
border-radius: 16px;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
padding: 20px;
border-left: 3px solid #2E7D32;
}
/* Gene classification badges */
.gene-badge-core {
display: inline-block;
padding: 4px 14px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
background: #2E7D32;
color: #FFFFFF;
}
.gene-badge-shell {
display: inline-block;
padding: 4px 14px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
background: #F9A825;
color: #333333;
}
.gene-badge-cloud {
display: inline-block;
padding: 4px 14px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
background: #C62828;
color: #FFFFFF;
}
/* ---- Backpack chips ---- */
.backpack-chip {
display: inline-block;
padding: 4px 12px;
border-radius: 16px;
font-size: 12px;
font-weight: 600;
margin: 2px 4px;
vertical-align: middle;
}
.backpack-chip-core {
background: #E8F5E9;
color: #2E7D32;
border: 1px solid #C8E6C9;
}
.backpack-chip-shell {
background: #FFF8E1;
color: #F9A825;
border: 1px solid #FFECB3;
}
.backpack-chip-cloud {
background: #FFEBEE;
color: #C62828;
border: 1px solid #FFCDD2;
}
/* ---- Progress stepper ---- */
.progress-stepper {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 0;
padding: 16px 0;
}
.progress-stepper .step {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
color: #757575;
padding: 0 16px;
position: relative;
}
.progress-stepper .step::after {
content: "";
position: absolute;
right: -2px;
width: 24px;
height: 2px;
background: #E0E0E0;
}
.progress-stepper .step:last-child::after {
display: none;
}
.progress-stepper .step .dot {
width: 24px;
height: 24px;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: 700;
flex-shrink: 0;
}
/* Completed step: filled green circle with checkmark */
.step-complete .dot {
background: #2E7D32;
color: #FFFFFF;
}
.step-complete {
color: #2E7D32;
font-weight: 500;
}
/* Current step: green ring, bold label */
.step-current .dot {
background: transparent;
border: 2.5px solid #2E7D32;
color: #2E7D32;
}
.step-current {
color: #2E7D32;
font-weight: 700;
}
/* Future step: gray dimmed circle */
.step-future .dot {
background: #E0E0E0;
color: #9E9E9E;
}
.step-future {
color: #9E9E9E;
}
/* ---- Buttons ---- */
.btn-primary {
display: inline-block;
padding: 10px 24px;
background: linear-gradient(135deg, #2E7D32, #43A047);
color: #FFFFFF !important;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: opacity 0.2s, box-shadow 0.2s;
text-decoration: none;
}
.btn-primary:hover {
opacity: 0.92;
box-shadow: 0 4px 12px rgba(46,125,50,0.25);
}
.btn-secondary {
display: inline-block;
padding: 10px 24px;
background: transparent;
color: #2E7D32 !important;
border: 2px solid #2E7D32;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
text-decoration: none;
}
.btn-secondary:hover {
background: #E8F5E9;
}
/* ---- Hide Gradio footer / reduce noise ---- */
footer {
display: none !important;
}
.gradio-container .gr-padded {
padding: 12px !important;
}
/* Clean accordion styling */
.gr-accordion {
border: 1px solid #E0E0E0 !important;
border-radius: 12px !important;
box-shadow: none !important;
}
.gr-accordion > .label-wrap {
padding: 12px 16px !important;
}
/* ---- Legacy classes (backward compat) ---- */
.quest-badge {
display: inline-block;
padding: 4px 12px;
border-radius: 16px;
font-size: 0.85em;
font-weight: 600;
margin: 2px 4px;
}
.badge-core { background: #2E7D32; color: white; }
.badge-shell { background: #F9A825; color: #333; }
.badge-cloud { background: #C62828; color: white; }
.gene-card {
border: 2px solid #2E7D32;
border-radius: 12px;
padding: 16px;
background: #FFFFFF;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.presence-barcode span {
display: inline-block;
width: 3px;
height: 20px;
margin: 0;
}
.presence-barcode .present { background: #2E7D32; }
.presence-barcode .absent { background: #E0E0E0; }
.stat-card {
text-align: center;
padding: 20px;
border-radius: 12px;
background: #FFFFFF;
border-top: 3px solid #2E7D32;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-card .stat-value {
font-size: 1.8em;
font-weight: 700;
color: #2E7D32;
}
.stat-card .stat-label {
font-size: 0.85em;
color: #757575;
}
.achievement-badge {
display: inline-block;
padding: 6px 14px;
border-radius: 20px;
background: linear-gradient(135deg, #D4A017, #F9A825);
color: #333;
font-weight: 600;
margin: 4px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
"""
|