swarm-ui: the refresh picker shows a spinner in place of its clock while its page is fetching
usePolled reports when a request is in flight (through a new onBusy of the poller) and holds it on for at least 0.4 seconds, so a quick answer still reads as a refresh. The picker swaps its clock for the spinner, in the same box so its width stays, and the spinner stands still where motion is off. Every page with a picker passes it; a page with several polled requests shows it while any of them runs. The Jobs page fetches through shared components and has none yet.
This commit is contained in:
parent
89bbeb9757
commit
47c447409b
2 changed files with 296 additions and 23 deletions
|
|
@ -35,6 +35,40 @@
|
|||
color: inherit;
|
||||
}
|
||||
.ui-refresh-picker-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
font-size: 0.85em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* The spinner takes the clock's place: the same box, so the picker keeps its
|
||||
width. Motion follows the page's setting, the same three rules the page
|
||||
switch uses; where motion is off it is a static arc. */
|
||||
.ui-refresh-picker-spinner {
|
||||
box-sizing: border-box;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
border: 2px solid currentColor;
|
||||
border-right-color: transparent;
|
||||
border-radius: 50%;
|
||||
animation: ui-refresh-spin 0.8s linear infinite;
|
||||
}
|
||||
@keyframes ui-refresh-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ui-refresh-picker-spinner {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
:root[data-motion="reduce"] .ui-refresh-picker-spinner {
|
||||
animation: none;
|
||||
}
|
||||
:root[data-motion="allow"] .ui-refresh-picker-spinner {
|
||||
animation: ui-refresh-spin 0.8s linear infinite;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,16 +43,23 @@ export function RefreshIntervalPicker({
|
|||
id,
|
||||
value,
|
||||
onChange,
|
||||
refreshing = false,
|
||||
}: {
|
||||
id: string;
|
||||
value: RefreshIntervalMs;
|
||||
onChange: (value: RefreshIntervalMs) => void;
|
||||
/** A request is in flight: a spinner takes the clock's place, so the width stays. */
|
||||
refreshing?: boolean;
|
||||
}) {
|
||||
const current = PRESETS.find((p) => p.value === value) ?? PRESETS[0];
|
||||
return (
|
||||
<div class="ui-refresh-picker">
|
||||
<span class="ui-refresh-picker-icon" aria-hidden="true">
|
||||
🕐
|
||||
<div class="ui-refresh-picker" aria-busy={refreshing}>
|
||||
<span
|
||||
class="ui-refresh-picker-icon"
|
||||
aria-hidden="true"
|
||||
title={refreshing ? "refreshing" : undefined}
|
||||
>
|
||||
{refreshing ? <span class="ui-refresh-picker-spinner" /> : "🕐"}
|
||||
</span>
|
||||
<Listbox
|
||||
id={id}
|
||||
|
|
|
|||
Loading…
Reference in a new issue