mirror of
https://github.com/azaion/ui.git
synced 2026-04-22 07:06:35 +00:00
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import { useDropzone } from 'react-dropzone';
|
|
import './MediaList.css'
|
|
|
|
function MediaList({ files, selectedFile, onFileSelect, onDropNewFiles }) {
|
|
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
onDrop: onDropNewFiles,
|
|
});
|
|
|
|
return (
|
|
<div className='explorer'>
|
|
<h3 className='menu-title' >Files</h3>
|
|
<ul className='file-list-group' >
|
|
{files.map((file) => (
|
|
<li
|
|
className='file-list-item'
|
|
key={file.name}
|
|
style={{
|
|
backgroundColor: selectedFile === file ? '#f0f0f0' : 'transparent'
|
|
}}
|
|
onClick={() => onFileSelect(file)}
|
|
>
|
|
{file.name}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<div className='file-input-block' {...getRootProps()} >
|
|
<input {...getInputProps()} />
|
|
{isDragActive ? (
|
|
<p className='label' >Drop here</p>
|
|
) : (
|
|
<p className='label' >Drag new files</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default MediaList; |