Skip to content

Commit

Permalink
feat(icon): 添加三种状态的checkbox图标
Browse files Browse the repository at this point in the history
  • Loading branch information
beth committed May 20, 2018
1 parent c41a00c commit f0e430f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/component/Tree/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
font-weight: 300;
}

.TreeNode .checkbox img {
float: left;
width: 24px;
height: 24px;
}

.TreeNode .title-children {
display: inline-block;
margin-left: 20px;
Expand Down
23 changes: 17 additions & 6 deletions src/component/Tree/treeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { contextTypes } from './index';
import { toArray, getPosition, getNodeChildren, traverseTreeNodes } from './util';
import './index.css';

import checkbox1Img from '../../image/checkbox1.png';
import checkbox2Img from '../../image/checkbox2.png';
import checkbox3Img from '../../image/checkbox3.png';

const LOAD_STATUS_NONE = 0;

const defaultTitle = '---';
Expand Down Expand Up @@ -155,16 +159,23 @@ class TreeNode extends React.Component {
renderCheckbox = () => {
const { checked, halfChecked } = this.props;

let $checked = null;
if (halfChecked) {
$checked = (<img src={checkbox3Img} />);
} else if (checked) {
$checked = (<img src={checkbox2Img} />);
} else {
$checked = (<img src={checkbox1Img} />);
}

return (
<span>
{checked && 'select'}
{!checked && halfChecked && 'halfChecked'}
{!checked && 'default'}
{
<span className="checkbox" onClick={this.onCheck}>
{$checked}
{/*
checked ?
<input type="checkbox" checked onClick={this.onCheck} />
: <input type="checkbox" checked={false} onClick={this.onCheck} />
}
*/}
</span>
);
};
Expand Down
Binary file added src/image/checkbox1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/image/checkbox2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/image/checkbox3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f0e430f

Please sign in to comment.