Skip to content

Commit 5d62e22

Browse files
authored
Update README.md
1 parent 698c3c5 commit 5d62e22

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ npm install --save react-infinite-tree
2727

2828
## Example
2929

30+
#### Tree.jsx
3031
```jsx
3132
<InfiniteTree
3233
ref={node => {
@@ -137,6 +138,66 @@ npm install --save react-infinite-tree
137138
</InfiniteTree>
138139
```
139140

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+
140201
## API Documentation
141202

142203
Check out API documentation at [infinite-tree](https://github.com/cheton/infinite-tree/wiki):

0 commit comments

Comments
 (0)