Nischal Subedi commited on
Commit
ff69f36
·
1 Parent(s): 7c87254

updated UI v5

Browse files
Files changed (1) hide show
  1. app.py +52 -39
app.py CHANGED
@@ -247,15 +247,15 @@ Answer:"""
247
  self,
248
  **kwargs,
249
  ):
 
250
  super().__init__(
251
- # Custom fonts
252
  font=[themes.GoogleFont("Inter"), "sans-serif"],
253
  font_mono=themes.GoogleFont("JetBrains Mono"),
254
- heading_font=[themes.GoogleFont("Playfair Display"), "serif"],
255
 
256
  # --- Dark Mode Colors (Legal Noir) ---
257
  # Primary/Accent Colors (Goldenrod/Amber scale)
258
- primary_50_dark="#FFFDE7", # Very light yellow/amber
259
  primary_100_dark="#FFF9C4",
260
  primary_200_dark="#FFF59D",
261
  primary_300_dark="#FFF176",
@@ -265,50 +265,55 @@ Answer:"""
265
  primary_700_dark="#B88A00",
266
  primary_800_dark="#8D6C00",
267
  primary_900_dark="#614B00",
268
- primary_950_dark="#403200", # Darkest amber/brown
269
 
270
  # Backgrounds
271
- background_page_dark="#0F0F1A", # Overall app background
272
- block_background_fill_dark="#1A1A2B", # Header and main footer background
273
- background_fill_primary_dark="#1E1E30", # Main dashboard container background (slightly lighter than page)
274
- background_fill_secondary_dark="#2A2A40", # Inner card sections background (lighter than primary)
275
- background_fill_tertiary_dark="#3F3F5A", # For things like table headers, slightly more prominent
276
 
277
  # Text Colors
278
- text_color_body_dark="#EAEAF0", # Main text
279
- text_color_subdued_dark="#A0A0B0", # Secondary text, placeholders
280
- text_color_header_dark="#EAEAF0", # Heading text (matches body for consistency)
281
 
282
  # Borders
283
- border_color_primary_dark="#3F3F5A", # Main borders for blocks/cards
284
- border_color_secondary_dark="#505060", # Lighter borders for internal elements (e.g., table rows)
285
 
286
  # Shadows (as hex colors for theme consistency, will be applied as rgba in CSS)
287
- shadow_lg_dark="0F0F1A", # Represents darkest shadow color, will be used with rgba
288
- shadow_md_dark="1A1A2B",
289
- shadow_sm_dark="1E1E30",
290
-
 
291
 
292
  # Links
293
  link_text_color_dark="#FFC107",
294
  link_text_color_hover_dark="#E0A800",
295
 
 
 
 
 
 
296
  # Error Colors
297
- color_error_50_dark="#4D001A", # Lightest error tint (for background)
298
- color_error_200_dark="#990026", # Medium error (for border)
299
- color_error_500_dark="#CC0033", # Main error (for icon)
300
- color_error_600_dark="#FFB3C2", # Darker error (for text)
301
 
302
 
303
  # --- Light Mode Colors (Legal Lumen) ---
304
- # Primary Colors (Standard Blue scale)
305
  primary_50_light="#E3F2FD",
306
  primary_100_light="#BBDEFB",
307
  primary_200_light="#90CAF9",
308
  primary_300_light="#64B5F6",
309
  primary_400_light="#42A5F5",
310
- primary_500_light="#2196F3", # Main blue
311
- primary_600_light="#1E88E5", # Hover blue
312
  primary_700_light="#1976D2",
313
  primary_800_light="#1565C0",
314
  primary_900_light="#0D47A1",
@@ -334,6 +339,10 @@ Answer:"""
334
  link_text_color_light="#007bff",
335
  link_text_color_hover_light="#0056b3",
336
 
 
 
 
 
337
  color_error_50_light="#F8D7DA",
338
  color_error_200_light="#F5C6CB",
339
  color_error_500_light="#DC3545",
@@ -344,11 +353,14 @@ Answer:"""
344
  radius_sm="8px",
345
  radius_md="12px",
346
  radius_lg="24px",
347
- spacing_md="2.5rem", # Matches gaps between major sections
348
- spacing_lg="3.5rem", # Matches padding for header/main dashboard
349
- spacing_xl="4.5rem", # Matches header padding top/bottom
350
  **kwargs,
351
  )
 
 
 
352
 
353
  def gradio_interface(self):
354
  def query_interface_wrapper(api_key: str, query: str, state: str) -> str:
@@ -356,9 +368,9 @@ Answer:"""
356
  if not api_key or not api_key.strip() or not api_key.startswith("sk-"):
357
  return "<div class='error-message'><span class='error-icon'>⚠️</span>Please provide a valid OpenAI API key (starting with 'sk-'). <a href='https://platform.openai.com/api-keys' target='_blank'>Get one free from OpenAI</a>.</div>"
358
  if not state or state == "Select a state..." or "Error" in state:
359
- return "<div class='error-message'><span class='error-icon'>⚠️</span>Please select a valid state from the dropdown.</div>"
360
  if not query or not query.strip():
361
- return "<div class='error-message'><span class='error-icon'>⚠️</span>Please enter your question in the text box.</div>"
362
 
363
  # Call the core processing logic
364
  result = self.process_query(query=query, state=state, openai_api_key=api_key)
@@ -412,7 +424,7 @@ Answer:"""
412
  /* General Gradio container layout and centering */
413
  body { margin: 0; padding: 0; } /* Reset default body margin */
414
  .gradio-container {
415
- font-family: 'Inter', sans-serif !important; /* Ensure Inter is main font */
416
  min-height: 100vh;
417
  display: flex;
418
  justify-content: center; /* Center content horizontally */
@@ -452,7 +464,7 @@ Answer:"""
452
  animation: fadeInSlideDown 1.5s ease-out forwards; animation-delay: 0.3s;
453
  }
454
  .app-header-title {
455
- font-family: 'Playfair Display', serif !important; /* Override with specific heading font */
456
  font-size: 4.2rem; font-weight: 900;
457
  margin: 0 0 0.8rem 0; letter-spacing: -0.07em;
458
  color: var(--text-color-header); /* Use theme text color for headings */
@@ -461,7 +473,7 @@ Answer:"""
461
  animation: fadeInSlideDown 1.5s ease-out forwards; animation-delay: 0.6s;
462
  }
