mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
ui: toasts move to the top right, get readable titles, and get tests
The title was unreadable in dark, night and amber. Mantine paints a dark-scheme notification title with `--mantine-color-white`, and the bridge aliases that to `--btn-text` -- deliberately, because it is the text drawn on a filled button, near-black in those three themes. So the title came out rgb(28, 31, 33) on a rgb(38, 41, 43) surface: about 1.1:1, present and invisible. Fixing the alias is not an option, it is correct for the buttons it exists for, so notifications now take their surface, border and text from our tokens instead. Measured after: 14.9, 11.9, 5.0 and 8.6 to one. The description follows the same route, and night and amber drop its muting. `--muted` on a panel is 2.0:1 in night and 3.1:1 in amber -- the description is the message itself, so those two let the title's weight carry the hierarchy instead. (`--muted` being that dim in night is not only a toast problem; statistic labels and inactive tabs use it too. Left alone here.) Position moves from bottom right to top right. Bottom right put toasts over the file browser's sticky footer and a video's player controls, which are the two places a background task is most likely to report while the user is doing something else. Gallery gets a Toasts section: one button per type, one that stacks a numbered toast per press, one that fills the container to its limit of five, one that never expires, one with no title, one with text long enough to wrap, and clear-all. A toast is the one component that cannot be seen by loading a page, so it needs buttons rather than a sample. Tests ----- Thirteen, where there were none for thirteen call sites -- and `toast` has already failed once app-wide, when App.js dropped Semantic's container while seven pages still imported the old helper and every notification silently went nowhere. Six were verified red against planted defects (a shared `id`, which makes Mantine replace instead of stack; one colour for every type; `autoClose` taking the 0 literally). The duration tests use real timers with short durations, which matters. With fake timers the element is never removed from the DOM -- hiding a notification runs an exit transition, and advancing the clock, even awaited inside `act`, does not complete it. Both the assertion and its control then read the same whatever the code does. The test for `time: 0` passed against a planted `autoClose: 0` twice before this was rewritten: once asserting synchronously, once with a control that could not fail either. It now waits for a normally-expiring toast to disappear first, so dismissal is demonstrably working before the survivor is asserted.
This commit is contained in:
parent
db3889589f
commit
213b940a1b
4 changed files with 334 additions and 1 deletions
|
|
@ -779,6 +779,54 @@ html[data-theme="amber"] .wrolpi-label {
|
|||
--label-text: var(--btn-text) !important;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- Toasts */
|
||||
/*
|
||||
* Notifications take their colours from our tokens rather than from Mantine's colour scheme.
|
||||
*
|
||||
* Mantine paints a dark-scheme notification title with `--mantine-color-white`, and the
|
||||
* bridge aliases that to `--btn-text` -- deliberately, because it is the text drawn on a
|
||||
* filled button, which is near-black in dark, night and amber. So the title came out at
|
||||
* rgb(28, 31, 33) on a rgb(38, 41, 43) surface: about 1.1:1, present and invisible. Fixing
|
||||
* the alias is not an option; it is correct for the buttons it exists for.
|
||||
*
|
||||
* The `html` prefix is only there to outrank Mantine's single-class rules. One set of values
|
||||
* covers every theme, because the tokens are what differ.
|
||||
*/
|
||||
|
||||
html .mantine-Notification-root {
|
||||
background-color: var(--panel);
|
||||
border-color: var(--border);
|
||||
}
|
||||
|
||||
html .mantine-Notification-title {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
html .mantine-Notification-description {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/*
|
||||
* The description is the message itself, so it has to be read, and `--muted` is too dim to
|
||||
* read on a panel in the two monochrome themes -- 2.0:1 in night, 3.1:1 in amber, against
|
||||
* 5.1:1 and 5.7:1 in dark and light. Those two drop the muting and let the title's weight
|
||||
* carry the hierarchy instead, which is the same brightness-over-hue trade the rest of night
|
||||
* makes.
|
||||
*/
|
||||
html[data-theme="night"] .mantine-Notification-description,
|
||||
html[data-theme="amber"] .mantine-Notification-description {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
html .mantine-Notification-closeButton {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
html .mantine-Notification-closeButton:hover {
|
||||
background-color: var(--head);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- Messages */
|
||||
|
||||
.wrolpi-message {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue