дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
A plugin command that takes seconds (an LLM call that fills the commit message) gave no sign at the button that the click was taken, and a second click started a second run. Actions may now set `indicatesRunning`: the action runner counts their in-flight runs and an IconButton bound to such an action shows a spinner, sets aria-busy and ignores clicks until the run settles. Plugin commands set it, so every toolbar slot that draws them (editor.title, mainToolbar, commit.message) is covered without a plugin API change and without features importing each other. The button stays focusable (aria-disabled, not disabled). Spinner moves to its own module so Button can use it without a cycle with Feedback, which re-exports it. Refs #2254 Co-authored-by: NguyenBang <[email protected]>
47 рядки
1.2 KiB
TypeScript
47 рядки
1.2 KiB
TypeScript
import clsx from "clsx";
|
|
import styles from "./Spinner.module.css";
|
|
|
|
export function Spinner({
|
|
size = 14,
|
|
className,
|
|
label = "Loading",
|
|
variant = "ring",
|
|
}: {
|
|
size?: number;
|
|
className?: string;
|
|
label?: string;
|
|
variant?: "ring" | "spokes";
|
|
}) {
|
|
return (
|
|
<svg
|
|
className={clsx(styles.spinner, variant === "spokes" && styles.spokes, className)}
|
|
width={size}
|
|
height={size}
|
|
viewBox={variant === "spokes" ? "0 0 16 16" : "0 0 24 24"}
|
|
role="status"
|
|
aria-label={label}
|
|
>
|
|
{variant === "spokes" ? (
|
|
Array.from({ length: 8 }, (_, index) => (
|
|
<rect
|
|
key={index}
|
|
x="7"
|
|
y="1"
|
|
width="2"
|
|
height="4"
|
|
rx="1"
|
|
fill="currentColor"
|
|
opacity={1 - index * 0.1}
|
|
transform={`rotate(${-index * 45} 8 8)`}
|
|
/>
|
|
))
|
|
) : (
|
|
<>
|
|
<circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" strokeOpacity="0.2" strokeWidth="2.4" />
|
|
<path d="M21 12a9 9 0 0 0-9-9" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" />
|
|
</>
|
|
)}
|
|
</svg>
|
|
);
|
|
}
|