Created
October 21, 2015 14:15
-
-
Save Xananax/3f6ef7f6e260f28f30de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Directory extends Component{ | |
renderDirectories(){ | |
const {directories} = this.props; | |
if(!directories || !directories.length){ | |
return false; | |
} | |
return directories.map((dir,key)=> | |
<tr key={key}><td> | |
<Directory {...dir}/> | |
</td></tr> | |
) | |
} | |
renderFiles(){ | |
const {files} = this.props; | |
if(!files || !files.length){ | |
return false; | |
} | |
return files.map((file,key)=> | |
<tr key={key}> | |
<td>{file}</td> | |
</tr> | |
) | |
} | |
render(){ | |
const {name} = this.props; | |
return (<table name={name}> | |
<thead><tr><td>{name}</td></tr></thead> | |
<tbody> | |
{this.renderDirectories()} | |
{this.renderFiles()} | |
</tbody> | |
</table>) | |
} | |
} | |
const props = { | |
name:'Root' | |
directories:[ | |
{ | |
name:'dirA' | |
, directories:[ | |
{ | |
name:'dirB' | |
files:[ | |
'dirA/dirB/fileA' | |
, 'dirA/dirB/fileB' | |
] | |
} | |
] | |
, files:[ | |
'dirA/fileA' | |
] | |
} | |
] | |
, files:[ | |
'rootFile' | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table name="Root"> | |
<thead>Root</thead> | |
<tbody> | |
<tr><td> | |
<table name="DirA"> | |
<thead>DirA</thead> | |
<tbody> | |
<tr><td> | |
<table name="DirB"> | |
<thead>DirB</thead> | |
<tbody> | |
<tr><td> | |
dirA/dirB/fileA | |
</td></tr> | |
<tr><td> | |
dirA/dirB/fileB | |
</td></tr> | |
</tbody> | |
</table> | |
</td></tr> | |
<tr><td> | |
dirA/fileA | |
</td></tr> | |
</tbody> | |
</table> | |
</td></tr> | |
<tr><td> | |
rootFile | |
</td></tr> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment