Skip to content

Commit 16cda41

Browse files
committed
add mode select
1 parent 4ea29e7 commit 16cda41

13 files changed

Lines changed: 104 additions & 22 deletions

dist/react-switch-button.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@
132132
margin-left: 24px;
133133
background-color: #d5d5d5;
134134
}
135+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label:after,
136+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
137+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label {
138+
background-color: #579fcb !important;
139+
}
135140
/**
136141
* React Switch Button control style square.
137142
*
@@ -217,3 +222,8 @@
217222
margin-left: 24px;
218223
background-color: #d5d5d5;
219224
}
225+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label:after,
226+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
227+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label {
228+
background-color: #579fcb !important;
229+
}

dist/react-switch-button.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var SwitchButton = React.createClass({
1010
displayName: 'Switch Button',
1111

1212
// Version
13-
version: '2.1.0',
13+
version: '2.2.0',
1414

1515
/**
1616
* The props types.
@@ -25,6 +25,7 @@ var SwitchButton = React.createClass({
2525
disabled: React.PropTypes.bool,
2626
theme: React.PropTypes.string,
2727
checked: React.PropTypes.string,
28+
mode: React.PropTypes.string,
2829
onChange: React.PropTypes.func
2930
},
3031

@@ -44,6 +45,7 @@ var SwitchButton = React.createClass({
4445
defaultChecked: false,
4546
theme: 'rsbc-switch-button-flat-round',
4647
checked: null,
48+
mode: "switch",
4749
onChange: this.handleChange
4850
};
4951
},
@@ -61,7 +63,8 @@ var SwitchButton = React.createClass({
6163
render: function render() {
6264
var id = undefined,
6365
label = undefined,
64-
labelRight = undefined;
66+
labelRight = undefined,
67+
mode = this.props.mode || "switch";
6568

6669
if (this.props.id === '' && this.props.name !== '') {
6770
id = this.props.name;
@@ -75,7 +78,11 @@ var SwitchButton = React.createClass({
7578
labelRight = React.createElement('label', { htmlFor: id }, this.props.labelRight);
7679
}
7780

78-
return React.createElement('div', { className: 'rsbc-switch-button ' + this.props.theme + (this.props.disabled ? " disabled" : "") }, label, React.createElement('input', { onChange: this.props.onChange,
81+
if (['switch', 'select'].indexOf(mode) < -1) {
82+
mode = "switch";
83+
}
84+
85+
return React.createElement('div', { className: 'rsbc-switch-button rsbc-mode-' + mode + ' ' + this.props.theme + (this.props.disabled ? " disabled" : "") }, label, React.createElement('input', { onChange: this.props.onChange,
7986
defaultChecked: this.props.defaultChecked,
8087
disabled: this.props.disabled,
8188
id: id, name: this.props.name,

dist/react-switch-button.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-switch-button.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/dist/app.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@
137137
margin-left: 24px;
138138
background-color: #d5d5d5;
139139
}
140+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label:after,
141+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
142+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label {
143+
background-color: #579fcb !important;
144+
}
140145
/**
141146
* React Switch Button control style square.
142147
*
@@ -222,6 +227,11 @@
222227
margin-left: 24px;
223228
background-color: #d5d5d5;
224229
}
230+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label:after,
231+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
232+
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label {
233+
background-color: #579fcb !important;
234+
}
225235
body {
226236
font-family: Helvetica, Arial, sans-serif;
227237
font-size: 14px;

0 commit comments

Comments
 (0)