mirror of
https://github.com/azaion/ui.git
synced 2026-04-22 11:36:35 +00:00
add button to open files and folders
This commit is contained in:
@@ -3,14 +3,21 @@ import { useDropzone } from 'react-dropzone';
|
|||||||
import './MediaList.css'
|
import './MediaList.css'
|
||||||
|
|
||||||
function MediaList({ files, selectedFile, onFileSelect, onDropNewFiles }) {
|
function MediaList({ files, selectedFile, onFileSelect, onDropNewFiles }) {
|
||||||
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
const { getRootProps, getInputProps, isDragActive, open: openFileDialog } = useDropzone({
|
||||||
onDrop: onDropNewFiles,
|
onDrop: onDropNewFiles,
|
||||||
|
multiple: true,
|
||||||
});
|
});
|
||||||
|
const { getRootProps: getFolderRootProps, getInputProps: getFolderInputProps, open: openFolderDialog } = useDropzone({
|
||||||
|
onDrop: onDropNewFiles,
|
||||||
|
multiple: true
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
const [filteredFiles, setFilteredFiles] = useState(files);
|
const [filteredFiles, setFilteredFiles] = useState(files);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(() => {
|
||||||
setFilteredFiles(files);
|
setFilteredFiles(files);
|
||||||
},[files])
|
}, [files])
|
||||||
|
|
||||||
|
|
||||||
const handleInputChange = (e) => {
|
const handleInputChange = (e) => {
|
||||||
@@ -22,7 +29,13 @@ function MediaList({ files, selectedFile, onFileSelect, onDropNewFiles }) {
|
|||||||
return (
|
return (
|
||||||
<div className='explorer'>
|
<div className='explorer'>
|
||||||
<h3 className='menu-title' >Files</h3>
|
<h3 className='menu-title' >Files</h3>
|
||||||
<input className='file-filter' type='text' placeholder='Filename' onChange={handleInputChange}/>
|
<button type="button" onClick={openFileDialog}>
|
||||||
|
Open File
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={openFolderDialog}>
|
||||||
|
Open Folder
|
||||||
|
</button>
|
||||||
|
<input className='file-filter' type='text' placeholder='Filename' onChange={handleInputChange} />
|
||||||
<ul className='file-list-group' >
|
<ul className='file-list-group' >
|
||||||
{filteredFiles.map((file) => (
|
{filteredFiles.map((file) => (
|
||||||
<li
|
<li
|
||||||
@@ -39,6 +52,9 @@ function MediaList({ files, selectedFile, onFileSelect, onDropNewFiles }) {
|
|||||||
</ul>
|
</ul>
|
||||||
<div className='file-input-block' {...getRootProps()} >
|
<div className='file-input-block' {...getRootProps()} >
|
||||||
<input {...getInputProps()} />
|
<input {...getInputProps()} />
|
||||||
|
<div style={{ display: 'none' }}>
|
||||||
|
<input {...getFolderInputProps()} webkitdirectory="true" mozdirectory="true" />
|
||||||
|
</div>
|
||||||
{isDragActive ? (
|
{isDragActive ? (
|
||||||
<p className='label' >Drop here</p>
|
<p className='label' >Drop here</p>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user