refactor(web): give Spinner and RefreshIcon a size prop (#12985)

Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Fable 5 authored and GitHub committed 2026-09-21 22:57:43 -07:00
1 parent 438bf466fd
commit b5a0f81010
36 files changed
+101 -59

No files matched your search

@@ -905,7 +905,7 @@ export function BranchToolbarBranchSelector({
className="flex cursor-pointer items-center justify-between gap-3 border-t border-border/60 px-3 py-2 text-xs"
>
<span className="flex min-w-0 items-center gap-1.5 font-medium text-muted-foreground">
<RefreshIcon aria-hidden="true" className="size-3 shrink-0 opacity-70" />
<RefreshIcon aria-hidden="true" size="xs" className="shrink-0" />
<span className="truncate">Start from origin</span>
</span>
<Switch
+1 -1
View File
@@ -856,7 +856,7 @@ export default function DiffPanel({
/>
}
>
<RefreshIcon className="size-3.5" refreshing={isRefreshingDiff} />
<RefreshIcon size="sm" refreshing={isRefreshingDiff} />
</TooltipTrigger>
<TooltipPopup side="top">
{isRefreshingDiff ? "Refreshing diff…" : "Refresh diff"}
@@ -851,7 +851,7 @@ function PublishRepositoryDialog(props: PublishRepositoryDialogProps) {
aria-live="polite"
className="flex items-center gap-2 rounded-md border border-input bg-muted/40 px-3 py-2 text-xs text-muted-foreground dark:border-transparent dark:bg-white/[0.035]"
>
<Spinner className="size-3.5" aria-hidden />
<Spinner size="sm" aria-hidden />
Publishing repository to {publishProviderLabel}...
</div>
) : null}
@@ -938,7 +938,7 @@ function PublishRepositoryDialog(props: PublishRepositoryDialogProps) {
<Button disabled={!canSubmitPublishRepository} onClick={submitPublishRepository}>
{publishRepositoryAction.isPending ? (
<>
<Spinner className="size-3.5" aria-hidden />
<Spinner size="sm" aria-hidden />
Publishing...
</>
) : (
@@ -118,7 +118,7 @@ function EnvironmentUpdateRow({
let trailing: ReactNode;
switch (status.kind) {
case "loading":
trailing = <Spinner className="size-4 text-muted-foreground" />;
trailing = <Spinner size="md" tone="muted" />;
break;
case "success":
trailing = <CheckIcon aria-hidden="true" className="size-4 text-success" />;
@@ -252,7 +252,7 @@ export function PullRequestThreadDialog({
{isResolving ? (
<div className="flex items-center gap-2 text-muted-foreground text-xs">
<Spinner className="size-3.5" />
<Spinner size="sm" />
Resolving {terminology.singular}...
</div>
) : null}
@@ -254,7 +254,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
</span>
) : null}
{isConnecting || isSendBusy ? (
<Spinner className="size-3.5" aria-hidden="true" />
<Spinner size="sm" aria-hidden="true" />
) : (
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
<path
@@ -2567,7 +2567,7 @@ function BackgroundWorktreeSetupChip({ snapshot }: { snapshot: WorktreeSetupSnap
/>
}
>
<Spinner className="size-3 shrink-0" />
<Spinner size="xs" className="shrink-0" />
<span className="truncate">{scriptName}</span>
</PopoverTrigger>
<PopoverPopup
@@ -61,7 +61,7 @@ function StageIcon({ status }: { status: WorktreeSetupStage["status"] }) {
case "done":
return <CheckIcon aria-hidden className={className} />;
case "running":
return <Spinner className={className} />;
return <Spinner size="md" className="shrink-0" />;
case "failed":
return <XIcon aria-hidden className={className} />;
case "warning":
@@ -56,7 +56,7 @@ export function ClerkUserProfileRefreshButton({
disabled={disabled || isPending}
onClick={onClick}
>
<RefreshIcon aria-hidden="true" className="size-3.5" refreshing={isPending} />
<RefreshIcon aria-hidden="true" size="sm" refreshing={isPending} />
Refresh
</Button>
);
@@ -27,7 +27,7 @@ export function DeviceLoadingView(props: {
) : null}
</div>
<div className="flex items-center gap-2 text-xs text-muted-foreground">
{!props.error ? <Spinner className="size-3" /> : null}
{!props.error ? <Spinner size="xs" /> : null}
<span>{props.message}</span>
</div>
{props.children}
@@ -367,7 +367,7 @@ export function DevicePanel(props: {
onClick={() => void selectDevice(deviceKey(device))}
action={
pendingDeviceKey === deviceKey(device) ? (
<Spinner className="size-3" />
<Spinner size="xs" />
) : (
<span className="text-xs text-muted-foreground">
{device.booted ? "Open" : "Start"}
@@ -203,7 +203,7 @@ export function DeviceHubSetupStatus({
if (!pending && state.hostStatus !== "ready") return null;
return (
<p role="status" className="flex items-center gap-2 text-xs text-muted-foreground">
{pending ? <Spinner className="size-3" /> : <Check className="size-3 text-success" />}
{pending ? <Spinner size="xs" /> : <Check className="size-3 text-success" />}
{pending
? state.hostStatus === "installing"
? compact
@@ -235,7 +235,7 @@ function DevicePlatformSetup(props: {
You can use either platform. Fixing a missing platform does not block the other one.
</p>
<Button size="compact" variant="outline" disabled={props.disabled} onClick={props.onCheck}>
{props.checking ? <Spinner className="size-3" /> : null}
{props.checking ? <Spinner size="xs" /> : null}
{props.checking ? "Checking…" : "Check again"}
</Button>
</div>
@@ -262,7 +262,7 @@ export function AgentDeviceSetupStatus(props: {
: "Updating agent access…";
return (
<p role="status" className="flex items-center gap-2 text-xs text-muted-foreground">
<Spinner className="size-3" />
<Spinner size="xs" />
{label}
</p>
);
@@ -173,7 +173,7 @@ export function DeviceToolsPanel(props: {
>
<div className="flex h-9 shrink-0 items-center gap-2 border-b px-3">
<span className="font-medium">Tools</span>
{pending ? <Spinner className="size-3.5" /> : null}
{pending ? <Spinner size="sm" /> : null}
<Button
size="icon-xs"
variant="ghost-muted"
@@ -190,7 +190,7 @@ export function DeviceToolsPanel(props: {
) : null}
{detail === null && !error ? (
<div className="flex items-center gap-2 px-3 py-3 text-xs text-muted-foreground">
<Spinner className="size-3.5" /> Reading device settings…
<Spinner size="sm" /> Reading device settings…
</div>
) : null}
@@ -169,7 +169,7 @@ function WorkspaceImagePreview(props: {
</div>
) : (
<div className="flex min-h-0 flex-1 items-center justify-center text-muted-foreground">
<Spinner className="size-5" />
<Spinner size="lg" />
</div>
);
}
@@ -214,7 +214,7 @@ function WorkspaceBrowserPreview(props: {
if (assetUrl._tag !== "Success") {
return (
<div className="flex min-h-0 flex-1 items-center justify-center text-muted-foreground">
<Spinner className="size-5" />
<Spinner size="lg" />
</div>
);
}
@@ -1232,7 +1232,7 @@ export default function FilePreviewPanel({
</div>
) : relativePath && file.data === null ? (
<div className="flex min-h-0 flex-1 items-center justify-center text-muted-foreground">
<Spinner className="size-5" />
<Spinner size="lg" />
</div>
) : relativePath && file.data ? (
isMarkdown && renderMarkdown ? (
@@ -131,7 +131,7 @@ export function FileSurfaceLoading(props: { readonly className?: string }) {
props.className,
)}
>
<Spinner className="size-5" />
<Spinner size="lg" />
</div>
);
}
@@ -1162,7 +1162,7 @@ function ImportStep({
<div className="flex h-full min-h-40 flex-col">
<h1 className="text-2xl font-semibold tracking-tight text-foreground">Your projects</h1>
<div className="flex flex-1 flex-col items-center justify-center gap-3 py-6">
<Spinner className="size-5 text-muted-foreground" />
<Spinner size="lg" tone="muted" />
<p className="text-center text-sm text-muted-foreground">
Looking for projects from Claude Code and Codex…
</p>
@@ -1229,7 +1229,7 @@ function ImportStep({
) : null}
{scan.isPending && scan.data === null ? (
<div className="flex items-center gap-2 py-3 text-sm text-muted-foreground">
<Spinner className="size-4" />
<Spinner size="md" />
Looking for projects…
</div>
) : scan.error !== null ? (
@@ -23,7 +23,7 @@ export function PullRequestActivityUnavailableState({
<p className="text-sm font-medium text-foreground">Could not load pull request activity</p>
<p className="max-w-md text-xs text-muted-foreground">{error}</p>
<Button size="sm" variant="outline" onClick={onRetry}>
<RefreshIcon aria-hidden className="size-3.5" />
<RefreshIcon aria-hidden size="sm" />
Retry
</Button>
</div>
@@ -2010,7 +2010,7 @@ export function PullRequestDetailPanel({
the spinning glyph in place of the dots: the reader sees the panel
is fetching without a control appearing or the row shifting. */}
{refreshing ? (
<RefreshIcon refreshing className="size-4" />
<RefreshIcon refreshing size="md" />
) : (
<MoreHorizontalIcon className="size-4" />
)}
@@ -2034,7 +2034,7 @@ export function PullRequestDetailPanel({
onPickerOpenChange={setThreadPickerOpen}
/>
<MenuItem disabled={refreshing} onClick={() => void refreshFromHost()}>
<RefreshIcon className="size-3.5" refreshing={refreshing} />
<RefreshIcon size="sm" refreshing={refreshing} />
Refresh
</MenuItem>
<MenuItem disabled={handoff !== null} onClick={askAboutPullRequest}>
@@ -150,7 +150,7 @@ export function PullRequestListEmptyState({
{/* The hosts answered this query once; a pull request opened since then would answer
differently, and nothing on screen says which of the two the reader is looking at. */}
<Button size="sm" variant="outline" disabled={refreshing} onClick={onRefresh}>
<RefreshIcon className="size-3.5" refreshing={refreshing} />
<RefreshIcon size="sm" refreshing={refreshing} />
{refreshing ? "Checking..." : "Check again"}
</Button>
</EmptyContent>
@@ -176,7 +176,7 @@ export function PullRequestListEmptyState({
</Button>
) : null}
<Button size="sm" variant="outline" disabled={refreshing} onClick={onRefresh}>
<RefreshIcon className="size-3.5" refreshing={refreshing} />
<RefreshIcon size="sm" refreshing={refreshing} />
{refreshing ? "Checking..." : "Check again"}
</Button>
</EmptyContent>
@@ -46,7 +46,7 @@ export function PullRequestsUnavailableState({
disabled={refreshing}
aria-busy={refreshing}
>
<RefreshIcon className="size-3.5" refreshing={refreshing} />
<RefreshIcon size="sm" refreshing={refreshing} />
Retry
</Button>
) : null}
@@ -226,7 +226,7 @@ function OpenContentSearchDialog(props: {
<div className="flex h-9 shrink-0 items-center border-b px-3 text-xs text-muted-foreground">
{search.isPending ? (
<span className="flex items-center gap-2">
<Spinner className="size-3.5" /> Searching…
<Spinner size="sm" /> Searching…
</span>
) : search.error ? (
<span className="text-destructive">{search.error}</span>
@@ -491,7 +491,7 @@ function ImportingStep() {
<DialogDescription>This may take a moment.</DialogDescription>
</DialogHeader>
<DialogPanel className="flex items-center gap-3 py-6">
<Spinner className="size-4 text-muted-foreground" />
<Spinner size="md" tone="muted" />
<span className="text-sm text-muted-foreground">Importing…</span>
</DialogPanel>
</>
@@ -516,7 +516,7 @@ function CheckingStep({
</DialogDescription>
</DialogHeader>
<DialogPanel className="flex items-center gap-3 py-6">
<Spinner className="size-4 text-muted-foreground" />
<Spinner size="md" tone="muted" />
<span className="text-sm text-muted-foreground">
{check === "fullDiskAccess" ? "Checking access…" : "Checking…"}
</span>
@@ -3435,7 +3435,7 @@ export function ConnectionsSettings() {
pendingDesktopServerExposureMode === null || isUpdatingDesktopServerExposure
}
>
{isUpdatingDesktopServerExposure && <Spinner className="size-3.5" />}
{isUpdatingDesktopServerExposure && <Spinner size="sm" />}
<span className="[text-box:trim-both_cap_alphabetic]">
{isUpdatingDesktopServerExposure
? "Restarting…"
@@ -3499,7 +3499,7 @@ export function ConnectionsSettings() {
>
{isUpdatingWslBackend ? (
<>
<Spinner className="size-3.5" />
<Spinner size="sm" />
Applying…
</>
) : (
@@ -3513,7 +3513,7 @@ export function ConnectionsSettings() {
>
{isUpdatingWslBackend ? (
<>
<Spinner className="size-3.5" />
<Spinner size="sm" />
Applying…
</>
) : (
@@ -3534,7 +3534,7 @@ export function ConnectionsSettings() {
>
{isUpdatingWslBackend ? (
<>
<Spinner className="size-3.5" />
<Spinner size="sm" />
Applying…
</>
) : pendingWslChange?.kind === "disable" ? (
@@ -3583,7 +3583,7 @@ export function ConnectionsSettings() {
>
{isUpdatingTailscaleServe ? (
<>
<Spinner className="size-3.5" />
<Spinner size="sm" />
Restarting…
</>
) : (
@@ -3657,7 +3657,7 @@ export function ConnectionsSettings() {
>
{isUpdatingTailscaleServe ? (
<>
<Spinner className="size-3.5" />
<Spinner size="sm" />
Restarting…
</>
) : (
@@ -156,7 +156,7 @@ export function DeviceHostEditor({
if (Option.isSome(input)) void testConnection(input.value);
}}
>
{checking ? <Spinner className="size-3" /> : null} Test connection
{checking ? <Spinner size="xs" /> : null} Test connection
</Button>
</div>
{results ? (
@@ -173,7 +173,7 @@ export function DeviceHostEditor({
>
{result.status === "pending" ? (
<>
<Spinner className="size-3" /> Checking…
<Spinner size="xs" /> Checking…
</>
) : result.status === "local" ? (
<>
@@ -215,7 +215,7 @@ export function DeviceHostEditor({
Cancel
</Button>
<Button type="submit" disabled={busy || checking || !valid || !draft.label.trim()}>
{busy ? <Spinner className="size-3" /> : null} Save host
{busy ? <Spinner size="xs" /> : null} Save host
</Button>
</DialogFooter>
</DialogPopup>
@@ -267,7 +267,7 @@ function DeviceHostList({
role="status"
className="inline-flex items-center gap-1.5 text-xs text-muted-foreground"
>
<Spinner className="size-3" />
<Spinner size="xs" />
{progress}
</span>
) : null}
@@ -86,7 +86,7 @@ export function LocalEnvironmentSetting() {
>
{isUpdating ? (
<>
<Spinner className="size-3.5" />
<Spinner size="sm" />
Restarting…
</>
) : enabled ? (
@@ -976,7 +976,7 @@ export function ResourceTelemetryDiagnostics({
onClick={telemetry.refresh}
aria-label="Refresh resource telemetry"
>
<RefreshIcon className="size-3" refreshing={telemetry.isPending} />
<RefreshIcon size="xs" refreshing={telemetry.isPending} />
</Button>
}
/>
@@ -1087,7 +1087,7 @@ export function ResourceTelemetryDiagnostics({
headerAction={
collectorNeedsRetry ? (
<Button size="xs" variant="outline" disabled={isRetrying} onClick={retryCollector}>
<RefreshIcon className="size-3" refreshing={isRetrying} />
<RefreshIcon size="xs" refreshing={isRetrying} />
Retry monitor
</Button>
) : null
@@ -1225,7 +1225,7 @@ export function ResourceTelemetryDiagnostics({
onClick={history.refresh}
aria-label="Refresh resource history"
>
<RefreshIcon className="size-3" refreshing={history.isPending} />
<RefreshIcon size="xs" refreshing={history.isPending} />
</Button>
</div>
}
@@ -3359,7 +3359,7 @@ export function ArchivedThreadsPanel() {
title={
<span className="inline-flex items-center gap-2">
{isLoadingArchive ? (
<Spinner className="size-3.5 text-muted-foreground" />
<Spinner size="sm" tone="muted" />
) : (
<ArchiveIcon className="size-3.5 text-muted-foreground" />
)}
@@ -491,7 +491,7 @@ function EmptySourceControlDiscovery({
</EmptyHeader>
<EmptyContent>
<Button size="sm" variant="outline" onClick={onScan} disabled={isPending}>
<RefreshIcon className="size-3.5" refreshing={isPending} />
<RefreshIcon size="sm" refreshing={isPending} />
Scan
</Button>
</EmptyContent>
@@ -174,7 +174,7 @@ export function SidebarProviderUpdatePill() {
onClick={openProviderSettings}
>
{displayedView.tone === "loading" ? (
<Spinner className="size-3.5 shrink-0" />
<Spinner size="sm" className="shrink-0" />
) : displayedView.tone === "success" ? (
<CircleCheckIcon className="size-3.5 shrink-0" />
) : displayedView.tone === "error" ? (
+21 -2
View File
@@ -1,19 +1,38 @@
import { RefreshCwIcon } from "lucide-react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "~/lib/utils";
import { observeVisibleAnimation } from "~/lib/visibleAnimation";
// No default size: inside a Button the parent's svg rule sizes the glyph.
const refreshIconVariants = cva("", {
variants: {
size: {
xs: "size-3",
sm: "size-3.5",
md: "size-4",
lg: "size-5",
},
},
});
/** Keep the refresh glyph in place while its owning action is running. */
export function RefreshIcon({
refreshing = false,
className,
size,
...props
}: React.ComponentPropsWithoutRef<typeof RefreshCwIcon> & { refreshing?: boolean }) {
}: React.ComponentPropsWithoutRef<typeof RefreshCwIcon> &
VariantProps<typeof refreshIconVariants> & { refreshing?: boolean }) {
return (
<RefreshCwIcon
aria-hidden
ref={refreshing ? observeVisibleAnimation : undefined}
className={cn(refreshing && "motion-safe:visible-animate-spin", className)}
className={cn(
refreshIconVariants({ size }),
refreshing && "motion-safe:visible-animate-spin",
className,
)}
{...props}
/>
);
+25 -2
View File
@@ -1,13 +1,36 @@
import { LoaderCircleIcon } from "lucide-react";
import { cva, type VariantProps } from "class-variance-authority";
import { observeVisibleAnimation } from "~/lib/visibleAnimation";
import { cn } from "~/lib/utils";
function Spinner({ className, ...props }: React.ComponentPropsWithoutRef<typeof LoaderCircleIcon>) {
// No default size: inside a Button the parent's svg rule sizes the glyph.
const spinnerVariants = cva("motion-safe:visible-animate-spin", {
variants: {
size: {
xs: "size-3",
sm: "size-3.5",
md: "size-4",
lg: "size-5",
},
tone: {
current: "",
muted: "text-muted-foreground",
},
},
defaultVariants: { tone: "current" },
});
function Spinner({
className,
size,
tone,
...props
}: React.ComponentPropsWithoutRef<typeof LoaderCircleIcon> & VariantProps<typeof spinnerVariants>) {
return (
<LoaderCircleIcon
aria-label="Loading"
ref={observeVisibleAnimation}
className={cn("motion-safe:visible-animate-spin", className)}
className={cn(spinnerVariants({ size, tone }), className)}
role="status"
{...props}
/>
+2 -2
View File
@@ -300,7 +300,7 @@ export function UsagePage() {
size="icon-sm"
variant="ghost"
>
<RefreshIcon className="size-3.5" refreshing={isRefreshing} />
<RefreshIcon size="sm" refreshing={isRefreshing} />
</Button>
</div>
<div className="col-span-2 ms-auto flex min-w-0 items-center justify-end gap-1 xl:hidden">
@@ -359,7 +359,7 @@ export function UsagePage() {
size="icon-sm"
variant="ghost"
>
<RefreshIcon className="size-3.5" refreshing={isRefreshing} />
<RefreshIcon size="sm" refreshing={isRefreshing} />
</Button>
</div>
</div>
+1 -1
View File
@@ -99,7 +99,7 @@ function DraftStartError({ onRetry }: { readonly onRetry: () => void }) {
</EmptyDescription>
<div className="mt-5 flex justify-center">
<Button size="sm" onClick={onRetry}>
<RefreshIcon className="size-4" />
<RefreshIcon size="md" />
Try again
</Button>
</div>
+2 -2
View File
@@ -1830,7 +1830,7 @@ function PullRequestsRouteView() {
<div className="flex justify-center py-3 text-xs text-muted-foreground">
{loadingMore ? (
<span className="flex items-center gap-2">
<Spinner aria-hidden className="size-3.5" />
<Spinner aria-hidden size="sm" />
{sentCursors === null ? "Updating pull requests" : "Loading more"}
</span>
) : canContinue || pageSize < MAX_PAGE_SIZE ? (
@@ -2592,7 +2592,7 @@ function PullRequestRefreshControl({
onClick={onRefresh}
disabled={refreshing}
>
<RefreshIcon className="size-4" refreshing={refreshing} />
<RefreshIcon size="md" refreshing={refreshing} />
</Button>
);
}
+1 -1
View File
@@ -8,7 +8,7 @@ import * as NodeURL from "node:url";
// components/ui exports are migrated to variants (see vite.config.ts). This gate keeps the
// count from growing: CI fails when findings exceed the ceiling. Lower the ceiling when you
// migrate a file, and delete this script when the rule becomes an error.
export const RESTYLE_CEILING = 1214;
export const RESTYLE_CEILING = 1207;
const RULE = "shadcn(no-restyle)";