算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
feedback-loop-states-and-latency【设计与创意】Use this skill when designing the visible states an interactive element passes through (idle / pending / success / error) and matching feedback timing to the user's perceptual thresholds. Trigger when designing button states, form-submit flows, file-upload progress, loading screens, or any interaction whose response time is variable. Sub-aspect of `f…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
feedback-loop; read that first.'Most interactive actions pass through a small set of visible states; the system must communicate each. The latency of each state determines what feedback is appropriate — a 50ms response needs no spinner, a 5s response needs progress info, a 50s response needs estimated time remaining.
The element is interactive and waiting. Affordance signals "you can do this." Static styling.
Action triggered; system working. Disable trigger to prevent re-submit; show indicator if wait > ~500ms.
Action succeeded. Show the result in-place where possible; toast/banner if the result is on another surface.
Action failed. In-context, specific, actionable error message.
<button id="action" data-state="idle">
<span class="label">Save</span>
<span class="spinner" hidden></span>
</button>
<style>
button[data-state="pending"] { cursor: wait; opacity: 0.7; }
button[data-state="pending"] .spinner { display: inline-block; }
button[data-state="success"] { background: var(--success); }
button[data-state="error"] { background: var(--destructive); }
</style>
| Latency | Threshold | Pattern |
|---|---|---|
| < 100ms | "Instant" | No indicator. Just respond. |
| 100–400ms | "Responsive" | Light state change (button briefly disabled). |
| 400ms–1s | "Noticeable" | Spinner or progress micro-animation. |
| 1–10s | "Waiting" | Spinner with status text. |
| > 10s | "Long" | Progress bar with estimated time remaining; cancel option. |
Doherty Threshold (~400ms): response times under this keep users in flow. Above this, attention drifts and engagement drops.
For actions where the success rate is high and the action is reversible, update the UI as if the action succeeded immediately, then commit in the background. If the action fails, roll back visibly with an error message.
async function toggleStar(item) {
// Optimistic
item.starred = !item.starred;
render();
try {
await api.updateStar(item.id, item.starred);
} catch (err) {
// Rollback with feedback
item.starred = !item.starred;
render();
showToast(`Couldn't update: ${err.message}`);
}
}
The user gets instant feedback; failure is the exception, handled with explicit feedback.
For loading content (not actions), prefer skeleton screens to spinners:
<!-- While data loads -->
<article class="post-skeleton">
<div class="title-skel"></div>
<div class="meta-skel"></div>
<div class="body-skel"></div>
<div class="body-skel"></div>
</article>
Skeletons:
Spinners are better when the wait isn't structural (a single action's pending state) or when the location of the result isn't predictable.
For operations > 10s:
<div class="upload">
<p>Uploading <strong>file.zip</strong></p>
<progress max="100" value="42">42%</progress>
<p class="status">42% — about 2 minutes remaining</p>
<button>Cancel</button>
</div>
Errors should appear with the element that caused them, not in a generic page banner.
<div class="field" data-state="error">
<label for="email">Email</label>
<input id="email" type="email" aria-invalid="true" aria-describedby="email-error" />
<p id="email-error" class="error">
We couldn't find an account with this email.
<a href="/signup">Sign up?</a>
</p>
</div>
aria-invalid and aria-describedby make the error programmatically associated; screen readers announce both together.
feedback-loop (parent).feedback-loop-positive-vs-negative — loop architecture; this skill is loop implementation.accessibility-operable — aria-live regions communicate states to screen readers.forgiveness — error feedback is recovery's first step.