Luigi commited on
Commit
85487c1
·
1 Parent(s): 4465a4a

style: comprehensive CSS overhaul for polished visual design

Browse files

Major visual improvements:
- Add CSS variables for colors, shadows, and border-radius consistency
- Style Tabs with active states, hover effects, and proper borders
- Add subtle shadows to cards, groups, accordions for depth
- Style secondary buttons (Copy, Download) with hover states
- Improve accordion styling with gradient headers
- Add focus states for accessibility
- Add custom scrollbar styling for output boxes
- Style the footer with CSS class instead of inline styles
- Add responsive breakpoints for mobile
- Better typography with proper font stacks for monospace

The UI now has a cohesive, modern look with proper visual hierarchy.

Files changed (1) hide show
  1. app.py +296 -75
app.py CHANGED
@@ -1348,162 +1348,383 @@ def summarize_streaming(
1348
  # Custom CSS for better UI
1349
  custom_css = """
1350
  :root {
1351
- --primary-color: #3b82f6;
1352
- --primary-hover: #2563eb;
 
 
1353
  --bg-color: #f8fafc;
1354
  --card-bg: #ffffff;
1355
  --text-color: #1e293b;
 
1356
  --border-color: #e2e8f0;
 
 
 
 
 
 
 
 
 
 
 
1357
  }
1358
 
 
 
 
 
 
 
1359
  .app-header {
1360
  text-align: center;
1361
- padding: 1.5rem;
1362
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
1363
- border-radius: 12px;
1364
- margin-bottom: 2rem;
1365
  color: white;
 
1366
  }
1367
 
1368
  .app-header h1 {
1369
  margin: 0 0 0.5rem 0;
1370
- font-size: 2rem;
1371
  font-weight: 700;
 
1372
  }
1373
 
1374
  .app-header p {
1375
  margin: 0;
1376
  opacity: 0.9;
 
1377
  }
1378
 
1379
  .model-badge {
1380
  display: inline-flex;
1381
  align-items: center;
1382
  gap: 0.5rem;
1383
- background: rgba(255,255,255,0.2);
1384
  padding: 0.5rem 1rem;
1385
  border-radius: 20px;
1386
  font-size: 0.85rem;
1387
  margin-top: 1rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1388
  }
1389
 
 
 
 
 
 
 
1390
  .section-header {
1391
- font-size: 1.1rem;
1392
  font-weight: 600;
1393
  color: var(--text-color);
1394
  margin-bottom: 0.75rem;
1395
  display: flex;
1396
  align-items: center;
1397
  gap: 0.5rem;
 
 
1398
  }
1399
 
1400
  .section-icon {
1401
- font-size: 1.2rem;
1402
  }
1403
 
1404
- .instructions {
1405
- background: #f1f5f9;
1406
- border-left: 4px solid var(--primary-color);
1407
- padding: 1rem;
1408
- border-radius: 0 8px 8px 0;
1409
- margin-bottom: 1.5rem;
 
1410
  }
1411
 
1412
- .instructions ul {
1413
- margin: 0.5rem 0 0 0;
1414
- padding-left: 1.5rem;
1415
  }
1416
 
1417
- .instructions li {
1418
- margin-bottom: 0.25rem;
 
 
 
1419
  }
1420
 
1421
- .output-container {
1422
- background: var(--card-bg);
1423
- border: 1px solid var(--border-color);
1424
- border-radius: 8px;
1425
- padding: 1rem;
1426
- min-height: 200px;
 
 
 
 
1427
  }
1428
 
1429
- .thinking-box {
1430
- background: #fef3c7;
1431
- border: 1px solid #fbbf24;
1432
- border-radius: 8px;
1433
- padding: 1rem;
1434
- font-family: 'Courier New', monospace;
1435
- font-size: 0.9rem;
1436
- white-space: pre-wrap;
1437
  }
1438
 
1439
- .summary-box {
1440
- background: #f0fdf4;
1441
- border: 1px solid #86efac;
1442
- border-radius: 8px;
1443
- padding: 1rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1444
  }
1445
 
 
 
1446
  .submit-btn {
1447
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
1448
  border: none !important;
1449
  color: white !important;
1450
  font-weight: 600 !important;
1451
- padding: 0.75rem 2rem !important;
1452
- border-radius: 8px !important;
1453
  cursor: pointer;
1454
- transition: transform 0.2s, box-shadow 0.2s !important;
 
 
 
1455
  }
1456
 
1457
  .submit-btn:hover {
1458
  transform: translateY(-2px);
1459
- box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4) !important;
 
 
 
 
1460
  }
1461
 
1462
- .advanced-settings {
1463
- background: #f8fafc;
1464
- border: 1px solid var(--border-color);
1465
- border-radius: 8px;
1466
- padding: 1rem;
 
 
 
 
 
 
1467
  }
1468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1469
  .file-upload-area {
1470
- border: 2px dashed #cbd5e1;
1471
- border-radius: 12px;
1472
- padding: 2rem;
1473
  text-align: center;
1474
- transition: border-color 0.3s, background 0.3s;
 
1475
  }
1476
 
1477
  .file-upload-area:hover {
1478
- border-color: var(--primary-color);
1479
- background: #f8fafc;
 
 
 
 
 
 
 
 
 
1480
  }
1481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1482
  .stats-grid {
1483
- display: grid;
1484
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
1485
- gap: 1rem;
1486
- margin-top: 1rem;
1487
  }
1488
 
1489
- .stat-card {
1490
- background: var(--card-bg);
1491
- border: 1px solid var(--border-color);
1492
- border-radius: 8px;
1493
- padding: 1rem;
1494
- text-align: center;
1495
  }
1496
 
1497
- .stat-value {
1498
- font-size: 1.5rem;
1499
- font-weight: 700;
1500
- color: var(--primary-color);
 
 
 
 
 
 
 
 
 
 
1501
  }
1502
 
1503
- .stat-label {
 
 
 
 
 
1504
  font-size: 0.85rem;
1505
- color: #64748b;
1506
- margin-top: 0.25rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1507
  }
1508
  """
1509
 
@@ -2056,8 +2277,8 @@ def create_interface():
2056
 
2057
  # Footer
2058
  gr.HTML("""
2059
- <div style="text-align: center; margin-top: 2rem; padding: 1rem; color: #64748b; font-size: 0.85rem; border-top: 1px solid #e2e8f0;">
2060
- Bilingual summaries (English & zh-TW) • Powered by <strong>llama-cpp-python</strong> • Running on <strong>HuggingFace Spaces Free Tier</strong><br>
2061
  Traditional Chinese conversion via <strong>OpenCC</strong>
2062
  </div>
2063
  """)
 
1348
  # Custom CSS for better UI
1349
  custom_css = """
1350
  :root {
1351
+ --primary-color: #667eea;
1352
+ --primary-dark: #5a67d8;
1353
+ --primary-light: #a3bffa;
1354
+ --accent-color: #764ba2;
1355
  --bg-color: #f8fafc;
1356
  --card-bg: #ffffff;
1357
  --text-color: #1e293b;
1358
+ --text-muted: #64748b;
1359
  --border-color: #e2e8f0;
1360
+ --border-light: #f1f5f9;
1361
+ --success-bg: #f0fdf4;
1362
+ --success-border: #86efac;
1363
+ --warning-bg: #fef3c7;
1364
+ --warning-border: #fbbf24;
1365
+ --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
1366
+ --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
1367
+ --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
1368
+ --radius-sm: 6px;
1369
+ --radius-md: 8px;
1370
+ --radius-lg: 12px;
1371
  }
1372
 
1373
+ /* ===== LAYOUT & BASE ===== */
1374
+ .gradio-container {
1375
+ max-width: 1400px !important;
1376
+ }
1377
+
1378
+ /* ===== HEADER ===== */
1379
  .app-header {
1380
  text-align: center;
1381
+ padding: 2rem 1.5rem;
1382
+ background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
1383
+ border-radius: var(--radius-lg);
1384
+ margin-bottom: 1.5rem;
1385
  color: white;
1386
+ box-shadow: var(--shadow-lg);
1387
  }
1388
 
1389
  .app-header h1 {
1390
  margin: 0 0 0.5rem 0;
1391
+ font-size: 2.25rem;
1392
  font-weight: 700;
1393
+ letter-spacing: -0.025em;
1394
  }
1395
 
1396
  .app-header p {
1397
  margin: 0;
1398
  opacity: 0.9;
1399
+ font-size: 1.1rem;
1400
  }
1401
 
1402
  .model-badge {
1403
  display: inline-flex;
1404
  align-items: center;
1405
  gap: 0.5rem;
1406
+ background: rgba(255, 255, 255, 0.2);
1407
  padding: 0.5rem 1rem;
1408
  border-radius: 20px;
1409
  font-size: 0.85rem;
1410
  margin-top: 1rem;
1411
+ backdrop-filter: blur(4px);
1412
+ }
1413
+
1414
+ /* ===== INSTRUCTIONS ===== */
1415
+ .instructions {
1416
+ background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
1417
+ border-left: 4px solid var(--primary-color);
1418
+ padding: 1rem 1.25rem;
1419
+ border-radius: 0 var(--radius-md) var(--radius-md) 0;
1420
+ margin-bottom: 1.5rem;
1421
+ box-shadow: var(--shadow-sm);
1422
+ }
1423
+
1424
+ .instructions ul {
1425
+ margin: 0.5rem 0 0 0;
1426
+ padding-left: 1.25rem;
1427
  }
1428
 
1429
+ .instructions li {
1430
+ margin-bottom: 0.35rem;
1431
+ color: var(--text-color);
1432
+ }
1433
+
1434
+ /* ===== SECTION HEADERS ===== */
1435
  .section-header {
1436
+ font-size: 1rem;
1437
  font-weight: 600;
1438
  color: var(--text-color);
1439
  margin-bottom: 0.75rem;
1440
  display: flex;
1441
  align-items: center;
1442
  gap: 0.5rem;
1443
+ padding-bottom: 0.5rem;
1444
+ border-bottom: 1px solid var(--border-light);
1445
  }
1446
 
1447
  .section-icon {
1448
+ font-size: 1.1rem;
1449
  }
1450
 
1451
+ /* ===== TABS STYLING ===== */
1452
+ .gradio-tabs {
1453
+ border: 1px solid var(--border-color) !important;
1454
+ border-radius: var(--radius-lg) !important;
1455
+ overflow: hidden;
1456
+ box-shadow: var(--shadow-sm);
1457
+ margin-bottom: 1rem;
1458
  }
1459
 
1460
+ .gradio-tabitem {
1461
+ padding: 1rem !important;
1462
+ background: var(--card-bg) !important;
1463
  }
1464
 
1465
+ .tab-nav {
1466
+ background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
1467
+ border-bottom: 1px solid var(--border-color) !important;
1468
+ padding: 0 !important;
1469
+ gap: 0 !important;
1470
  }
1471
 
1472
+ .tab-nav button {
1473
+ padding: 0.875rem 1.25rem !important;
1474
+ font-weight: 500 !important;
1475
+ color: var(--text-muted) !important;
1476
+ border: none !important;
1477
+ border-bottom: 3px solid transparent !important;
1478
+ background: transparent !important;
1479
+ transition: all 0.2s ease !important;
1480
+ margin: 0 !important;
1481
+ border-radius: 0 !important;
1482
  }
1483
 
1484
+ .tab-nav button:hover {
1485
+ color: var(--primary-color) !important;
1486
+ background: rgba(102, 126, 234, 0.05) !important;
 
 
 
 
 
1487
  }
1488
 
1489
+ .tab-nav button.selected {
1490
+ color: var(--primary-color) !important;
1491
+ border-bottom-color: var(--primary-color) !important;
1492
+ background: var(--card-bg) !important;
1493
+ font-weight: 600 !important;
1494
+ }
1495
+
1496
+ /* ===== GROUPS & CARDS ===== */
1497
+ .gradio-group {
1498
+ border: 1px solid var(--border-color) !important;
1499
+ border-radius: var(--radius-md) !important;
1500
+ padding: 1rem !important;
1501
+ background: var(--card-bg) !important;
1502
+ box-shadow: var(--shadow-sm) !important;
1503
+ margin-bottom: 1rem !important;
1504
+ }
1505
+
1506
+ /* ===== ACCORDION STYLING ===== */
1507
+ .gradio-accordion {
1508
+ border: 1px solid var(--border-color) !important;
1509
+ border-radius: var(--radius-md) !important;
1510
+ overflow: hidden;
1511
+ box-shadow: var(--shadow-sm);
1512
+ margin-bottom: 1rem;
1513
+ }
1514
+
1515
+ .gradio-accordion > .label-wrap {
1516
+ background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
1517
+ padding: 0.875rem 1rem !important;
1518
+ border-bottom: 1px solid var(--border-color);
1519
+ }
1520
+
1521
+ .gradio-accordion > .label-wrap:hover {
1522
+ background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%) !important;
1523
+ }
1524
+
1525
+ .gradio-accordion > .label-wrap span {
1526
+ font-weight: 600 !important;
1527
+ color: var(--text-color) !important;
1528
+ }
1529
+
1530
+ .gradio-accordion > div:last-child {
1531
+ padding: 1rem !important;
1532
+ background: var(--card-bg) !important;
1533
  }
1534
 
1535
+ /* ===== BUTTONS ===== */
1536
+ /* Primary submit button */
1537
  .submit-btn {
1538
+ background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%) !important;
1539
  border: none !important;
1540
  color: white !important;
1541
  font-weight: 600 !important;
1542
+ padding: 0.875rem 2rem !important;
1543
+ border-radius: var(--radius-md) !important;
1544
  cursor: pointer;
1545
+ transition: all 0.2s ease !important;
1546
+ box-shadow: var(--shadow-md) !important;
1547
+ width: 100% !important;
1548
+ font-size: 1rem !important;
1549
  }
1550
 
1551
  .submit-btn:hover {
1552
  transform: translateY(-2px);
1553
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
1554
+ }
1555
+
1556
+ .submit-btn:active {
1557
+ transform: translateY(0);
1558
  }
1559
 
1560
+ /* Secondary buttons (Copy, Download, Load) */
1561
+ button.secondary,
1562
+ button[size="sm"] {
1563
+ background: var(--card-bg) !important;
1564
+ border: 1px solid var(--border-color) !important;
1565
+ color: var(--text-color) !important;
1566
+ font-weight: 500 !important;
1567
+ padding: 0.5rem 1rem !important;
1568
+ border-radius: var(--radius-sm) !important;
1569
+ transition: all 0.2s ease !important;
1570
+ box-shadow: var(--shadow-sm) !important;
1571
  }
1572
 
1573
+ button.secondary:hover,
1574
+ button[size="sm"]:hover {
1575
+ background: var(--bg-color) !important;
1576
+ border-color: var(--primary-color) !important;
1577
+ color: var(--primary-color) !important;
1578
+ box-shadow: var(--shadow-md) !important;
1579
+ }
1580
+
1581
+ /* Small primary buttons (Load Model) */
1582
+ button.primary[size="sm"] {
1583
+ background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%) !important;
1584
+ border: none !important;
1585
+ color: white !important;
1586
+ font-weight: 600 !important;
1587
+ }
1588
+
1589
+ button.primary[size="sm"]:hover {
1590
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4) !important;
1591
+ color: white !important;
1592
+ }
1593
+
1594
+ /* ===== INPUT COMPONENTS ===== */
1595
+ /* File upload area */
1596
  .file-upload-area {
1597
+ border: 2px dashed var(--border-color) !important;
1598
+ border-radius: var(--radius-lg) !important;
1599
+ padding: 1.5rem !important;
1600
  text-align: center;
1601
+ transition: all 0.3s ease !important;
1602
+ background: var(--bg-color) !important;
1603
  }
1604
 
1605
  .file-upload-area:hover {
1606
+ border-color: var(--primary-color) !important;
1607
+ background: rgba(102, 126, 234, 0.05) !important;
1608
+ }
1609
+
1610
+ /* Dropdowns */
1611
+ .gradio-dropdown {
1612
+ border-radius: var(--radius-sm) !important;
1613
+ }
1614
+
1615
+ .gradio-dropdown > div > input {
1616
+ border-radius: var(--radius-sm) !important;
1617
  }
1618
 
1619
+ /* Sliders */
1620
+ input[type="range"] {
1621
+ accent-color: var(--primary-color);
1622
+ }
1623
+
1624
+ /* ===== OUTPUT BOXES ===== */
1625
+ .thinking-box {
1626
+ background: var(--warning-bg) !important;
1627
+ border: 1px solid var(--warning-border) !important;
1628
+ border-radius: var(--radius-md) !important;
1629
+ font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace !important;
1630
+ font-size: 0.875rem !important;
1631
+ }
1632
+
1633
+ .thinking-box textarea {
1634
+ background: transparent !important;
1635
+ border: none !important;
1636
+ }
1637
+
1638
+ .summary-box {
1639
+ background: var(--success-bg) !important;
1640
+ border: 1px solid var(--success-border) !important;
1641
+ border-radius: var(--radius-md) !important;
1642
+ padding: 1rem !important;
1643
+ }
1644
+
1645
+ /* ===== MODEL INFO GRID ===== */
1646
  .stats-grid {
1647
+ font-size: 0.9rem;
 
 
 
1648
  }
1649
 
1650
+ .stats-grid table {
1651
+ width: 100%;
1652
+ border-collapse: collapse;
 
 
 
1653
  }
1654
 
1655
+ .stats-grid th {
1656
+ text-align: left;
1657
+ padding: 0.5rem;
1658
+ background: var(--bg-color);
1659
+ font-weight: 600;
1660
+ color: var(--text-muted);
1661
+ font-size: 0.8rem;
1662
+ text-transform: uppercase;
1663
+ letter-spacing: 0.025em;
1664
+ }
1665
+
1666
+ .stats-grid td {
1667
+ padding: 0.5rem;
1668
+ border-bottom: 1px solid var(--border-light);
1669
  }
1670
 
1671
+ /* ===== FOOTER ===== */
1672
+ .footer {
1673
+ text-align: center;
1674
+ margin-top: 2rem;
1675
+ padding: 1.25rem;
1676
+ color: var(--text-muted);
1677
  font-size: 0.85rem;
1678
+ border-top: 1px solid var(--border-color);
1679
+ background: linear-gradient(180deg, var(--bg-color) 0%, #f1f5f9 100%);
1680
+ border-radius: 0 0 var(--radius-lg) var(--radius-lg);
1681
+ }
1682
+
1683
+ /* ===== RESPONSIVE ADJUSTMENTS ===== */
1684
+ @media (max-width: 768px) {
1685
+ .app-header h1 {
1686
+ font-size: 1.75rem;
1687
+ }
1688
+
1689
+ .app-header p {
1690
+ font-size: 1rem;
1691
+ }
1692
+
1693
+ .submit-btn {
1694
+ padding: 0.75rem 1.5rem !important;
1695
+ }
1696
+ }
1697
+
1698
+ /* ===== FOCUS STATES (Accessibility) ===== */
1699
+ button:focus-visible,
1700
+ input:focus-visible,
1701
+ select:focus-visible,
1702
+ textarea:focus-visible {
1703
+ outline: 2px solid var(--primary-color) !important;
1704
+ outline-offset: 2px !important;
1705
+ }
1706
+
1707
+ /* ===== SCROLLBAR STYLING ===== */
1708
+ .thinking-box textarea::-webkit-scrollbar,
1709
+ .summary-box::-webkit-scrollbar {
1710
+ width: 8px;
1711
+ }
1712
+
1713
+ .thinking-box textarea::-webkit-scrollbar-track,
1714
+ .summary-box::-webkit-scrollbar-track {
1715
+ background: var(--border-light);
1716
+ border-radius: 4px;
1717
+ }
1718
+
1719
+ .thinking-box textarea::-webkit-scrollbar-thumb,
1720
+ .summary-box::-webkit-scrollbar-thumb {
1721
+ background: var(--border-color);
1722
+ border-radius: 4px;
1723
+ }
1724
+
1725
+ .thinking-box textarea::-webkit-scrollbar-thumb:hover,
1726
+ .summary-box::-webkit-scrollbar-thumb:hover {
1727
+ background: var(--text-muted);
1728
  }
1729
  """
1730
 
 
2277
 
2278
  # Footer
2279
  gr.HTML("""
2280
+ <div class="footer">
2281
+ Bilingual summaries (English &amp; zh-TW) • Powered by <strong>llama-cpp-python</strong> • Running on <strong>HuggingFace Spaces Free Tier</strong><br>
2282
  Traditional Chinese conversion via <strong>OpenCC</strong>
2283
  </div>
2284
  """)