Skip to content

Commit eb30848

Browse files
committed
feat: change theme to full-node drag theme
1 parent 1b2e6f7 commit eb30848

10 files changed

+259
-502
lines changed

CHANGELOG.md

-31
Original file line numberDiff line numberDiff line change
@@ -1,31 +0,0 @@
1-
# Change Log
2-
3-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4-
5-
<a name="1.1.2"></a>
6-
## [1.1.2](https://github.com/fritz-c/react-sortable-tree-theme-file-explorer/compare/v1.1.1...v1.1.2) (2017-11-28)
7-
8-
9-
### Bug Fixes
10-
11-
* silence warning on latest react-sortable-tree ([7c81d55](https://github.com/fritz-c/react-sortable-tree-theme-file-explorer/commit/7c81d55))
12-
13-
14-
15-
<a name="1.1.1"></a>
16-
## [1.1.1](https://github.com/fritz-c/react-sortable-tree-theme-file-explorer/compare/v1.1.0...v1.1.1) (2017-11-01)
17-
18-
19-
### Bug Fixes
20-
21-
* make canDrag work. Fixes [#5](https://github.com/fritz-c/react-sortable-tree-theme-file-explorer/issues/5) ([f82d6c1](https://github.com/fritz-c/react-sortable-tree-theme-file-explorer/commit/f82d6c1))
22-
23-
24-
25-
<a name="1.1.0"></a>
26-
# 1.1.0 (2017-10-29)
27-
28-
29-
### Features
30-
31-
* Complete basic appearance ([98a8d09](https://github.com/fritz-c/react-sortable-tree/commit/98a8d09))

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# React Sortable Tree File Explorer Theme
2-
![theme appearance](https://user-images.githubusercontent.com/4413963/32144463-a7de23e0-bcfc-11e7-8054-1a83d561261e.png)
1+
# React Sortable Tree Full Node Drag Theme
2+
<img alt="theme appearance" src="https://user-images.githubusercontent.com/4413963/33521792-61dc2c50-d81f-11e7-8ab1-359661a11ca4.png" width="500">
3+
34
## Features
4-
* You can click anywhere on a node to drag it.
5-
* More compact design, with indentation alone used to represent tree depth.
5+
* No drag handles. You can click anywhere on a node to drag it.
66

77
## Usage
88

99
```sh
10-
npm install --save react-sortable-tree-theme-file-explorer
10+
npm install --save react-sortable-tree-theme-full-node-drag
1111
```
1212

1313
```jsx
1414
import React, { Component } from 'react';
1515
import SortableTree from 'react-sortable-tree';
16-
import FileExplorerTheme from 'react-sortable-tree-theme-file-explorer';
16+
import FileExplorerTheme from 'react-sortable-tree-theme-full-node-drag';
1717

1818
export default class Tree extends Component {
1919
constructor(props) {

demo/app.css

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
body {
22
padding: 0;
33
margin: 0;
4+
background-color: #f1f1f1;
45
}

demo/app.js

+14-85
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import SortableTree, { toggleExpandedForAll } from 'react-sortable-tree';
3-
import FileExplorerTheme from '../index';
3+
import CustomTheme from '../index';
44
import './app.css';
55

66
class App extends Component {
@@ -12,44 +12,16 @@ class App extends Component {
1212
searchFocusIndex: 0,
1313
searchFoundCount: null,
1414
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' },
1717
{
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,
4921
},
22+
{ title: 'Chicken', children: [{ title: 'Egg' }] },
5023
],
5124
};
52-
5325
this.updateTreeData = this.updateTreeData.bind(this);
5426
this.expandAll = this.expandAll.bind(this);
5527
this.collapseAll = this.collapseAll.bind(this);
@@ -118,7 +90,7 @@ class App extends Component {
11890
style={{ display: 'flex', flexDirection: 'column', height: '100vh' }}
11991
>
12092
<div style={{ flex: '0 0 auto', padding: '0 15px' }}>
121-
<h3>File Explorer Theme</h3>
93+
<h3>Full Node Drag Theme</h3>
12294
<button onClick={this.expandAll}>Expand All</button>
12395
<button onClick={this.collapseAll}>Collapse All</button>
12496
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
@@ -135,7 +107,8 @@ class App extends Component {
135107
type="text"
136108
value={searchString}
137109
onChange={event =>
138-
this.setState({ searchString: event.target.value })}
110+
this.setState({ searchString: event.target.value })
111+
}
139112
/>
140113
</label>
141114

@@ -166,7 +139,7 @@ class App extends Component {
166139

167140
<div style={{ flex: '1 0 50%', padding: '0 0 0 15px' }}>
168141
<SortableTree
169-
theme={FileExplorerTheme}
142+
theme={CustomTheme}
170143
treeData={treeData}
171144
onChange={this.updateTreeData}
172145
searchQuery={searchString}
@@ -176,56 +149,12 @@ class App extends Component {
176149
searchFoundCount: matches.length,
177150
searchFocusIndex:
178151
matches.length > 0 ? searchFocusIndex % matches.length : 0,
179-
})}
152+
})
153+
}
180154
canDrag={({ node }) => !node.dragDisabled}
181-
canDrop={({ nextParent }) => !nextParent || nextParent.isDirectory}
182155
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-
],
213156
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>,
229158
],
230159
})}
231160
/>

index.js

-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111
// placeholderRenderer: PropTypes.func,
1212

1313
import nodeContentRenderer from './node-content-renderer';
14-
import treeNodeRenderer from './tree-node-renderer';
1514

1615
module.exports = {
1716
nodeContentRenderer,
18-
treeNodeRenderer,
19-
scaffoldBlockPxWidth: 25,
20-
rowHeight: 25,
21-
slideRegionSize: 50,
2217
};

0 commit comments

Comments
 (0)