Spaces:
Running
on
Zero
Running
on
Zero
File size: 9,562 Bytes
b9892ff 53f9237 b9892ff f1d5053 21d4df0 f1d5053 53f9237 f1d5053 21d4df0 f1d5053 53f9237 178c670 21d4df0 178c670 f1d5053 53f9237 f1d5053 21d4df0 f1d5053 53f9237 f1d5053 21d4df0 f1d5053 53f9237 21d4df0 f1d5053 53f9237 21d4df0 f1d5053 53f9237 f1d5053 21d4df0 f1d5053 53f9237 21d4df0 f1d5053 53f9237 21d4df0 f1d5053 53f9237 f1d5053 21d4df0 f1d5053 21d4df0 53f9237 21d4df0 f1d5053 21d4df0 53f9237 b9892ff c4cdf32 b9892ff c4cdf32 b9892ff c4cdf32 b9892ff c4cdf32 b9892ff f1d5053 e7fa673 b9892ff f1d5053 b9892ff 0a6e04f b9892ff f1d5053 b9892ff c4cdf32 b9892ff c4cdf32 b9892ff c4cdf32 b9892ff c4cdf32 b9892ff f1d5053 b9892ff f1d5053 b9892ff f1d5053 b9892ff c4cdf32 f1d5053 c4cdf32 f1d5053 b9892ff f1d5053 b9892ff f1d5053 b9892ff c4cdf32 f1d5053 c4cdf32 f1d5053 b9892ff f1d5053 b9892ff f1d5053 b9892ff c4cdf32 f1d5053 c4cdf32 b9892ff |
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 |
"""Custom Gradio theme for Portfolio Intelligence Platform.
Professional financial application theme with:
- Trust-inspiring blue/grey colour palette
- Clean typography with Inter font
- Subtle shadows and borders
- Optimised for data-heavy interfaces
"""
import gradio as gr
from gradio.themes.base import Base
from gradio.themes.utils import colors, fonts, sizes
class FinancialTheme(Base):
"""Professional financial application theme for Gradio."""
def __init__(self, **kwargs):
"""Initialise financial theme with professional colours and typography."""
super().__init__(
# Trust & stability colours
primary_hue=colors.blue, # Professional blue
secondary_hue=colors.slate, # Neutral greys
neutral_hue=colors.gray,
# Professional sizing
spacing_size=sizes.spacing_md,
radius_size=sizes.radius_sm, # Subtle rounded corners
text_size=sizes.text_lg, # Readable text
# Professional fonts
font=fonts.GoogleFont("Inter"), # Clean sans-serif
font_mono=fonts.GoogleFont("IBM Plex Mono")
)
# Custom colour overrides
super().set(
# Background
body_background_fill="#f8f9fa",
body_background_fill_dark="#1a1a1a",
# Primary buttons
button_primary_background_fill="#288cfa",
button_primary_background_fill_hover="#1a7de8",
button_primary_text_color="white",
button_primary_shadow="0 2px 4px rgba(40, 140, 250, 0.2)",
button_primary_border_color="#288cfa",
# Secondary buttons
button_secondary_background_fill="white",
button_secondary_background_fill_hover="#f8f9fa",
button_secondary_text_color="#288cfa",
button_secondary_border_color="#dee2e6",
# Card/block styling
block_background_fill="white",
block_border_width="1px",
block_border_color="#e5e7eb",
block_shadow="0 1px 3px 0 rgba(0, 0, 0, 0.1)",
block_title_text_weight="600",
block_title_text_color="#242c34",
block_label_text_weight="500",
block_label_text_color="#6b7280",
# Input styling
input_background_fill="white",
input_border_color="#d1d5db",
input_shadow="0 1px 2px 0 rgba(0, 0, 0, 0.05)",
input_border_width="1px",
# Checkbox/radio
checkbox_border_color="#d1d5db",
checkbox_background_color="white",
# Status colours
color_accent_soft="#10b981", # Green for positive
stat_background_fill="#fef3c7", # Subtle yellow for highlights
# Progress bar
loader_color="#288cfa",
slider_color="#288cfa",
# Table styling
table_border_color="#e5e7eb",
table_odd_background_fill="#f9fafb",
table_even_background_fill="white",
# Panel styling
panel_background_fill="white",
panel_border_color="#e5e7eb",
panel_border_width="1px",
)
# Custom CSS for additional styling (theme-adaptive with dark mode improvements)
FINANCIAL_CSS = """
/* Global container styling */
.gradio-container {
font-family: 'Inter', 'Arial', sans-serif;
max-width: 1400px;
margin: auto;
}
/* Adaptive container background - follows HuggingFace Spaces theme */
.gradio-container {
background: var(--body-background-fill);
}
/* Clean input styling - theme adaptive */
input,
textarea {
background-color: var(--input-background-fill);
border: 1px solid var(--input-border-color);
border-radius: 8px;
}
input:focus-visible,
textarea:focus-visible {
outline: 3px solid var(--button-primary-background-fill);
outline-offset: 2px;
border-radius: 2px;
opacity: 1 !important;
}
input:focus,
textarea:focus {
opacity: 1 !important;
border-color: var(--button-primary-background-fill);
box-shadow: 0 0 0 3px var(--button-primary-background-fill-hover);
}
/* Group/card styling with subtle shadows - theme adaptive */
.gr-group,
.gr-box {
background-color: var(--block-background-fill);
border: 1px solid var(--block-border-color);
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
/* Button styling - theme adaptive */
.gr-button {
border-radius: 8px;
}
.gr-button-primary {
background: var(--button-primary-background-fill);
border: none;
color: var(--button-primary-text-color);
font-weight: 600;
}
.gr-button-primary:hover {
background: var(--button-primary-background-fill-hover);
}
/* Example portfolio cards - theme adaptive */
.gr-examples {
background-color: var(--block-background-fill);
border: 1px solid var(--block-border-color);
border-radius: 8px;
}
.gr-examples button {
background-color: var(--button-secondary-background-fill);
border: 1px solid var(--button-secondary-border-color);
}
.gr-examples button:hover {
background-color: var(--button-secondary-background-fill-hover);
border-color: var(--button-primary-background-fill);
}
/* Header styling - theme adaptive */
.header h1 {
color: var(--body-text-color);
font-weight: 700;
letter-spacing: -0.025em;
margin-bottom: 0.5rem;
}
.header h3 {
color: var(--body-text-color);
opacity: 0.7;
font-weight: 400;
margin-top: 0;
}
.markdown-text h1 {
font-weight: 600;
border-bottom: 2px solid var(--color-accent);
padding-bottom: 0.5rem;
margin-bottom: 1rem;
}
.markdown-text h2 {
font-weight: 600;
margin-top: 1.5rem;
margin-bottom: 0.75rem;
}
.markdown-text h3 {
font-weight: 500;
margin-top: 1rem;
margin-bottom: 0.5rem;
opacity: 0.8;
}
/* Metric cards */
.metrics-row {
gap: 1rem;
}
.metric-card {
padding: 1.5rem;
border-radius: 8px;
}
.metric-card .label {
font-size: 0.875rem;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 0.5rem;
opacity: 0.7;
}
.metric-card .value {
font-size: 2rem;
font-weight: 600;
}
/* Status colours */
.positive {
color: #10b981;
font-weight: 600;
}
.negative {
color: #ef4444;
font-weight: 600;
}
.neutral {
font-weight: 500;
opacity: 0.7;
}
/* Data tables */
.dataframe {
border-radius: 6px;
overflow: visible;
}
.dataframe th {
font-weight: 600;
text-transform: uppercase;
font-size: 0.75rem;
letter-spacing: 0.05em;
}
/* Button enhancements */
.primary.lg {
padding: 0.75rem 2rem;
font-weight: 600;
font-size: 1.125rem;
}
.secondary.lg {
padding: 0.75rem 2rem;
font-weight: 600;
font-size: 1.125rem;
}
/* Progress bar */
.progress-bar {
background: linear-gradient(90deg, var(--color-accent), var(--color-accent-soft));
}
/* Accordion styling for ChatMessage metadata */
.message-metadata {
border-left: 3px solid var(--color-accent);
padding-left: 1rem;
margin: 0.5rem 0;
border-radius: 4px;
padding: 0.75rem 1rem;
}
.message-metadata .title {
font-weight: 600;
margin-bottom: 0.25rem;
}
.message-metadata .log {
font-size: 0.875rem;
opacity: 0.7;
}
/* Tool call status indicators */
.status-pending {
color: #f59e0b;
}
.status-done {
color: #10b981;
}
.status-error {
color: #ef4444;
}
/* Loading spinner */
.loading {
border: 3px solid var(--border-color-primary);
border-top-color: var(--color-accent);
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Responsive design */
@media (max-width: 768px) {
.gradio-container {
padding: 1rem;
}
.metric-card .value {
font-size: 1.5rem;
}
}
/* Chart containers */
.plotly-chart {
border-radius: 8px;
padding: 1rem;
}
/* Tab styling */
.tab-nav button.selected {
border-bottom: 2px solid var(--color-accent);
color: var(--color-accent);
font-weight: 600;
}
/* Error messages - theme adaptive */
.error-message {
background: var(--error-background-fill, #fee2e2);
border-left: 4px solid var(--error-border-color, #ef4444);
padding: 1rem;
border-radius: 4px;
color: var(--error-text-color, #991b1b);
}
.dark .error-message {
background: var(--error-background-fill-dark, #450a0a);
color: var(--error-text-color-dark, #fca5a5);
}
/* Success messages - theme adaptive */
.success-message {
background: var(--color-accent-soft-background, #d1fae5);
border-left: 4px solid var(--color-accent-soft, #10b981);
padding: 1rem;
border-radius: 4px;
color: var(--color-accent-soft-text, #065f46);
}
.dark .success-message {
background: var(--color-accent-soft-background-dark, #064e3b);
color: var(--color-accent-soft-text-dark, #6ee7b7);
}
/* Info messages - theme adaptive */
.info-message {
background: var(--info-background-fill, #dbeafe);
border-left: 4px solid var(--button-primary-background-fill, #3b82f6);
padding: 1rem;
border-radius: 4px;
color: var(--info-text-color, #1e40af);
}
.dark .info-message {
background: var(--info-background-fill-dark, #1e3a8a);
color: var(--info-text-color-dark, #93c5fd);
}
"""
def get_financial_theme() -> gr.Theme:
"""Get the financial theme instance.
Returns:
Configured FinancialTheme instance
"""
return FinancialTheme()
|