Skip to content

Custom collapse icon #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updating version
  • Loading branch information
whortaneto committed Apr 19, 2017
commit 8a211c7ff5c5b720f99b0b2d5484977dfba6ccd2
18 changes: 12 additions & 6 deletions dist/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ var Node = React.createClass({

renderCollapse: function renderCollapse() {
var index = this.props.index;
var renderCollapse = this.props.renderCollapse;

if (index.children && index.children.length) {
var collapsed = index.node.collapsed;

return React.createElement('span', {
className: cx('collapse', collapsed ? 'caret-right' : 'caret-down'),
onMouseDown: function onMouseDown(e) {
e.stopPropagation();
return React.createElement(
'span',
{
onMouseDown: function onMouseDown(e) {
e.stopPropagation();
},
onClick: this.handleCollapse
},
onClick: this.handleCollapse });
renderCollapse(collapsed)
);
}

return null;
Expand Down Expand Up @@ -47,7 +52,8 @@ var Node = React.createClass({
dragging: dragging,
paddingLeft: _this.props.paddingLeft,
onCollapse: _this.props.onCollapse,
onDragStart: _this.props.onDragStart
onDragStart: _this.props.onDragStart,
renderCollapse: _this.props.renderCollapse
});
})
);
Expand Down
6 changes: 4 additions & 2 deletions dist/react-ui-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ module.exports = React.createClass({
React.createElement(Node, {
tree: tree,
index: draggingIndex,
paddingLeft: this.props.paddingLeft
paddingLeft: this.props.paddingLeft,
renderCollapse: this.props.renderCollapse
})
);
}
Expand All @@ -83,7 +84,8 @@ module.exports = React.createClass({
paddingLeft: this.props.paddingLeft,
onDragStart: this.dragStart,
onCollapse: this.toggleCollapse,
dragging: dragging && dragging.id
dragging: dragging && dragging.id,
renderCollapse: this.props.renderCollapse
})
);
},
Expand Down
1 change: 1 addition & 0 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var App = React.createClass({
},

renderCollapse(collapsed) {
debugger;
return (
<span
className={cx('collapse', collapsed ? 'caret-right' : 'caret-down')}
Expand Down