Skip to content

Commit 785f4b1

Browse files
author
Asgator
committed
Checkbox: add props 'type'
1 parent 099da42 commit 785f4b1

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

index.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,10 +1335,8 @@ export interface CheckboxProps extends BaseProps<Checkbox> {
13351335
disabled?: boolean;
13361336
name?: string;
13371337
onClick?: React.MouseEventHandler;
1338-
radio?: boolean;
13391338
readOnly?: boolean;
1340-
slider?: boolean;
1341-
toggle?: boolean;
1339+
type?: "default" | "radio" | "toggle" | "slider";
13421340
}
13431341
export class Checkbox extends React.Component<CheckboxProps, any> {
13441342
}

src/components/modules/checkbox/checkbox.jsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,13 @@ export default class Checkbox extends Component {
2323
*/
2424
onClick: React.PropTypes.func,
2525
/**
26-
* Checkbox - appearance
27-
*/
28-
radio: React.PropTypes.bool,
29-
/**
3026
* Attr name
3127
*/
3228
name: React.PropTypes.string,
3329
/**
3430
* Checkbox - appearance
3531
*/
36-
slider: React.PropTypes.bool,
37-
/**
38-
* Checkbox - appearance
39-
*/
40-
toggle: React.PropTypes.bool,
32+
type: React.PropTypes.oneOf(['default', 'radio', 'toggle', 'slider']),
4133
/**
4234
* A fitted checkbox does not leave padding for a label
4335
*/
@@ -46,6 +38,7 @@ export default class Checkbox extends Component {
4638

4739
static defaultProps = {
4840
...DefaultProps.defaultProps,
41+
type: 'default',
4942
onClick: () => { }
5043
};
5144

@@ -57,8 +50,8 @@ export default class Checkbox extends Component {
5750

5851
renderChildren() {
5952
/* eslint-disable no-use-before-define */
60-
let { children, defaultClasses, className, onClick,
61-
radio, slider, toggle, component, readOnly, checked, ...other } = this.props;
53+
let { children, defaultClasses, className, onClick, type,
54+
component, readOnly, checked, ...other } = this.props;
6255
/* eslint-enable no-use-before-define */
6356

6457
let childElements = [
@@ -79,7 +72,7 @@ export default class Checkbox extends Component {
7972

8073
render() {
8174
/* eslint-disable no-use-before-define */
82-
let { component, defaultClasses, checked, onClick, name, ...other } = this.props;
75+
let { component, defaultClasses, checked, type, onClick, name, ...other } = this.props;
8376
/* eslint-enable no-use-before-define */
8477

8578
other.className = classNames(this.props.className, this.getClasses());
@@ -101,12 +94,12 @@ export default class Checkbox extends Component {
10194
// positioning
10295

10396
// types
104-
radio: this.props.radio,
97+
radio: this.props.type == 'radio',
98+
slider: this.props.type == 'slider',
99+
toggle: this.props.type == 'toggle',
105100

106101
// variations
107102
fitted: this.props.fitted,
108-
slider: this.props.slider,
109-
toggle: this.props.toggle,
110103

111104
// state
112105
'read-only': this.props.readOnly,

0 commit comments

Comments
 (0)