Toymakerftw commited on
Commit
a07c1a8
·
1 Parent(s): be3d7a9

feat: Enhance table styling for better readability

Browse files

- Improved the background colors of the table for better readability:
- Header background color set to light grey (#f3f4f6).
- Alternating row background colors between white (#ffffff) and very light grey (#f9fafb).
- Hover effect on rows changes background to light grey (#f9fafb).

- Added borders and padding for consistent spacing:
- Bottom border for the header with a slightly darker grey (#d1d5db).
- Cell padding set to 0.75rem.

- Adjusted text colors for better contrast:
- Header text color set to dark grey (#1f2937).
- Increased font weight of the header to 600 for emphasis.

These changes make the table more visually appealing and easier to read.

Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -244,7 +244,7 @@ def _format_number(num):
244
 
245
  def convert_to_dataframe(analyzed_articles):
246
  df = pd.DataFrame(analyzed_articles)
247
-
248
  def sentiment_badge(sentiment):
249
  colors = {
250
  "negative": "#ef4444",
@@ -269,32 +269,39 @@ def convert_to_dataframe(analyzed_articles):
269
 
270
  # Convert to HTML table
271
  html_table = df[["Sentiment", "Title", "Description", "Date"]].to_html(
272
- escape=False,
273
  index=False,
274
  border=0,
275
  classes="gradio-table",
276
  justify="start"
277
  )
278
-
279
  # Add custom styling
280
  styled_html = f"""
281
  <style>
282
  .gradio-table {{
283
  width: 100%;
284
  border-collapse: collapse;
 
285
  }}
286
  .gradio-table th {{
287
  text-align: left;
288
  padding: 0.75rem;
289
- background-color: #f8fafc;
290
- border-bottom: 2px solid #e2e8f0;
 
 
291
  }}
292
  .gradio-table td {{
293
  padding: 0.75rem;
294
- border-bottom: 1px solid #f1f5f9;
 
295
  }}
296
  .gradio-table tr:hover td {{
297
- background-color: #f8fafc;
 
 
 
298
  }}
299
  </style>
300
  {html_table}
 
244
 
245
  def convert_to_dataframe(analyzed_articles):
246
  df = pd.DataFrame(analyzed_articles)
247
+
248
  def sentiment_badge(sentiment):
249
  colors = {
250
  "negative": "#ef4444",
 
269
 
270
  # Convert to HTML table
271
  html_table = df[["Sentiment", "Title", "Description", "Date"]].to_html(
272
+ escape=False,
273
  index=False,
274
  border=0,
275
  classes="gradio-table",
276
  justify="start"
277
  )
278
+
279
  # Add custom styling
280
  styled_html = f"""
281
  <style>
282
  .gradio-table {{
283
  width: 100%;
284
  border-collapse: collapse;
285
+ margin-bottom: 1rem;
286
  }}
287
  .gradio-table th {{
288
  text-align: left;
289
  padding: 0.75rem;
290
+ background-color: #f3f4f6;
291
+ border-bottom: 2px solid #d1d5db;
292
+ color: #1f2937;
293
+ font-weight: 600;
294
  }}
295
  .gradio-table td {{
296
  padding: 0.75rem;
297
+ border-bottom: 1px solid #e5e7eb;
298
+ background-color: #ffffff;
299
  }}
300
  .gradio-table tr:hover td {{
301
+ background-color: #f9fafb;
302
+ }}
303
+ .gradio-table tr:nth-child(even) td {{
304
+ background-color: #f9fafb;
305
  }}
306
  </style>
307
  {html_table}