Spaces:
Running
fix(ui): make the columns work, flatten the categories card, align tabs
Browse filesThe Generate tab was a single 704px stack with one card 4225px tall, and
buttons sat at mismatched heights. Four separate causes, all found by
measuring the live DOM rather than reading the CSS.
1. Category grid never applied. Gradio wraps gr.Column children in a
div.form, so `.whyx-cat-grid` had exactly one child and the 28 checkboxes
were never grid items -- they stacked as 28 full-width rows. The grid is
now declared on `.whyx-cat-grid > .form`. The card went 4225px -> 992px
and cells became a uniform 107px (they were ragged 126-179px, because each
one rendered its full `info` description).
2. Descriptions clamped to two lines with an ellipsis, which is what actually
keeps the cells equal height. Field help text also got one shared
line-height and colour, so it stops reading as a different kind of text
from the panel notes above it.
3. Gradio caps its own `.main.fillable` at 768px. Setting max-width on
`.gradio-container` alone did nothing, because the inner cap won -- so the
"multi-column cockpit" collapsed to one column on every desktop. Raised to
1240px; the Tagger's two columns now sit side by side (422px each) instead
of stacking, and the Generate page dropped 8136px -> 4693px overall.
4. `.tabs button` matched every button in the app, since all components are
nested somewhere inside `.tabs`; it was restyling accordions, slide
triggers and the action bar and leaving them at 34/35/38px. Scoped to
`.tabs .tab-container:not(.visually-hidden) > button` with a fixed height.
The `gap: 6px` there was also dead -- .tabs is a block box, so gap did
nothing until the container was made flex.
Tests pin each of these; the grid one in particular is invisible to review,
because the rule is present and looks correct.
552 passed / 2 skipped, ruff clean, HTTP 200, measured in-browser.
- src/ui/studio.css +53 -6
- tests/test_ui_assets.py +49 -0
|
@@ -11,6 +11,10 @@ body::before {
|
|
| 11 |
radial-gradient(800px 480px at 92% 10%, var(--glow-2), transparent 60%);
|
| 12 |
}
|
| 13 |
.gradio-container { position: relative; z-index: 1; max-width: 1280px !important; margin: 0 auto !important; padding: 16px 20px 48px !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
:focus-visible { outline: 2px solid var(--accent) !important; outline-offset: 2px !important; }
|
| 15 |
*::-webkit-scrollbar { width: 6px; height: 6px; }
|
| 16 |
*::-webkit-scrollbar-track { background: transparent; }
|
|
@@ -247,11 +251,29 @@ input[type="radio"], input[type="checkbox"] { accent-color: var(--accent) !impor
|
|
| 247 |
}
|
| 248 |
.whyx-chip-group { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; }
|
| 249 |
|
| 250 |
-
/* ---------- categories grid ----------
|
|
|
|
|
|
|
|
|
|
| 251 |
.whyx-cat-search { margin-bottom: 4px !important; }
|
| 252 |
.whyx-cat-search input { border-radius: var(--pill) !important; font-size: 12px !important; }
|
| 253 |
-
.whyx-cat-grid {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
.whyx-cat-btn { margin: 0 !important; min-width: 0 !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
.whyx-cat-btn label {
|
| 256 |
display: flex !important; align-items: center !important; justify-content: center !important; gap: 5px !important;
|
| 257 |
background: var(--surface-2) !important; border: 1px solid var(--panel-border) !important;
|
|
@@ -324,6 +346,14 @@ input[type="radio"], input[type="checkbox"] { accent-color: var(--accent) !impor
|
|
| 324 |
border-left: 2px solid var(--chip-border) !important; background: var(--surface-2) !important;
|
| 325 |
padding: 7px 12px !important; border-radius: 0 var(--r-sm) var(--r-sm) 0 !important; margin-top: 8px !important;
|
| 326 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
.whyx-suggest-box { padding: 12px 16px !important; }
|
| 328 |
.whyx-suggest-title { font-size: 12.5px !important; font-weight: 700 !important; color: var(--text) !important; margin-bottom: 8px !important; }
|
| 329 |
.whyx-suggest-box ul { margin: 0 !important; padding-left: 18px !important; }
|
|
@@ -338,10 +368,27 @@ input[type="radio"], input[type="checkbox"] { accent-color: var(--accent) !impor
|
|
| 338 |
}
|
| 339 |
.whyx-tooltip:hover .whyx-tooltip-text { visibility: visible !important; opacity: 1 !important; }
|
| 340 |
|
| 341 |
-
/* ---------- tabs ----------
|
| 342 |
-
.tabs
|
| 343 |
-
.tabs
|
| 344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
.tabitem { border: none !important; padding: 4px 0 0 !important; }
|
| 346 |
|
| 347 |
/* ---------- tagger ---------- */
|
|
|
|
| 11 |
radial-gradient(800px 480px at 92% 10%, var(--glow-2), transparent 60%);
|
| 12 |
}
|
| 13 |
.gradio-container { position: relative; z-index: 1; max-width: 1280px !important; margin: 0 auto !important; padding: 16px 20px 48px !important; }
|
| 14 |
+
/* Gradio caps its own .main.fillable at 768px, which made the multi-column
|
| 15 |
+
cockpit collapse into a single 704px stack on any desktop. Raise it so the
|
| 16 |
+
grid rules below actually have room to lay out side by side. */
|
| 17 |
+
.main.fillable, .main.fillable > .wrap { max-width: 1240px !important; margin-left: auto !important; margin-right: auto !important; }
|
| 18 |
:focus-visible { outline: 2px solid var(--accent) !important; outline-offset: 2px !important; }
|
| 19 |
*::-webkit-scrollbar { width: 6px; height: 6px; }
|
| 20 |
*::-webkit-scrollbar-track { background: transparent; }
|
|
|
|
| 251 |
}
|
| 252 |
.whyx-chip-group { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; }
|
| 253 |
|
| 254 |
+
/* ---------- categories grid ----------
|
| 255 |
+
Gradio wraps every gr.Column's children in a div.form, so the grid must be
|
| 256 |
+
applied to that inner form. Targeting .whyx-cat-grid itself does nothing:
|
| 257 |
+
it has a single child, and the 28 checkboxes were stacking as 28 rows. */
|
| 258 |
.whyx-cat-search { margin-bottom: 4px !important; }
|
| 259 |
.whyx-cat-search input { border-radius: var(--pill) !important; font-size: 12px !important; }
|
| 260 |
+
.whyx-cat-grid { margin-top: 10px !important; }
|
| 261 |
+
.whyx-cat-grid > .form {
|
| 262 |
+
display: grid !important;
|
| 263 |
+
grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)) !important;
|
| 264 |
+
gap: 8px !important; align-items: stretch !important;
|
| 265 |
+
}
|
| 266 |
.whyx-cat-btn { margin: 0 !important; min-width: 0 !important; }
|
| 267 |
+
/* Clamp the per-category description: unclamped it made each pill 126-179px
|
| 268 |
+
tall and pushed the card past 4200px. Two lines, then an ellipsis. */
|
| 269 |
+
.whyx-cat-btn .info-text, .whyx-cat-btn .info {
|
| 270 |
+
display: -webkit-box !important; -webkit-box-orient: vertical !important;
|
| 271 |
+
-webkit-line-clamp: 2 !important; line-clamp: 2 !important; overflow: hidden !important;
|
| 272 |
+
font-size: 10.5px !important; line-height: 1.35 !important; color: var(--faint) !important;
|
| 273 |
+
text-align: center !important; margin-top: 3px !important; padding: 0 2px !important;
|
| 274 |
+
border: none !important; background: none !important;
|
| 275 |
+
}
|
| 276 |
+
.whyx-cat-btn:has(input:checked) .info-text { color: var(--muted) !important; }
|
| 277 |
.whyx-cat-btn label {
|
| 278 |
display: flex !important; align-items: center !important; justify-content: center !important; gap: 5px !important;
|
| 279 |
background: var(--surface-2) !important; border: 1px solid var(--panel-border) !important;
|
|
|
|
| 346 |
border-left: 2px solid var(--chip-border) !important; background: var(--surface-2) !important;
|
| 347 |
padding: 7px 12px !important; border-radius: 0 var(--r-sm) var(--r-sm) 0 !important; margin-top: 8px !important;
|
| 348 |
}
|
| 349 |
+
/* Per-field help text. Gradio renders it in its own colour/size, which made
|
| 350 |
+
field descriptions read as a different kind of text from the panel notes
|
| 351 |
+
above them. One line-height and colour for all of them. */
|
| 352 |
+
.gradio-container label + .info, .gradio-container .info:not(.whyx-info-text) {
|
| 353 |
+
color: var(--muted) !important; font-size: 11px !important; line-height: 1.45 !important;
|
| 354 |
+
text-align: left !important; margin-top: 4px !important; padding: 0 2px !important;
|
| 355 |
+
background: none !important; border: none !important;
|
| 356 |
+
}
|
| 357 |
.whyx-suggest-box { padding: 12px 16px !important; }
|
| 358 |
.whyx-suggest-title { font-size: 12.5px !important; font-weight: 700 !important; color: var(--text) !important; margin-bottom: 8px !important; }
|
| 359 |
.whyx-suggest-box ul { margin: 0 !important; padding-left: 18px !important; }
|
|
|
|
| 368 |
}
|
| 369 |
.whyx-tooltip:hover .whyx-tooltip-text { visibility: visible !important; opacity: 1 !important; }
|
| 370 |
|
| 371 |
+
/* ---------- tabs ----------
|
| 372 |
+
.tabs is a block box; the buttons live in an inner .tab-container. Setting
|
| 373 |
+
`gap` on .tabs did nothing (gap needs flex/grid), which is why the tab row
|
| 374 |
+
came out cramped.
|
| 375 |
+
The button rule is scoped to that container on purpose: every component in
|
| 376 |
+
the app is nested somewhere inside .tabs, so a bare `.tabs button` also hit
|
| 377 |
+
accordions, slide triggers and the action bar and left them at mismatched
|
| 378 |
+
heights. The visually-hidden container is an a11y duplicate of the same
|
| 379 |
+
buttons and is excluded so only the real row is styled. */
|
| 380 |
+
.tabs { border-bottom: 1px solid var(--line-soft) !important; padding-bottom: 8px !important; margin-bottom: 4px !important; }
|
| 381 |
+
.tabs .tab-container { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; align-items: center !important; }
|
| 382 |
+
.tabs .tab-container:not(.visually-hidden) > button {
|
| 383 |
+
display: inline-flex !important; align-items: center !important; justify-content: center !important;
|
| 384 |
+
height: 34px !important; min-height: 34px !important; box-sizing: border-box !important;
|
| 385 |
+
border-radius: var(--pill) !important; padding: 0 18px !important;
|
| 386 |
+
font-size: 12.5px !important; font-weight: 600 !important; line-height: 1 !important;
|
| 387 |
+
border: 1px solid transparent !important; background: transparent !important;
|
| 388 |
+
color: var(--muted) !important; white-space: nowrap !important;
|
| 389 |
+
}
|
| 390 |
+
.tabs .tab-container:not(.visually-hidden) > button:hover { color: var(--text) !important; background: var(--surface-2) !important; }
|
| 391 |
+
.tabs .tab-container:not(.visually-hidden) > button.selected { background: var(--accent-soft) !important; border-color: var(--chip-border) !important; color: var(--chip-ink) !important; }
|
| 392 |
.tabitem { border: none !important; padding: 4px 0 0 !important; }
|
| 393 |
|
| 394 |
/* ---------- tagger ---------- */
|
|
@@ -330,6 +330,55 @@ def test_header_and_action_bar_are_each_styled_once():
|
|
| 330 |
assert expected_z in body, f"{selector} lost its {expected_z}"
|
| 331 |
|
| 332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
def test_responsive_block_survives_the_rewrite():
|
| 334 |
"""The desktop-only rules must not leak into small viewports."""
|
| 335 |
css = _STUDIO_CSS.read_text(encoding="utf-8")
|
|
|
|
| 330 |
assert expected_z in body, f"{selector} lost its {expected_z}"
|
| 331 |
|
| 332 |
|
| 333 |
+
def test_category_grid_targets_gradios_inner_form():
|
| 334 |
+
"""Gradio wraps gr.Column children in a div.form.
|
| 335 |
+
|
| 336 |
+
Styling `.whyx-cat-grid` itself therefore did nothing: it has exactly one
|
| 337 |
+
child, so the 28 category checkboxes were never grid items and stacked as
|
| 338 |
+
28 full-width rows -- the Enhancement Categories card rendered 4225px tall
|
| 339 |
+
instead of ~990px. The grid must be declared on the inner form.
|
| 340 |
+
"""
|
| 341 |
+
css = _STUDIO_CSS.read_text(encoding="utf-8")
|
| 342 |
+
assert ".whyx-cat-grid > .form" in css, "category grid is not applied to the .form wrapper"
|
| 343 |
+
grid_rule = css.split(".whyx-cat-grid > .form {", 1)[1].split("}", 1)[0]
|
| 344 |
+
assert "display: grid" in grid_rule
|
| 345 |
+
assert "grid-template-columns: repeat(auto-fill" in grid_rule
|
| 346 |
+
assert "align-items: stretch" in grid_rule, "cells will have ragged heights"
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
def test_category_descriptions_are_clamped():
|
| 350 |
+
"""Unclamped descriptions made every pill 126-179px tall."""
|
| 351 |
+
bodies = _rule_bodies(_STUDIO_CSS.read_text(encoding="utf-8"), ".whyx-cat-btn .info-text")
|
| 352 |
+
assert bodies, "no rule styles the per-category description"
|
| 353 |
+
body = bodies[0]
|
| 354 |
+
assert "-webkit-line-clamp: 2" in body, "category descriptions are not clamped"
|
| 355 |
+
assert "overflow: hidden" in body, "clamped text will spill out of the pill"
|
| 356 |
+
assert "line-height" in body, "clamped text needs a tight line-height to stay 2 lines"
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
def test_tab_button_rules_are_scoped_to_the_tab_bar():
|
| 360 |
+
"""A bare `.tabs button` also matched every button in the app.
|
| 361 |
+
|
| 362 |
+
Every component is nested somewhere inside .tabs, so the unscoped rule
|
| 363 |
+
restyled accordions, slide triggers and the action bar too and left them
|
| 364 |
+
at mismatched heights (34/35/38px). The rule must target the real tab row
|
| 365 |
+
and skip the visually-hidden a11y duplicate.
|
| 366 |
+
"""
|
| 367 |
+
css = _STUDIO_CSS.read_text(encoding="utf-8")
|
| 368 |
+
assert ".tabs .tab-container:not(.visually-hidden) > button" in css
|
| 369 |
+
for line in css.splitlines():
|
| 370 |
+
sel = line.split("{")[0].strip()
|
| 371 |
+
if sel.endswith("button") and sel.startswith(".tabs"):
|
| 372 |
+
assert ".tab-container" in sel, f"unscoped tab button rule: {sel!r}"
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
def test_app_max_width_is_raised_above_gradios_cap():
|
| 376 |
+
"""Gradio caps .main.fillable at 768px, collapsing the cockpit to one column."""
|
| 377 |
+
css = _STUDIO_CSS.read_text(encoding="utf-8")
|
| 378 |
+
assert ".main.fillable" in css, "Gradio's 768px cap is still in force"
|
| 379 |
+
assert "max-width: 1240px" in css
|
| 380 |
+
|
| 381 |
+
|
| 382 |
def test_responsive_block_survives_the_rewrite():
|
| 383 |
"""The desktop-only rules must not leak into small viewports."""
|
| 384 |
css = _STUDIO_CSS.read_text(encoding="utf-8")
|