2025-09-21 11:02:31 -07:00
|
|
|
import { memo } from "react";
|
|
|
|
|
import { initialArtifactData, useArtifact } from "@/hooks/use-artifact";
|
|
|
|
|
import { CrossIcon } from "./icons";
|
2025-02-13 08:25:57 -08:00
|
|
|
|
|
|
|
|
function PureArtifactCloseButton() {
|
|
|
|
|
const { setArtifact } = useArtifact();
|
|
|
|
|
|
|
|
|
|
return (
|
2026-03-20 09:37:02 +00:00
|
|
|
<button
|
|
|
|
|
className="group flex size-8 items-center justify-center rounded-lg border border-transparent text-muted-foreground transition-all duration-150 hover:border-border hover:bg-muted hover:text-foreground active:scale-95"
|
2025-09-21 11:02:31 -07:00
|
|
|
data-testid="artifact-close-button"
|
2025-02-13 08:25:57 -08:00
|
|
|
onClick={() => {
|
|
|
|
|
setArtifact((currentArtifact) =>
|
2025-09-21 11:02:31 -07:00
|
|
|
currentArtifact.status === "streaming"
|
2025-02-13 08:25:57 -08:00
|
|
|
? {
|
|
|
|
|
...currentArtifact,
|
|
|
|
|
isVisible: false,
|
|
|
|
|
}
|
2025-09-21 11:02:31 -07:00
|
|
|
: { ...initialArtifactData, status: "idle" }
|
2025-02-13 08:25:57 -08:00
|
|
|
);
|
|
|
|
|
}}
|
2026-03-20 09:37:02 +00:00
|
|
|
type="button"
|
2025-02-13 08:25:57 -08:00
|
|
|
>
|
2026-03-20 09:37:02 +00:00
|
|
|
<CrossIcon size={16} />
|
|
|
|
|
</button>
|
2025-02-13 08:25:57 -08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ArtifactCloseButton = memo(PureArtifactCloseButton, () => true);
|