mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Change button variants from 'outline' to 'default' for consistency across components. Enhance FilePreview component with better spacing, borders, and file name display to improve visual clarity and user experience.
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
|
|
interface FilePreviewProps {
|
|
files: File[];
|
|
imageDataList: string[];
|
|
onRemove: (index: number) => void;
|
|
}
|
|
|
|
const FilePreview: React.FC<FilePreviewProps> = ({ files, imageDataList, onRemove }) => {
|
|
if (!files || files.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-row overflow-x-auto mx-2 -mt-1 p-2 bg-bolt-elements-background-depth-3 border border-b-none border-bolt-elements-borderColor rounded-lg rounded-b-none">
|
|
{files.map((file, index) => (
|
|
<div key={file.name + file.size} className="mr-2 relative">
|
|
{imageDataList[index] && (
|
|
<div className="relative">
|
|
<img
|
|
src={imageDataList[index]}
|
|
alt={file.name}
|
|
className="max-h-20 border border-bolt-elements-borderColor rounded-lg"
|
|
/>
|
|
<button
|
|
onClick={() => onRemove(index)}
|
|
className="absolute -top-1 -right-1 z-10 bg-black rounded-full w-5 h-5 shadow-md hover:bg-gray-900 transition-colors flex items-center justify-center"
|
|
>
|
|
<div className="i-ph:x w-3 h-3 text-gray-200" />
|
|
</button>
|
|
<div className="px-2 absolute bottom-0 w-full h-5 flex items-center border-t border-bolt-elements-borderColor text-bolt-elements-textTertiary font-thin text-xs">
|
|
<span className="truncate">{file.name}</span>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default FilePreview;
|