-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
98 lines (92 loc) · 3.4 KB
/
index.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<title>Nested-file-tree Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body>
<div class="container">
<h1>Nested File Tree demo</h1>
<a href="https://github.com/woodpig07/react-nested-file-tree">Code and Docs on GitHub</a>
<section>
<h2>Directory with pre-selected file and file click handler</h2>
<div id="demo1" class="demo"></div>
<div class="code"><pre><code>
class Demo1 extends Component {
constructor (props) {
super(props)
this.state = {
selectedFile: '.gitignore'
}
}
handleFileClick (file) {
console.log(file)
this.setState({ selectedFile: file.path })
}
render () {
return (
<NestedFileTreeView
selectedFilePath={this.state.selectedFile}
fileClickHandler={::this.handleFileClick}
directory={directory} />
)
}
}
</code></pre></div>
</section>
<section>
<h2>Directory with max folder level 3 and expend by default</h2>
<div id="demo2" class="demo"></div>
<div class="code"><pre><code>
function Demo2 () {
return (
<NestedFileTreeView
expended
maxFolderLevel={3}
directory={directory} />
)
}
</code></pre></div>
</section>
<section>
<h2>Directory with custom folder and file templates</h2>
<div id="demo3" class="demo"></div>
<div class="code"><pre><code>
function CustomFolder (props) {
return (
<a onClick={props.onclick}><span className='svg'
dangerouslySetInnerHTML={{__html: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="24" height="24" viewBox="0 0 24.00 24.00" enable-background="new 0 0 24.00 24.00" xml:space="preserve">' +
'<path d="M0 0h24v24H0z" fill="none"></path>' +
'<path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"></path>' +
'</svg>'}} />
{ props.name }
</a>
)
}
function CustomFile (props) {
return (
<a><span className='svg'
dangerouslySetInnerHTML={{__html: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="24" height="24" viewBox="0 0 24.00 24.00" enable-background="new 0 0 24.00 24.00" xml:space="preserve">' +
'<path d="M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M15,18V16H6V18H15M18,14V12H6V14H18Z"></path>' +
'</svg>'}} />
{ props.name }
</a>
)
}
function Demo3 () {
return (
<NestedFileTreeView
expended
maxFolderLevel={3}
fileTemplate={CustomFile}
folderTemplate={CustomFolder}
directory={directory} />
)
}
</code></pre></div>
</section>
</div>
</body>
</html>