463
  .app-header-tagline {
464
- font-family: 'Inter', sans-serif !important;
465
  font-size: 1.6rem; font-weight: 300;
466
  color: var(--text-color-subdued); /* Use theme subdued text color */
467
  opacity: 0.9; max-width: 900px;
@@ -492,7 +504,7 @@ Answer:"""
492
 
493
  /* Section titles within cards */
494
  .card-section-title {
495
- font-family: 'Playfair Display', serif !important;
496
  font-size: 2.2rem !important;
497
  font-weight: 800 !important;
498
  color: var(--text-color-body) !important; /* Use theme body text color */
@@ -504,7 +516,7 @@ Answer:"""
504
 
505
  /* General text styling within cards */
506
  .dashboard-card-section p {
507
- font-family: 'Inter', sans-serif !important;
508
  font-size: 1.1rem;
509
  line-height: 1.6;
510
  color: var(--text-color-body);
@@ -597,7 +609,7 @@ Answer:"""
597
  color: var(--primary-500); /* Use theme primary color */
598
  }
599
  .response-title {
600
- font-family: 'Playfair Display', serif !important;
601
  font-size: 1.8rem !important;
602
  font-weight: 700 !important;
603
  color: var(--text-color-body) !important; /* Ensure heading is legible */
@@ -610,7 +622,7 @@ Answer:"""
610
  margin: 1rem 0 1.5rem 0;
611
  }
612
  .output-content-wrapper {
613
- font-family: 'Inter', sans-serif !important;
614
  line-height: 1.7;
615
  font-size: 1.05rem;
616
  color: var(--text-color-body);
@@ -705,7 +717,7 @@ Answer:"""
705
  width: 100%; /* Ensure content takes full width */
706
  }
707
  .app-footer p {
708
- font-family: 'Inter', sans-serif !important;
709
  font-size: 0.95rem !important;
710
  color: var(--text-color-subdued) !important;
711
  margin-bottom: 0.5rem;
@@ -725,7 +737,8 @@ Answer:"""
725
  .gr-messages-row, .gr-share-btn, .gr-api-btn, .gr-view-api, /* Common boilerplate elements */
726
  .gradio-container > footer, /* Default Gradio footer text that appears below blocks */
727
  .gradio-app .version-info, /* Gradio version info */
728
- .gradio-app .dark\:text-gray-400 /* Target other default footer text */ {
 
729
  display: none !important;
730
  visibility: hidden !important;
731
  width: 0 !important;
 
247
  self,
248
  **kwargs,
249
  ):
250
+ # Pass all accepted kwargs to the base class
251
  super().__init__(
252
+ # Fonts are accepted directly by themes.Base
253
  font=[themes.GoogleFont("Inter"), "sans-serif"],
254
  font_mono=themes.GoogleFont("JetBrains Mono"),
 
255
 
256
  # --- Dark Mode Colors (Legal Noir) ---
257
  # Primary/Accent Colors (Goldenrod/Amber scale)
258
+ primary_50_dark="#FFFDE7",
259
  primary_100_dark="#FFF9C4",
260
  primary_200_dark="#FFF59D",
261
  primary_300_dark="#FFF176",
 
265
  primary_700_dark="#B88A00",
266
  primary_800_dark="#8D6C00",
267
  primary_900_dark="#614B00",
268
+ primary_950_dark="#403200",
269
 
270
  # Backgrounds
271
+ background_page_dark="#0F0F1A",
272
+ block_background_fill_dark="#1A1A2B",
273
+ background_fill_primary_dark="#1E1E30",
274
+ background_fill_secondary_dark="#2A2A40",
275
+ background_fill_tertiary_dark="#3F3F5A",
276
 
277
  # Text Colors
278
+ text_color_body_dark="#EAEAF0",
279
+ text_color_subdued_dark="#A0A0B0",
280
+ text_color_header_dark="#EAEAF0",
281
 
282
  # Borders
283
+ border_color_primary_dark="#3F3F5A",
284
+ border_color_secondary_dark="#505060",
285
 
286
  # Shadows (as hex colors for theme consistency, will be applied as rgba in CSS)
287
+ # These are colors, not directly applied as 'shadow-lg' etc. by theme.Base
288
+ # They will be used via CSS variables
289
+ shadow_lg_dark="0F0F1A", # Represents darkest shadow color for rgba(..., 0.6)
290
+ shadow_md_dark="1A1A2B", # Represents medium shadow color for rgba(..., 0.4)
291
+ shadow_sm_dark="1E1E30", # Represents light shadow color for rgba(..., 0.35)
292
 
293
  # Links
294
  link_text_color_dark="#FFC107",
295
  link_text_color_hover_dark="#E0A800",
296
 
297
+ # Buttons (theme handles primary colors, custom CSS for secondary)
298
+ button_primary_background_dark="#FFC107",
299
+ button_primary_background_hover_dark="#E0A800",
300
+ button_primary_text_color_dark="#1A1A2B",
301
+
302
  # Error Colors
303
+ color_error_50_dark="#4D001A",
304
+ color_error_200_dark="#990026",
305
+ color_error_500_dark="#CC0033",
306
+ color_error_600_dark="#FFB3C2",
307
 
308
 
309
  # --- Light Mode Colors (Legal Lumen) ---
 
310
  primary_50_light="#E3F2FD",
311
  primary_100_light="#BBDEFB",
312
  primary_200_light="#90CAF9",
313
  primary_300_light="#64B5F6",
314
  primary_400_light="#42A5F5",
315
+ primary_500_light="#2196F3",
316
+ primary_600_light="#1E88E5",
317
  primary_700_light="#1976D2",
318
  primary_800_light="#1565C0",
319
  primary_900_light="#0D47A1",
 
339
  link_text_color_light="#007bff",
340
  link_text_color_hover_light="#0056b3",
341
 
342
+ button_primary_background_light="#007bff",
343
+ button_primary_background_hover_light="#0056b3",
344
+ button_primary_text_color_light="#FFFFFF",
345
+
346
  color_error_50_light="#F8D7DA",
347
  color_error_200_light="#F5C6CB",
348
  color_error_500_light="#DC3545",
 
353
  radius_sm="8px",
354
  radius_md="12px",
355
  radius_lg="24px",
356
+ spacing_md="2.5rem",
357
+ spacing_lg="3.5rem",
358
+ spacing_xl="4.5rem",
359
  **kwargs,
360
  )
361
+ # Assign heading_font directly to self after super().__init__ as it's not a direct base constructor argument
362
+ self.heading_font = [themes.GoogleFont("Playfair Display"), "serif"]
363
+
364
 
365
  def gradio_interface(self):
366
  def query_interface_wrapper(api_key: str, query: str, state: str) -> str:
 
368
  if not api_key or not api_key.strip() or not api_key.startswith("sk-"):
369
  return "<div class='error-message'><span class='error-icon'>⚠️</span>Please provide a valid OpenAI API key (starting with 'sk-'). <a href='https://platform.openai.com/api-keys' target='_blank'>Get one free from OpenAI</a>.</div>"
370
  if not state or state == "Select a state..." or "Error" in state:
371
+ return "<div class='error-message'>Error: Please select a valid state.</div>" # Simplified message
372
  if not query or not query.strip():
373
+ return "<div class='error-message'>Error: Please enter your question.</div>" # Simplified message
374
 
375
  # Call the core processing logic
376
  result = self.process_query(query=query, state=state, openai_api_key=api_key)
 
424
  /* General Gradio container layout and centering */
425
  body { margin: 0; padding: 0; } /* Reset default body margin */
426
  .gradio-container {
427
+ font-family: var(--font-text) !important; /* Use theme's text font variable */
428
  min-height: 100vh;
429
  display: flex;
430
  justify-content: center; /* Center content horizontally */
 
464
  animation: fadeInSlideDown 1.5s ease-out forwards; animation-delay: 0.3s;
465
  }
466
  .app-header-title {
467
+ font-family: var(--font-heading) !important; /* Use theme's heading font variable */
468
  font-size: 4.2rem; font-weight: 900;
469
  margin: 0 0 0.8rem 0; letter-spacing: -0.07em;
470
  color: var(--text-color-header); /* Use theme text color for headings */
 
473
  animation: fadeInSlideDown 1.5s ease-out forwards; animation-delay: 0.6s;
474
  }
475
  .app-header-tagline {
476
+ font-family: var(--font-text) !important;
477
  font-size: 1.6rem; font-weight: 300;
478
  color: var(--text-color-subdued); /* Use theme subdued text color */
479
  opacity: 0.9; max-width: 900px;
 
504
 
505
  /* Section titles within cards */
506
  .card-section-title {
507
+ font-family: var(--font-heading) !important; /* Use theme's heading font variable */
508
  font-size: 2.2rem !important;
509
  font-weight: 800 !important;
510
  color: var(--text-color-body) !important; /* Use theme body text color */
 
516
 
517
  /* General text styling within cards */
518
  .dashboard-card-section p {
519
+ font-family: var(--font-text) !important;
520
  font-size: 1.1rem;
521
  line-height: 1.6;
522
  color: var(--text-color-body);
 
609
  color: var(--primary-500); /* Use theme primary color */
610
  }
611
  .response-title {
612
+ font-family: var(--font-heading) !important;
613
  font-size: 1.8rem !important;
614
  font-weight: 700 !important;
615
  color: var(--text-color-body) !important; /* Ensure heading is legible */
 
622
  margin: 1rem 0 1.5rem 0;
623
  }
624
  .output-content-wrapper {
625
+ font-family: var(--font-text) !important;
626
  line-height: 1.7;
627
  font-size: 1.05rem;
628
  color: var(--text-color-body);
 
717
  width: 100%; /* Ensure content takes full width */
718
  }
719
  .app-footer p {
720
+ font-family: var(--font-text) !important;
721
  font-size: 0.95rem !important;
722
  color: var(--text-color-subdued) !important;
723
  margin-bottom: 0.5rem;
 
737
  .gr-messages-row, .gr-share-btn, .gr-api-btn, .gr-view-api, /* Common boilerplate elements */
738
  .gradio-container > footer, /* Default Gradio footer text that appears below blocks */
739
  .gradio-app .version-info, /* Gradio version info */
740
+ .gradio-app .dark\:text-gray-400, /* Target other default footer text classes */
741
+ .gradio-app .absolute.bottom-0.right-0.px-2.py-1.text-gray-400.text-xs /* another common footer class */ {
742
  display: none !important;
743
  visibility: hidden !important;
744
  width: 0 !important;