Spaces:
Running
Running
Commit
·
f75a510
1
Parent(s):
43ebc64
Force desktop viewport on mobile browsers
Browse files
app.py
CHANGED
|
@@ -1281,236 +1281,17 @@ custom_css = """
|
|
| 1281 |
min-height: auto !important;
|
| 1282 |
}
|
| 1283 |
|
| 1284 |
-
/*
|
| 1285 |
@media screen and (max-width: 768px) {
|
| 1286 |
-
/*
|
| 1287 |
-
.gradio-container {
|
| 1288 |
-
|
| 1289 |
-
}
|
| 1290 |
-
|
| 1291 |
-
/* Stack columns vertically on mobile */
|
| 1292 |
-
.gradio-row {
|
| 1293 |
-
flex-direction: column !important;
|
| 1294 |
-
}
|
| 1295 |
-
|
| 1296 |
-
/* Full width columns on mobile */
|
| 1297 |
-
.gradio-column {
|
| 1298 |
-
width: 100% !important;
|
| 1299 |
-
max-width: 100% !important;
|
| 1300 |
-
flex: 1 1 100% !important;
|
| 1301 |
-
}
|
| 1302 |
-
|
| 1303 |
-
/* Force radio buttons to wrap on mobile */
|
| 1304 |
-
[data-testid="radio-group"], .gr-radio-group, .radio-group {
|
| 1305 |
-
flex-wrap: wrap !important;
|
| 1306 |
-
}
|
| 1307 |
-
|
| 1308 |
-
[data-testid="radio-group"] > *, .gr-radio-group > * {
|
| 1309 |
-
flex: 0 0 auto !important;
|
| 1310 |
-
}
|
| 1311 |
-
|
| 1312 |
-
/* Smaller task buttons on mobile */
|
| 1313 |
-
.task-btn {
|
| 1314 |
-
min-width: 100px !important;
|
| 1315 |
-
padding: 8px 12px !important;
|
| 1316 |
-
font-size: 13px !important;
|
| 1317 |
-
}
|
| 1318 |
-
|
| 1319 |
-
/* CRITICAL: Fix Safari file upload icon size */
|
| 1320 |
-
.file-upload svg, .upload-button svg, [data-testid="file"] svg,
|
| 1321 |
-
.gr-file svg, button svg, .upload svg {
|
| 1322 |
-
max-width: 48px !important;
|
| 1323 |
-
max-height: 48px !important;
|
| 1324 |
-
width: 48px !important;
|
| 1325 |
-
height: 48px !important;
|
| 1326 |
-
}
|
| 1327 |
-
|
| 1328 |
-
/* Compact file upload areas */
|
| 1329 |
-
.file-upload, .upload-button, [data-testid="file"], .gr-file {
|
| 1330 |
-
min-height: 80px !important;
|
| 1331 |
-
max-height: 120px !important;
|
| 1332 |
-
padding: 10px !important;
|
| 1333 |
-
}
|
| 1334 |
-
|
| 1335 |
-
/* Smaller upload button text */
|
| 1336 |
-
.upload-button span, .gr-file span, [data-testid="file"] span {
|
| 1337 |
-
font-size: 13px !important;
|
| 1338 |
-
}
|
| 1339 |
-
|
| 1340 |
-
/* Compact buttons */
|
| 1341 |
-
button {
|
| 1342 |
-
padding: 8px 14px !important;
|
| 1343 |
-
font-size: 14px !important;
|
| 1344 |
-
}
|
| 1345 |
-
|
| 1346 |
-
/* Smaller primary action button */
|
| 1347 |
-
button.primary, button.lg {
|
| 1348 |
-
padding: 10px 16px !important;
|
| 1349 |
-
font-size: 15px !important;
|
| 1350 |
-
}
|
| 1351 |
-
|
| 1352 |
-
/* Compact form inputs */
|
| 1353 |
-
input, textarea, select {
|
| 1354 |
-
padding: 8px !important;
|
| 1355 |
-
font-size: 14px !important;
|
| 1356 |
-
}
|
| 1357 |
-
|
| 1358 |
-
/* Reduce textbox heights */
|
| 1359 |
-
textarea {
|
| 1360 |
-
min-height: 60px !important;
|
| 1361 |
-
}
|
| 1362 |
-
|
| 1363 |
-
/* Smaller dropdown */
|
| 1364 |
-
.gr-dropdown {
|
| 1365 |
-
font-size: 14px !important;
|
| 1366 |
-
}
|
| 1367 |
-
|
| 1368 |
-
/* Compact radio buttons */
|
| 1369 |
-
.gr-radio, .gr-checkbox {
|
| 1370 |
-
gap: 6px !important;
|
| 1371 |
-
}
|
| 1372 |
-
|
| 1373 |
-
.gr-radio label, .gr-checkbox label {
|
| 1374 |
-
font-size: 13px !important;
|
| 1375 |
-
padding: 6px 10px !important;
|
| 1376 |
-
}
|
| 1377 |
-
|
| 1378 |
-
/* Smaller headings */
|
| 1379 |
-
h1 {
|
| 1380 |
-
font-size: 1.4rem !important;
|
| 1381 |
-
}
|
| 1382 |
-
|
| 1383 |
-
h2, h3 {
|
| 1384 |
-
font-size: 1.1rem !important;
|
| 1385 |
-
}
|
| 1386 |
-
|
| 1387 |
-
/* Compact markdown text */
|
| 1388 |
-
.prose, .gr-markdown {
|
| 1389 |
-
font-size: 14px !important;
|
| 1390 |
-
}
|
| 1391 |
-
|
| 1392 |
-
/* Compact accordion */
|
| 1393 |
-
.gr-accordion {
|
| 1394 |
-
padding: 8px !important;
|
| 1395 |
-
}
|
| 1396 |
-
|
| 1397 |
-
/* Smaller logo on mobile */
|
| 1398 |
-
img[alt="logo"], .gr-image img {
|
| 1399 |
-
height: 80px !important;
|
| 1400 |
-
max-height: 80px !important;
|
| 1401 |
-
}
|
| 1402 |
-
|
| 1403 |
-
/* Compact group containers */
|
| 1404 |
-
.gr-group {
|
| 1405 |
-
padding: 10px !important;
|
| 1406 |
-
gap: 8px !important;
|
| 1407 |
-
}
|
| 1408 |
-
|
| 1409 |
-
/* Reduce spacing between form elements */
|
| 1410 |
-
.gr-form > *, .gr-block > * {
|
| 1411 |
-
margin-bottom: 8px !important;
|
| 1412 |
-
}
|
| 1413 |
-
|
| 1414 |
-
/* Compact dataframe/table on mobile */
|
| 1415 |
-
.gr-dataframe, .dataframe {
|
| 1416 |
-
font-size: 12px !important;
|
| 1417 |
-
}
|
| 1418 |
-
|
| 1419 |
-
.gr-dataframe th, .gr-dataframe td {
|
| 1420 |
-
padding: 4px 6px !important;
|
| 1421 |
-
}
|
| 1422 |
-
|
| 1423 |
-
/* Make plot responsive */
|
| 1424 |
-
.gr-plot {
|
| 1425 |
-
max-width: 100% !important;
|
| 1426 |
-
overflow-x: auto !important;
|
| 1427 |
-
}
|
| 1428 |
-
|
| 1429 |
-
/* Compact download buttons */
|
| 1430 |
-
.gr-file-download, [data-testid="download"] {
|
| 1431 |
-
padding: 8px !important;
|
| 1432 |
-
}
|
| 1433 |
-
}
|
| 1434 |
-
|
| 1435 |
-
/* Extra small devices (phones in portrait) */
|
| 1436 |
-
@media screen and (max-width: 480px) {
|
| 1437 |
-
.gradio-container {
|
| 1438 |
-
padding: 4px !important;
|
| 1439 |
-
}
|
| 1440 |
-
|
| 1441 |
-
.task-btn {
|
| 1442 |
-
min-width: 80px !important;
|
| 1443 |
-
padding: 6px 10px !important;
|
| 1444 |
-
font-size: 12px !important;
|
| 1445 |
-
}
|
| 1446 |
-
|
| 1447 |
-
button {
|
| 1448 |
-
padding: 6px 12px !important;
|
| 1449 |
-
font-size: 13px !important;
|
| 1450 |
-
}
|
| 1451 |
-
|
| 1452 |
-
h1 {
|
| 1453 |
-
font-size: 1.2rem !important;
|
| 1454 |
-
}
|
| 1455 |
-
|
| 1456 |
-
h2, h3 {
|
| 1457 |
-
font-size: 1rem !important;
|
| 1458 |
-
}
|
| 1459 |
-
|
| 1460 |
-
.prose, .gr-markdown {
|
| 1461 |
-
font-size: 13px !important;
|
| 1462 |
-
}
|
| 1463 |
-
|
| 1464 |
-
img[alt="logo"], .gr-image img {
|
| 1465 |
-
height: 60px !important;
|
| 1466 |
-
max-height: 60px !important;
|
| 1467 |
-
}
|
| 1468 |
-
|
| 1469 |
-
/* Stack task buttons vertically on very small screens */
|
| 1470 |
-
.task-btn {
|
| 1471 |
-
width: 100% !important;
|
| 1472 |
-
min-width: unset !important;
|
| 1473 |
-
}
|
| 1474 |
-
|
| 1475 |
-
/* More aggressive SVG fix for Safari on small screens */
|
| 1476 |
-
svg {
|
| 1477 |
-
max-width: 40px !important;
|
| 1478 |
-
max-height: 40px !important;
|
| 1479 |
-
}
|
| 1480 |
-
|
| 1481 |
-
/* File upload button - limit the whole container */
|
| 1482 |
-
[data-testid="block"] button[aria-label*="Upload"],
|
| 1483 |
-
[data-testid="block"] button[aria-label*="upload"],
|
| 1484 |
-
.upload-button, .file-upload button {
|
| 1485 |
-
max-height: 100px !important;
|
| 1486 |
-
overflow: hidden !important;
|
| 1487 |
-
}
|
| 1488 |
-
|
| 1489 |
-
/* Force radio group to stack vertically */
|
| 1490 |
-
[data-testid="radio-group"] {
|
| 1491 |
-
flex-direction: column !important;
|
| 1492 |
-
align-items: flex-start !important;
|
| 1493 |
-
}
|
| 1494 |
-
|
| 1495 |
-
[data-testid="radio-group"] label {
|
| 1496 |
-
margin-bottom: 4px !important;
|
| 1497 |
}
|
| 1498 |
}
|
| 1499 |
"""
|
| 1500 |
|
| 1501 |
custom_js = """
|
| 1502 |
function() {
|
| 1503 |
-
// Force desktop viewport on mobile
|
| 1504 |
-
var viewport = document.querySelector('meta[name="viewport"]');
|
| 1505 |
-
if (viewport) {
|
| 1506 |
-
viewport.setAttribute('content', 'width=900, initial-scale=0.4, maximum-scale=2.0, user-scalable=yes');
|
| 1507 |
-
} else {
|
| 1508 |
-
var meta = document.createElement('meta');
|
| 1509 |
-
meta.name = 'viewport';
|
| 1510 |
-
meta.content = 'width=900, initial-scale=0.4, maximum-scale=2.0, user-scalable=yes';
|
| 1511 |
-
document.head.appendChild(meta);
|
| 1512 |
-
}
|
| 1513 |
-
|
| 1514 |
// Add click-to-expand functionality for the plot
|
| 1515 |
document.addEventListener('click', function(e) {
|
| 1516 |
const plot = e.target.closest('.expandable-plot');
|
|
@@ -1531,7 +1312,12 @@ function() {
|
|
| 1531 |
}
|
| 1532 |
"""
|
| 1533 |
|
| 1534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1535 |
gr.Image("logo.png", show_label=False, show_download_button=False, height=115, container=False)
|
| 1536 |
gr.Markdown("# CatLLM - Research Data Classifier")
|
| 1537 |
gr.Markdown("Extract categories from or classify text data, PDFs, and images using LLMs.")
|
|
|
|
| 1281 |
min-height: auto !important;
|
| 1282 |
}
|
| 1283 |
|
| 1284 |
+
/* Force desktop view on mobile - override any responsive behavior */
|
| 1285 |
@media screen and (max-width: 768px) {
|
| 1286 |
+
/* Keep everything at desktop size, let viewport scaling handle it */
|
| 1287 |
+
.gradio-container, .main, .wrap, .contain, .app {
|
| 1288 |
+
min-width: 900px !important;
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1289 |
}
|
| 1290 |
}
|
| 1291 |
"""
|
| 1292 |
|
| 1293 |
custom_js = """
|
| 1294 |
function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1295 |
// Add click-to-expand functionality for the plot
|
| 1296 |
document.addEventListener('click', function(e) {
|
| 1297 |
const plot = e.target.closest('.expandable-plot');
|
|
|
|
| 1312 |
}
|
| 1313 |
"""
|
| 1314 |
|
| 1315 |
+
# Force desktop viewport via HTML head injection (more reliable than JS)
|
| 1316 |
+
custom_head = """
|
| 1317 |
+
<meta name="viewport" content="width=1024, initial-scale=0.4, maximum-scale=3.0, user-scalable=yes">
|
| 1318 |
+
"""
|
| 1319 |
+
|
| 1320 |
+
with gr.Blocks(title="CatLLM - Research Data Classifier", theme=gr.themes.Soft(), css=custom_css, js=custom_js, head=custom_head) as demo:
|
| 1321 |
gr.Image("logo.png", show_label=False, show_download_button=False, height=115, container=False)
|
| 1322 |
gr.Markdown("# CatLLM - Research Data Classifier")
|
| 1323 |
gr.Markdown("Extract categories from or classify text data, PDFs, and images using LLMs.")
|