Peymanasmari commited on
Commit
d5aa640
·
verified ·
1 Parent(s): 1a1b989

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -18
app.py CHANGED
@@ -1342,21 +1342,45 @@ html, body {
1342
  font-weight: 900 !important;
1343
  }
1344
 
1345
- /* Exact Input + Label file-control treatment from the supplied React example.
1346
- mx-auto max-w-xs space-y-2 -> centered, max-width 20rem (320px), 0.5rem spacing.
1347
- Neutral gray only: no gradient, cyan glow, dashed drop-zone treatment, or large upload card. */
1348
  .input-file-example {
1349
  width: 100% !important;
1350
- max-width: 20rem !important; /* Tailwind max-w-xs = 320px */
1351
- margin-left: auto !important;
1352
- margin-right: auto !important;
1353
- gap: 0.5rem !important; /* Tailwind space-y-2 */
1354
  padding: 0 !important;
 
 
 
 
 
 
1355
  background: transparent !important;
1356
  border: 0 !important;
1357
  box-shadow: none !important;
1358
  }
1359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1360
  .input-file-example .input-file-label {
1361
  display: block !important;
1362
  margin: 0 !important;
@@ -1364,13 +1388,12 @@ html, body {
1364
  font-size: 0.875rem !important;
1365
  line-height: 1.25rem !important;
1366
  font-weight: 500 !important;
 
1367
  }
1368
 
1369
- /* Gradio component shell: make it behave visually like <Input type="file" className="mt-2" />. */
1370
  .input-file-control {
1371
- width: 100% !important;
1372
- min-width: 0 !important;
1373
- margin-top: 0.5rem !important; /* mt-2 */
1374
  padding: 0 !important;
1375
  background: transparent !important;
1376
  border: 0 !important;
@@ -1482,11 +1505,12 @@ html, body {
1482
  }
1483
 
1484
  .input-file-example .input-file-help {
1485
- margin: 0.5rem 0 0 0 !important; /* mt-2 */
1486
- color: #6b7280 !important; /* text-gray-500 / dark:text-gray-500 */
1487
- font-size: 0.75rem !important; /* text-xs */
1488
  line-height: 1rem !important;
1489
  font-weight: 400 !important;
 
1490
  }
1491
 
1492
  .gradio-container table,
@@ -1666,9 +1690,12 @@ except Exception:
1666
  HORT_THEME = None
1667
 
1668
  def make_exact_file_input():
1669
- """Render the supplied React InputFileExample visual using a functional Gradio File input."""
1670
- with gr.Column(elem_classes=["input-file-example"]):
1671
- gr.HTML('<label class="input-file-label">Upload a file</label>')
 
 
 
1672
  file_component = gr.File(
1673
  label="Upload a file",
1674
  show_label=False,
@@ -1676,7 +1703,10 @@ def make_exact_file_input():
1676
  height=36,
1677
  elem_classes=["input-file-control"]
1678
  )
1679
- gr.HTML('<p class="input-file-help">You are only allowed to upload .CSV, .XLSX or .XLS files.</p>')
 
 
 
1680
  return file_component
1681
 
1682
 
 
1342
  font-weight: 900 !important;
1343
  }
1344
 
1345
+ /* File input laid out as one horizontal row:
1346
+ label | compact file picker | helper text. */
 
1347
  .input-file-example {
1348
  width: 100% !important;
1349
+ max-width: none !important;
1350
+ margin: 0 !important;
 
 
1351
  padding: 0 !important;
1352
+ display: flex !important;
1353
+ flex-direction: row !important;
1354
+ align-items: center !important;
1355
+ justify-content: flex-start !important;
1356
+ flex-wrap: nowrap !important;
1357
+ gap: 0.75rem !important;
1358
  background: transparent !important;
1359
  border: 0 !important;
1360
  box-shadow: none !important;
1361
  }
1362
 
1363
+ /* Keep Gradio's child wrappers from stretching each item onto its own line. */
1364
+ .input-file-example > * {
1365
+ margin: 0 !important;
1366
+ }
1367
+ .input-file-example .input-file-label-wrap {
1368
+ flex: 0 0 auto !important;
1369
+ width: auto !important;
1370
+ min-width: max-content !important;
1371
+ }
1372
+ .input-file-example .input-file-control {
1373
+ flex: 0 0 20rem !important;
1374
+ width: 20rem !important;
1375
+ max-width: 20rem !important;
1376
+ min-width: 16rem !important;
1377
+ }
1378
+ .input-file-example .input-file-help-wrap {
1379
+ flex: 1 1 auto !important;
1380
+ width: auto !important;
1381
+ min-width: 0 !important;
1382
+ }
1383
+
1384
  .input-file-example .input-file-label {
1385
  display: block !important;
1386
  margin: 0 !important;
 
1388
  font-size: 0.875rem !important;
1389
  line-height: 1.25rem !important;
1390
  font-weight: 500 !important;
1391
+ white-space: nowrap !important;
1392
  }
1393
 
1394
+ /* Gradio component shell: compact native-style file field. */
1395
  .input-file-control {
1396
+ margin: 0 !important;
 
 
1397
  padding: 0 !important;
1398
  background: transparent !important;
1399
  border: 0 !important;
 
1505
  }
1506
 
1507
  .input-file-example .input-file-help {
1508
+ margin: 0 !important;
1509
+ color: #6b7280 !important;
1510
+ font-size: 0.75rem !important;
1511
  line-height: 1rem !important;
1512
  font-weight: 400 !important;
1513
+ white-space: nowrap !important;
1514
  }
1515
 
1516
  .gradio-container table,
 
1690
  HORT_THEME = None
1691
 
1692
  def make_exact_file_input():
1693
+ """Render label, file picker, and helper text on one horizontal line."""
1694
+ with gr.Row(elem_classes=["input-file-example"]):
1695
+ gr.HTML(
1696
+ '<label class="input-file-label">Upload a file</label>',
1697
+ elem_classes=["input-file-label-wrap"]
1698
+ )
1699
  file_component = gr.File(
1700
  label="Upload a file",
1701
  show_label=False,
 
1703
  height=36,
1704
  elem_classes=["input-file-control"]
1705
  )
1706
+ gr.HTML(
1707
+ '<p class="input-file-help">You are only allowed to upload .CSV, .XLSX or .XLS files.</p>',
1708
+ elem_classes=["input-file-help-wrap"]
1709
+ )
1710
  return file_component
1711
 
1712