2024-07-10 16:44:39 +00:00
|
|
|
import { useStore } from '@nanostores/react';
|
|
|
|
import { workspaceStore } from '~/lib/stores/workspace';
|
|
|
|
|
|
|
|
interface ArtifactProps {
|
|
|
|
messageId: string;
|
|
|
|
}
|
|
|
|
|
2024-07-12 15:25:41 +00:00
|
|
|
export function Artifact({ messageId }: ArtifactProps) {
|
2024-07-10 16:44:39 +00:00
|
|
|
const artifacts = useStore(workspaceStore.artifacts);
|
|
|
|
|
|
|
|
const artifact = artifacts[messageId];
|
|
|
|
|
|
|
|
return (
|
2024-07-12 15:25:41 +00:00
|
|
|
<button
|
|
|
|
className="flex border rounded-lg overflow-hidden items-stretch bg-gray-50/25 w-full"
|
|
|
|
onClick={() => {
|
|
|
|
const showWorkspace = workspaceStore.showWorkspace.get();
|
|
|
|
workspaceStore.showWorkspace.set(!showWorkspace);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className="border-r flex items-center px-6 bg-gray-100/50">
|
2024-07-10 16:44:39 +00:00
|
|
|
{!artifact?.closed ? (
|
|
|
|
<div className="i-svg-spinners:90-ring-with-bg scale-130"></div>
|
|
|
|
) : (
|
|
|
|
<div className="i-ph:code-bold scale-130 text-gray-600"></div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-col items-center px-4 p-2.5">
|
|
|
|
<div className="text-left w-full">{artifact?.title}</div>
|
|
|
|
<small className="w-full text-left">Click to open code</small>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|