mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-24 17:06:18 -05:00
ui: a downloads table wider than the phone showing it (#660)
The two downloads tables came out 676px and 727px in a 540px window, so Completed At and
Control sat off the right edge and their buttons could not be reached without scrolling
sideways.
`.table-ellipsis` was trying to truncate under `table-layout: auto`, where a table is as
wide as its columns want to be and the container simply overflows. The rule leaned on
`max-width: 0` to force an ellipsis and `min-width: 25em` to keep the text column readable
-- but 25em is 385px, and a floor wider than the screen makes the overflow certain.
Fixed layout inverts it: the columns divide the table's width and the column marked
`column-ellipsis` gives up what it cannot show. Neither the max-width trick nor the floor
is needed then. Columns that must fit something exact -- a checkbox, a group of buttons --
state a width; the rest is the truncating column's.
`table.table-ellipsis`, not the bare class: Mantine sets `table-layout` on its own
`.mantine-Table-table`, the same specificity and later in the cascade, so the first version
of this lost silently. Every other property in the rule applied, which made the table look
fixed while it stayed auto -- the recurring table got *wider* than before, not narrower.
Three things the rework then had to answer for, each of them measured in the browser:
* A header overran its column: "Completed At" printed on top of "Control", because
`.wrolpi-th-sort` is nowrap so a label never splits from its arrow. It wraps here, and
needs `min-width: 0` as well -- the label is an anonymous flex item whose automatic
minimum is its longest word, so without it the label still refuses to go below
"Completed" and still overruns.
* A grouped button was squeezed: `ButtonGroup` is a nowrap flex row whose children shrink,
and the Stop button on a pending download came out 23px against its neighbour's 40 --
clipped, and too small to hit. The columns are sized for the widest group a row can
have, so the buttons no longer give.
* Status's Top Processes table had the same bug. It already asked for `.table-ellipsis`
and already marked its Command cell, so it overflowed a phone too (548px into 503px).
The same rule fixes it, with widths for the three short readings.
A wrapped header is the fallback, not the layout, so every column is sized to hold its own
label on one line -- including on a phone. "Download Frequency" is the exception at 11.7em,
which a phone cannot spare beside four other columns, so it takes a class that widens at the
tablet breakpoint and wraps below it.
Measured, nothing overflowing, no header overrun, no clipped cell, no shrunken button:
540px once 40 / 208 / 146 / 146 recurring 123 / 108 / 131 / 62 / 116
1400px once 40 / 1033 / 146 / 146 recurring 871 / 185 / 131 / 62 / 116
Desktop gains from it as well: the checkbox column drops from 90px to 40 and Completed At
from 291 to 146, so the URL column picks up about 255px.
Covered by five tests in the Cypress layout suite. None of this is checkable in jsdom --
it is all resolved widths, and the central question is whether our `table-layout` beats the
one Mantine sets, which is exactly the part that failed silently.
69 suites / 1214 jest tests pass.
This commit is contained in:
parent
ebdf9dcc4b
commit
0ae8bd5442
5 changed files with 283 additions and 16 deletions
|
|
@ -336,12 +336,94 @@ textarea.otp {
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
* A table that truncates to the width it has, rather than growing past it.
|
||||
*
|
||||
* `table-layout: fixed` is what makes the truncation possible at all. Under the default
|
||||
* `auto` layout a table is as wide as its columns want to be and the container simply
|
||||
* overflows -- on a 540px phone the downloads tables came out 676px and 727px, so Completed
|
||||
* At and Control sat off the right edge and the buttons could not be reached without
|
||||
* scrolling sideways. Fixed layout inverts that: the columns get the table's width divided
|
||||
* between them, and the one marked `column-ellipsis` gives up what it cannot show.
|
||||
*
|
||||
* The old rule tried to do this with `max-width: 0` and `min-width: 25em`. The max-width was
|
||||
* the usual trick for forcing an ellipsis under `auto` layout; the min-width was there so the
|
||||
* text column stayed readable -- but 25em is 385px, and a floor wider than the screen is what
|
||||
* made the overflow certain. Under fixed layout neither is needed: the column width comes
|
||||
* from the header, and every other column is sized to its content so the ellipsis column
|
||||
* keeps the remainder.
|
||||
*
|
||||
* Columns that must fit something exact -- a checkbox, a group of buttons -- state a width on
|
||||
* their header cell. Any column that does not is sized by what is left over.
|
||||
*/
|
||||
/*
|
||||
* `table.` rather than the class alone: Mantine sets `table-layout` on its own
|
||||
* `.mantine-Table-table`, which is the same specificity and comes later in the cascade, so
|
||||
* the bare class silently lost and the table stayed `auto` -- with every other property here
|
||||
* applying, which made it look like the rule had worked.
|
||||
*/
|
||||
table.table-ellipsis {
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.table-ellipsis td.column-ellipsis {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 0; /* Ensures the content doesn't exceed the cell's width */
|
||||
min-width: 25em; /* About iPhone SE width */
|
||||
}
|
||||
|
||||
/*
|
||||
* The one column width that has to change with the screen.
|
||||
*
|
||||
* Most headers here are sized to hold their own label on one line at any width -- a wrapped
|
||||
* label is a fallback, not a layout. "Download Frequency" is the exception: 11.7em on one
|
||||
* line, which a phone cannot spare when four other columns need room, and it is one of five
|
||||
* columns rather than one of four. So it wraps below the tablet breakpoint and gets its line
|
||||
* back above it, where the width costs nothing.
|
||||
*
|
||||
* 700px is the app's `tablet` breakpoint (see `AppMedia` in contexts.js).
|
||||
*/
|
||||
.table-ellipsis th.col-frequency {
|
||||
width: 7em;
|
||||
}
|
||||
|
||||
@media (min-width: 700px) {
|
||||
.table-ellipsis th.col-frequency {
|
||||
width: 12em;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A header wraps instead of running into the next column.
|
||||
*
|
||||
* `.wrolpi-th-sort` is `white-space: nowrap` so a sortable label never splits from its arrow.
|
||||
* That is right under `auto` layout, where the column widens to fit; under fixed layout the
|
||||
* column does not widen, so "Completed At" overran its cell and printed on top of "Control".
|
||||
* Wrapping to two lines is the only thing a fixed column can do with a label too long for it.
|
||||
*
|
||||
* `min-width: 0` as well as the wrap: the button is a flex container, and its text is an
|
||||
* anonymous flex item whose automatic minimum is its longest word. Without this the label
|
||||
* still refuses to go below "Completed" and still overruns. A column narrower than its
|
||||
* longest word is a width to fix at the call site, not something CSS can hide.
|
||||
*/
|
||||
.table-ellipsis th .wrolpi-th-sort {
|
||||
display: flex;
|
||||
white-space: normal;
|
||||
min-width: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/*
|
||||
* Grouped buttons keep their size in a fixed column.
|
||||
*
|
||||
* `ButtonGroup` is a nowrap flex row whose children may shrink, and in a column too narrow
|
||||
* for them they did: the Stop button on a pending download was squeezed to 23px against its
|
||||
* neighbour's 40px, a target too small to hit and visibly clipped. The column is sized for
|
||||
* the widest group it has to hold (three buttons), so the buttons themselves should not give.
|
||||
*/
|
||||
.table-ellipsis td .mantine-ButtonGroup-group > * {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-title-ellipsis {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue