Files
NODEDC_DESIGN_GUIDELINE/packages/ui-react/src/ProgressButton.tsx
T
Codex cb534dbe39 feat(ui): add docking, viewport controls and composed settings
Add shared dock layouts, navigation cube, range bands, progress actions and comparison surfaces. Extend toolbar menus and loading composition, and align tokens, registry entries, documentation and the living catalog.
2026-10-29 09:38:25 +03:00

32 lines
1.5 KiB
TypeScript

import { useId } from "react";
import { Button, type ButtonProps } from "./Button.js";
import { ProgressBar } from "./ProgressBar.js";
import { Icon } from "./Icon.js";
import { cn } from "./cn.js";
export interface ProgressButtonProps extends Omit<ButtonProps, "children" | "loading" | "size"> {
label: string;
/** Presence means pending. Value is measured progress of the named phase, not elapsed time. */
progress?: { label: string; value?: number; valueText?: string };
}
export function ProgressButton({ label, progress, className, disabled, icon, ...props }: ProgressButtonProps) {
const statusId = useId();
return <div className={cn("nodedc-progress-button", className)} data-pending={!!progress || undefined}
data-icon={!!icon || undefined}>
<Button {...props} icon={icon} disabled={disabled || !!progress} aria-busy={!!progress}
aria-label={label} aria-describedby={progress ? statusId : undefined}>
<span className="nodedc-progress-button__label">{progress?.label ?? label}</span>
</Button>
{progress ? <>
<span id={statusId} className="nodedc-progress-button__status" role="status">{progress.label}</span>
<ProgressBar label={label} value={progress.value} valueText={progress.valueText ?? progress.label} />
</> : null}
</div>;
}
/** Decorative animation of the canonical layers glyph. The surrounding action owns live status. */
export function LayerStackIndicator() {
return <Icon name="layers" className="nodedc-layer-stack-indicator" />;
}