Skip to content

Commit e1f997b

Browse files
committed
add render right option
1 parent 08d86a0 commit e1f997b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/js/CheckboxTree.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CheckboxTree extends React.Component {
2323
expandDisabled: PropTypes.bool,
2424
expandOnClick: PropTypes.bool,
2525
expanded: listShape,
26+
expanderRight: PropTypes.bool,
2627
icons: iconsShape,
2728
iconsClass: PropTypes.string,
2829
id: PropTypes.string,
@@ -48,6 +49,7 @@ class CheckboxTree extends React.Component {
4849
expandDisabled: false,
4950
expandOnClick: false,
5051
expanded: [],
52+
expanderRight: false,
5153
icons: {
5254
check: <span className="rct-icon rct-icon-check" />,
5355
uncheck: <span className="rct-icon rct-icon-uncheck" />,
@@ -208,6 +210,7 @@ class CheckboxTree extends React.Component {
208210
const {
209211
expandDisabled,
210212
expandOnClick,
213+
expanderRight,
211214
icons,
212215
lang,
213216
noCascade,
@@ -247,6 +250,7 @@ class CheckboxTree extends React.Component {
247250
className={node.className}
248251
disabled={flatNode.disabled}
249252
expandDisabled={expandDisabled}
253+
expanderRight={expanderRight}
250254
expandOnClick={expandOnClick}
251255
expanded={flatNode.expanded}
252256
icon={node.icon}

src/js/TreeNode.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class TreeNode extends React.Component {
1313
disabled: PropTypes.bool.isRequired,
1414
expandDisabled: PropTypes.bool.isRequired,
1515
expanded: PropTypes.bool.isRequired,
16+
expanderRight: PropTypes.bool.isRequired,
1617
icons: iconsShape.isRequired,
1718
isLeaf: PropTypes.bool.isRequired,
1819
isParent: PropTypes.bool.isRequired,
@@ -105,7 +106,9 @@ class TreeNode extends React.Component {
105106
}
106107

107108
renderCollapseButton() {
108-
const { expandDisabled, isLeaf, lang } = this.props;
109+
const {
110+
expandDisabled, isLeaf, lang, expanderRight,
111+
} = this.props;
109112

110113
if (isLeaf) {
111114
return (
@@ -117,7 +120,7 @@ class TreeNode extends React.Component {
117120

118121
return (
119122
<Button
120-
className="rct-collapse rct-collapse-btn"
123+
className={`rct-collapse rct-collapse-btn ${expanderRight ? 'rct-collapse-right' : ''}`}
121124
disabled={expandDisabled}
122125
title={lang.toggle}
123126
onClick={this.onExpand}
@@ -275,6 +278,7 @@ class TreeNode extends React.Component {
275278
className,
276279
disabled,
277280
expanded,
281+
expanderRight,
278282
isLeaf,
279283
} = this.props;
280284
const nodeClass = classNames({
@@ -289,8 +293,9 @@ class TreeNode extends React.Component {
289293
return (
290294
<li className={nodeClass}>
291295
<span className="rct-text">
292-
{this.renderCollapseButton()}
296+
{expanderRight ? null : this.renderCollapseButton() }
293297
{this.renderLabel()}
298+
{expanderRight ? this.renderCollapseButton() : null }
294299
</span>
295300
{this.renderChildren()}
296301
</li>

src/scss/react-checkbox-tree.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ $rct-clickable-focus: rgba($rct-icon-color, .2) !default;
147147
}
148148
}
149149

150+
.rct-collapse-right {
151+
margin-left: auto;
152+
}
153+
150154
.rct-checkbox {
151155
.rct-native-display & {
152156
display: none;

0 commit comments

Comments
 (0)