EngrMuhammadBilal commited on
Commit
5273e75
·
verified ·
1 Parent(s): be4e843

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -62
app.py CHANGED
@@ -39,29 +39,21 @@ PALETTE = {
39
  "stroke_alt":"rgba(255,255,255,0.10)",
40
  }
41
 
 
 
42
  def build_custom_css():
43
  """
44
- Strong-contrast dark UI, light text everywhere by default.
45
- Uses string.Template so CSS braces don't break Python parsing.
46
  """
47
  tmpl = Template(r"""
48
  :root{
49
- --bg: $bg;
50
- --panel: $panel;
51
- --panel-alt: $panel_alt;
52
- --text-light: $text_light;
53
- --text-dark: $text_dark;
54
-
55
- --primary: $primary;
56
- --secondary: $secondary;
57
- --accent: $accent;
58
- --success: $success;
59
- --danger: $danger;
60
-
61
- --stroke: $stroke;
62
- --stroke-alt: $stroke_alt;
63
-
64
- /* Feed Gradio's CSS variables so components comply */
65
  --body-background-fill: var(--bg);
66
  --body-text-color: var(--text-light);
67
  --block-background-fill: var(--panel);
@@ -95,7 +87,7 @@ html, body, .gradio-container{
95
  border-radius: 12px;
96
  }
97
 
98
- /* Hero (subtle gradient from brand accents) */
99
  #hero{
100
  background:
101
  radial-gradient(900px 350px at 20% -20%, color-mix(in srgb, var(--secondary) 25%, transparent) 0%, transparent 100%),
@@ -106,83 +98,88 @@ html, body, .gradio-container{
106
  color: var(--text-light);
107
  }
108
 
109
- /* KPI cards */
110
- .kpi{
111
- text-align:center; padding:12px;
112
- border-radius:10px; border:1px solid var(--stroke);
113
- background: var(--panel-alt); color: var(--text-light);
114
- }
115
 
116
  /* Buttons */
117
  .gradio-container .gr-button, .gradio-container button{
118
- border-radius: 10px !important; font-weight: 650 !important;
119
- letter-spacing: .2px;
120
  }
121
  .gradio-container .gr-button-primary, .gradio-container button.primary{
122
- background: var(--primary) !important;
123
- color: var(--text-dark) !important;
124
  border: 1px solid var(--button-primary-border-color) !important;
125
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--primary) 50%, transparent);
126
  }
127
  .gradio-container .gr-button-secondary, .gradio-container button.secondary{
128
- background: var(--secondary) !important;
129
- color: var(--text-dark) !important;
130
  border: 1px solid var(--button-secondary-border-color) !important;
131
  }
132
 
133
- /* Inputs / dropdowns / file */
134
- input, textarea, select,
135
- .gr-textbox, .gr-text-area, .gr-dropdown, .gr-file, .gr-slider{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  background: var(--panel-alt) !important;
137
  color: var(--text-light) !important;
138
- border: 1px solid var(--stroke-alt) !important;
139
  border-radius: 10px !important;
140
  }
141
- input::placeholder, textarea::placeholder{
142
- color: color-mix(in srgb, var(--text-light) 60%, transparent) !important;
143
- }
144
-
145
- /* Markdown / labels */
146
- label, .label, .prose h1, .prose h2, .prose h3, .prose p, .markdown-body{
147
  color: var(--text-light) !important;
 
148
  }
149
 
150
- /* Links */
151
- a, .prose a{ color: var(--accent) !important; text-decoration:none; }
152
- a:hover{ text-decoration: underline; }
153
-
154
- /* Dataframe / tables */
155
- .dataframe, table, .table, .gr-dataframe *{
156
- color: var(--text-light) !important; background: transparent !important;
157
  }
158
- .dataframe th{
 
 
159
  background: var(--panel-alt) !important;
160
- border-bottom: 1px solid var(--stroke) !important;
 
161
  }
162
- .dataframe td{
163
- border-bottom: 1px solid var(--stroke-alt) !important;
 
 
 
164
  }
165
 
166
  /* Accordion */
167
  .accordion, .gr-accordion{
168
- background: var(--panel-alt) !important;
169
- border: 1px solid var(--stroke) !important;
170
- border-radius: 10px !important;
171
  }
172
 
173
  /* Tabs active underline */
174
  .gradio-container .tabs .tab-nav button.selected{
175
- box-shadow: inset 0 -3px 0 0 var(--primary) !important;
176
- color: var(--text-light) !important;
177
  }
178
 
179
  /* Focus outlines for a11y */
180
- :focus-visible{
181
- outline: 3px solid var(--accent) !important;
182
- outline-offset: 2px !important;
183
- }
184
 
185
- /* Page width for large screens */
186
  .gradio-container{ max-width: 1120px; margin: 0 auto; }
187
  """)
188
  return tmpl.substitute(
@@ -193,6 +190,7 @@ a:hover{ text-decoration: underline; }
193
  stroke=PALETTE["stroke"], stroke_alt=PALETTE["stroke_alt"],
194
  )
195
 
 
196
  # =========================
197
  # Engine config
198
  # =========================
 
39
  "stroke_alt":"rgba(255,255,255,0.10)",
40
  }
41
 
42
+ from string import Template
43
+
44
  def build_custom_css():
45
  """
46
+ Strong-contrast dark UI, light text everywhere (incl. Dataframe & Examples).
 
47
  """
