mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
When the workspace is off, we set a disabled text/stroke color, but for the idle icon that also needs a fill, this only changed the outline making it look weird. Instead, move the disabled logic into the component so we can apply a matching fill. I felt it looked too thick with both the outline and fill, so I also removed the outline. Really I think maybe the workspace status should be a separate column rather than disabling these icons, but this maintains the status quo. Before with mismatching stroke and fill color:  After with disabled fill and stroke removal:  Enabled fill and stroke removal: 
71 lines
1.6 KiB
TypeScript
71 lines
1.6 KiB
TypeScript
import type { WorkspaceAppStatusState } from "api/typesGenerated";
|
|
import { Spinner } from "components/Spinner/Spinner";
|
|
import {
|
|
BanIcon,
|
|
CircleAlertIcon,
|
|
CircleCheckIcon,
|
|
HourglassIcon,
|
|
PauseIcon,
|
|
TriangleAlertIcon,
|
|
} from "lucide-react";
|
|
import type { FC } from "react";
|
|
import { cn } from "utils/cn";
|
|
|
|
type AppStatusStateIconProps = {
|
|
state: WorkspaceAppStatusState;
|
|
latest: boolean;
|
|
disabled?: boolean;
|
|
className?: string;
|
|
};
|
|
|
|
export const AppStatusStateIcon: FC<AppStatusStateIconProps> = ({
|
|
state,
|
|
disabled,
|
|
latest,
|
|
className: customClassName,
|
|
}) => {
|
|
const className = cn([
|
|
"size-4 shrink-0",
|
|
customClassName,
|
|
disabled && "text-content-disabled",
|
|
]);
|
|
|
|
switch (state) {
|
|
case "idle":
|
|
// The pause icon is outlined; add a fill since it is hard to see and
|
|
// remove the stroke so it is not overly thick.
|
|
return (
|
|
<PauseIcon
|
|
css={{ strokeWidth: 0 }}
|
|
className={cn([
|
|
"text-content-secondary",
|
|
className,
|
|
disabled ? "fill-content-disabled" : "fill-content-secondary",
|
|
])}
|
|
/>
|
|
);
|
|
case "complete":
|
|
return (
|
|
<CircleCheckIcon className={cn(["text-content-success", className])} />
|
|
);
|
|
case "failure":
|
|
return (
|
|
<CircleAlertIcon className={cn(["text-content-warning", className])} />
|
|
);
|
|
case "working":
|
|
return disabled ? (
|
|
<BanIcon className={cn(["text-content-disabled", className])} />
|
|
) : latest ? (
|
|
<Spinner size="sm" className="shrink-0" loading />
|
|
) : (
|
|
<HourglassIcon className={cn(["text-content-secondary", className])} />
|
|
);
|
|
default:
|
|
return (
|
|
<TriangleAlertIcon
|
|
className={cn(["text-content-secondary", className])}
|
|
/>
|
|
);
|
|
}
|
|
};
|