forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.tsx
More file actions
43 lines (36 loc) · 936 Bytes
/
Directory.tsx
File metadata and controls
43 lines (36 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import * as React from 'react';
import File from '../File';
import ModuleList from '../ModuleList';
import { IFiles } from '../../../types';
export interface Props {
prefixedPath: string;
files: IFiles;
selectFile: (path: string) => void;
openedPath: string;
depth: number;
}
export default class Directory extends React.Component<Props> {
state = {
open: true,
};
toggleOpen = () => {
this.setState({ open: !this.state.open });
};
render() {
const { prefixedPath, files, selectFile, openedPath, depth } = this.props;
return (
<div key={prefixedPath}>
<File onClick={this.toggleOpen} path={prefixedPath + '/'} />
{this.state.open && (
<ModuleList
prefixedPath={prefixedPath}
files={files}
selectFile={selectFile}
openedPath={openedPath}
depth={depth}
/>
)}
</div>
);
}
}