48
  tmpl = Template(r"""
49
  :root{
50
+ --bg: $bg; --panel: $panel; --panel-alt: $panel_alt;
51
+ --text-light: $text_light; --text-dark: $text_dark;
52
+ --primary: $primary; --secondary: $secondary; --accent: $accent;
53
+ --success: $success; --danger: $danger;
54
+ --stroke: $stroke; --stroke-alt: $stroke_alt;
55
+
56
+ /* Gradio tokens */
 
 
 
 
 
 
 
 
 
57
  --body-background-fill: var(--bg);
58
  --body-text-color: var(--text-light);
59
  --block-background-fill: var(--panel);
 
87
  border-radius: 12px;
88
  }
89
 
90
+ /* Hero */
91
  #hero{
92
  background:
93
  radial-gradient(900px 350px at 20% -20%, color-mix(in srgb, var(--secondary) 25%, transparent) 0%, transparent 100%),
 
98
  color: var(--text-light);
99
  }
100
 
101
+ /* KPI */
102
+ .kpi{ text-align:center; padding:12px; border-radius:10px; border:1px solid var(--stroke);
103
+ background: var(--panel-alt); color: var(--text-light); }
 
 
 
104
 
105
  /* Buttons */
106
  .gradio-container .gr-button, .gradio-container button{
107
+ border-radius: 10px !important; font-weight: 650 !important; letter-spacing: .2px;
 
108
  }
109
  .gradio-container .gr-button-primary, .gradio-container button.primary{
110
+ background: var(--primary) !important; color: var(--text-dark) !important;
 
111
  border: 1px solid var(--button-primary-border-color) !important;
112
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--primary) 50%, transparent);
113
  }
114
  .gradio-container .gr-button-secondary, .gradio-container button.secondary{
115
+ background: var(--secondary) !important; color: var(--text-dark) !important;
 
116
  border: 1px solid var(--button-secondary-border-color) !important;
117
  }
118
 
119
+ /* Inputs */
120
+ input, textarea, select, .gr-textbox, .gr-text-area, .gr-dropdown, .gr-file, .gr-slider{
121
+ background: var(--panel-alt) !important; color: var(--text-light) !important;
122
+ border: 1px solid var(--stroke-alt) !important; border-radius: 10px !important;
123
+ }
124
+ input::placeholder, textarea::placeholder{ color: color-mix(in srgb, var(--text-light) 60%, transparent) !important; }
125
+
126
+ /* Markdown / labels / links */
127
+ label, .label, .prose h1, .prose h2, .prose h3, .prose p, .markdown-body{ color: var(--text-light) !important; }
128
+ a, .prose a{ color: var(--accent) !important; text-decoration:none; } a:hover{ text-decoration: underline; }
129
+
130
+ /* --- CRITICAL FIXES (visibility) --- */
131
+
132
+ /* Pandas DataFrame table (Top passages) */
133
+ .gradio-container table.dataframe,
134
+ .gradio-container .dataframe,
135
+ .gradio-container .gr-dataframe{
136
  background: var(--panel-alt) !important;
137
  color: var(--text-light) !important;
138
+ border: 1px solid var(--stroke) !important;
139
  border-radius: 10px !important;
140
  }
141
+ .gradio-container table.dataframe th,
142
+ .gradio-container table.dataframe td,
143
+ .gradio-container .gr-dataframe th,
144
+ .gradio-container .gr-dataframe td{
145
+ background: var(--panel-alt) !important;
 
146
  color: var(--text-light) !important;
147
+ border-color: var(--stroke-alt) !important;
148
  }
149
 
150
+ /* Examples grid (Quick examples) */
151
+ .gradio-container .examples,
152
+ .gradio-container .examples *{
153
+ color: var(--text-light) !important;
 
 
 
154
  }
155
+ .gradio-container .examples,
156
+ .gradio-container .examples .grid,
157
+ .gradio-container .examples .grid .item{
158
  background: var(--panel-alt) !important;
159
+ border: 1px solid var(--stroke-alt) !important;
160
+ border-radius: 10px !important;
161
  }
162
+
163
+ /* Code blocks in Markdown (error traces, etc.) */
164
+ .markdown-body pre, .markdown-body code{
165
+ background: #0B1D3A !important; color: var(--text-light) !important;
166
+ border: 1px solid var(--stroke-alt) !important; border-radius: 8px;
167
  }
168
 
169
  /* Accordion */
170
  .accordion, .gr-accordion{
171
+ background: var(--panel-alt) !important; border: 1px solid var(--stroke) !important; border-radius: 10px !important;
 
 
172
  }
173
 
174
  /* Tabs active underline */
175
  .gradio-container .tabs .tab-nav button.selected{
176
+ box-shadow: inset 0 -3px 0 0 var(--primary) !important; color: var(--text-light) !important;
 
177
  }
178
 
179
  /* Focus outlines for a11y */
180
+ :focus-visible{ outline: 3px solid var(--accent) !important; outline-offset: 2px !important; }
 
 
 
181
 
182
+ /* Page width */
183
  .gradio-container{ max-width: 1120px; margin: 0 auto; }
184
  """)
185
  return tmpl.substitute(
 
190
  stroke=PALETTE["stroke"], stroke_alt=PALETTE["stroke_alt"],
191
  )
192
 
193
+
194
  # =========================
195
  # Engine config
196
  # =========================