initial commit
This commit is contained in:
33
src/components/FileBrowserElement.tsx
Normal file
33
src/components/FileBrowserElement.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import React from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { Directory, File } from "../generated/graphql"
|
||||
import DirectoryComponent from "./DirectoryElement"
|
||||
import FileElement from "./FileElement"
|
||||
|
||||
interface Props {
|
||||
file?: File | null
|
||||
dir?: Directory | null
|
||||
onClick?: (data: File | Directory) => void
|
||||
}
|
||||
|
||||
const FileBrowserElement: React.FC<Props> = (props) => {
|
||||
return (
|
||||
<div onClick={()=>{
|
||||
if(props.file){
|
||||
props.onClick?.(props.file)
|
||||
}else if(props.dir){
|
||||
props.onClick?.(props.dir)
|
||||
}
|
||||
}}>
|
||||
{(props.file) ? <FileElement file={props.file}/>:(props.dir)?<DirectoryComponent dir={props.dir} />:<></>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
FileBrowserElement.propTypes = {
|
||||
dir: PropTypes.any,
|
||||
file: PropTypes.any,
|
||||
onClick: PropTypes.func
|
||||
}
|
||||
|
||||
export default FileBrowserElement
|
||||
Reference in New Issue
Block a user