1
1
import React , { Component } from 'react' ;
2
2
import SortableTree , { toggleExpandedForAll } from 'react-sortable-tree' ;
3
- import FileExplorerTheme from '../index' ;
3
+ import CustomTheme from '../index' ;
4
4
import './app.css' ;
5
5
6
6
class App extends Component {
@@ -12,44 +12,16 @@ class App extends Component {
12
12
searchFocusIndex : 0 ,
13
13
searchFoundCount : null ,
14
14
treeData : [
15
- { title : '.gitignore ' } ,
16
- { title : 'package.json ' } ,
15
+ { title : 'This is the Full Node Drag theme ' } ,
16
+ { title : 'You can click anywhere on the node to drag it ' } ,
17
17
{
18
- title : 'src' ,
19
- isDirectory : true ,
20
- expanded : true ,
21
- children : [
22
- { title : 'styles.css' } ,
23
- { title : 'index.js' } ,
24
- { title : 'reducers.js' } ,
25
- { title : 'actions.js' } ,
26
- { title : 'utils.js' } ,
27
- ] ,
28
- } ,
29
- {
30
- title : 'tmp' ,
31
- isDirectory : true ,
32
- children : [
33
- { title : '12214124-log' } ,
34
- { title : 'drag-disabled-file' , dragDisabled : true } ,
35
- ] ,
36
- } ,
37
- {
38
- title : 'build' ,
39
- isDirectory : true ,
40
- children : [ { title : 'react-sortable-tree.js' } ] ,
41
- } ,
42
- {
43
- title : 'public' ,
44
- isDirectory : true ,
45
- } ,
46
- {
47
- title : 'node_modules' ,
48
- isDirectory : true ,
18
+ title : 'This node has dragging disabled' ,
19
+ subtitle : 'Note how the hover behavior is different' ,
20
+ dragDisabled : true ,
49
21
} ,
22
+ { title : 'Chicken' , children : [ { title : 'Egg' } ] } ,
50
23
] ,
51
24
} ;
52
-
53
25
this . updateTreeData = this . updateTreeData . bind ( this ) ;
54
26
this . expandAll = this . expandAll . bind ( this ) ;
55
27
this . collapseAll = this . collapseAll . bind ( this ) ;
@@ -118,7 +90,7 @@ class App extends Component {
118
90
style = { { display : 'flex' , flexDirection : 'column' , height : '100vh' } }
119
91
>
120
92
< div style = { { flex : '0 0 auto' , padding : '0 15px' } } >
121
- < h3 > File Explorer Theme</ h3 >
93
+ < h3 > Full Node Drag Theme</ h3 >
122
94
< button onClick = { this . expandAll } > Expand All</ button >
123
95
< button onClick = { this . collapseAll } > Collapse All</ button >
124
96
@@ -135,7 +107,8 @@ class App extends Component {
135
107
type = "text"
136
108
value = { searchString }
137
109
onChange = { event =>
138
- this . setState ( { searchString : event . target . value } ) }
110
+ this . setState ( { searchString : event . target . value } )
111
+ }
139
112
/>
140
113
</ label >
141
114
@@ -166,7 +139,7 @@ class App extends Component {
166
139
167
140
< div style = { { flex : '1 0 50%' , padding : '0 0 0 15px' } } >
168
141
< SortableTree
169
- theme = { FileExplorerTheme }
142
+ theme = { CustomTheme }
170
143
treeData = { treeData }
171
144
onChange = { this . updateTreeData }
172
145
searchQuery = { searchString }
@@ -176,56 +149,12 @@ class App extends Component {
176
149
searchFoundCount : matches . length ,
177
150
searchFocusIndex :
178
151
matches . length > 0 ? searchFocusIndex % matches . length : 0 ,
179
- } ) }
152
+ } )
153
+ }
180
154
canDrag = { ( { node } ) => ! node . dragDisabled }
181
- canDrop = { ( { nextParent } ) => ! nextParent || nextParent . isDirectory }
182
155
generateNodeProps = { rowInfo => ( {
183
- icons : rowInfo . node . isDirectory
184
- ? [
185
- < div
186
- style = { {
187
- borderLeft : 'solid 8px gray' ,
188
- borderBottom : 'solid 10px gray' ,
189
- marginRight : 10 ,
190
- width : 16 ,
191
- height : 12 ,
192
- filter : rowInfo . node . expanded
193
- ? 'drop-shadow(1px 0 0 gray) drop-shadow(0 1px 0 gray) drop-shadow(0 -1px 0 gray) drop-shadow(-1px 0 0 gray)'
194
- : 'none' ,
195
- borderColor : rowInfo . node . expanded ? 'white' : 'gray' ,
196
- } }
197
- /> ,
198
- ]
199
- : [
200
- < div
201
- style = { {
202
- border : 'solid 1px black' ,
203
- fontSize : 8 ,
204
- textAlign : 'center' ,
205
- marginRight : 10 ,
206
- width : 12 ,
207
- height : 16 ,
208
- } }
209
- >
210
- F
211
- </ div > ,
212
- ] ,
213
156
buttons : [
214
- < button
215
- style = { {
216
- padding : 0 ,
217
- borderRadius : '100%' ,
218
- backgroundColor : 'gray' ,
219
- color : 'white' ,
220
- width : 16 ,
221
- height : 16 ,
222
- border : 0 ,
223
- fontWeight : 100 ,
224
- } }
225
- onClick = { ( ) => alertNodeInfo ( rowInfo ) }
226
- >
227
- i
228
- </ button > ,
157
+ < button onClick = { ( ) => alertNodeInfo ( rowInfo ) } > i</ button > ,
229
158
] ,
230
159
} ) }
231
160
/>
0 commit comments