@@ -27,6 +27,7 @@ npm install --save react-infinite-tree
27
27
28
28
## Example
29
29
30
+ #### Tree.jsx
30
31
``` jsx
31
32
< InfiniteTree
32
33
ref= {node => {
@@ -137,6 +138,66 @@ npm install --save react-infinite-tree
137
138
< / InfiniteTree>
138
139
```
139
140
141
+ #### render.jsx
142
+ ``` jsx
143
+ import React from ' react' ;
144
+ import styled from ' styled-components' ;
145
+
146
+ const rowHeight = 30 ;
147
+
148
+ export const TreeNode = styled .div `
149
+ cursor: default;
150
+ position: relative;
151
+ line-height: ${ rowHeight - 2 } px;
152
+ background: ${ props => props .selected ? ' #deecfd' : ' transparent' } ;
153
+ border: ${ props => props .selected ? ' 1px solid #06c' : ' 1px solid transparent' } ;
154
+ &:hover {
155
+ background: #f2fdff;
156
+ }
157
+ padding-left: ${ props => props .depth * 18 } px;
158
+ ` ;
159
+
160
+ export const Toggler = styled (({ state, ... props }) => (
161
+ < a {... props}>
162
+ {(state === ' expanded' ) &&
163
+ < i className= " fa fa-fw fa-chevron-right" / >
164
+ }
165
+ {(state === ' collapsed' ) &&
166
+ < i className= " fa fa-fw fa-chevron-down" / >
167
+ }
168
+ < / a>
169
+ ))`
170
+ color: #333;
171
+ display: inine-block;
172
+ text-align: center;
173
+ margin-right: 2px;
174
+ ` ;
175
+
176
+ export const Icon = ({ state, ... props }) => (
177
+ < span {... props}>
178
+ {(state === ' folder-open' ) &&
179
+ < i className= " fa fa-fw fa-folder-open-o" / >
180
+ }
181
+ {(state === ' folder' ) &&
182
+ < i className= " fa fa-fw fa-folder-o" / >
183
+ }
184
+ {(state === ' file' ) &&
185
+ < i className= " fa fa-fw fa-file-o" / >
186
+ }
187
+ < / span>
188
+ );
189
+
190
+ export const PointerCursor = styled .div `
191
+ display: inline-block;
192
+ cursor: pointer;
193
+ ` ;
194
+
195
+ export const Text = styled .span `
196
+ margin-left: 0 2px;
197
+ user-select: none;
198
+ ` ;
199
+ ```
200
+
140
201
## API Documentation
141
202
142
203
Check out API documentation at [ infinite-tree] ( https://github.com/cheton/infinite-tree/wiki ) :
0 commit comments