Skip to content

Commit

Permalink
add mode select
Browse files Browse the repository at this point in the history
  • Loading branch information
gfazioli committed Feb 9, 2017
1 parent 4ea29e7 commit 16cda41
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 22 deletions.
10 changes: 10 additions & 0 deletions dist/react-switch-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
margin-left: 24px;
background-color: #d5d5d5;
}
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label:after,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label {
background-color: #579fcb !important;
}
/**
* React Switch Button control style square.
*
Expand Down Expand Up @@ -217,3 +222,8 @@
margin-left: 24px;
background-color: #d5d5d5;
}
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label:after,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label {
background-color: #579fcb !important;
}
13 changes: 10 additions & 3 deletions dist/react-switch-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var SwitchButton = React.createClass({
displayName: 'Switch Button',

// Version
version: '2.1.0',
version: '2.2.0',

/**
* The props types.
Expand All @@ -25,6 +25,7 @@ var SwitchButton = React.createClass({
disabled: React.PropTypes.bool,
theme: React.PropTypes.string,
checked: React.PropTypes.string,
mode: React.PropTypes.string,
onChange: React.PropTypes.func
},

Expand All @@ -44,6 +45,7 @@ var SwitchButton = React.createClass({
defaultChecked: false,
theme: 'rsbc-switch-button-flat-round',
checked: null,
mode: "switch",
onChange: this.handleChange
};
},
Expand All @@ -61,7 +63,8 @@ var SwitchButton = React.createClass({
render: function render() {
var id = undefined,
label = undefined,
labelRight = undefined;
labelRight = undefined,
mode = this.props.mode || "switch";

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

return React.createElement('div', { className: 'rsbc-switch-button ' + this.props.theme + (this.props.disabled ? " disabled" : "") }, label, React.createElement('input', { onChange: this.props.onChange,
if (['switch', 'select'].indexOf(mode) < -1) {
mode = "switch";
}

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,
defaultChecked: this.props.defaultChecked,
disabled: this.props.disabled,
id: id, name: this.props.name,
Expand Down
2 changes: 1 addition & 1 deletion dist/react-switch-button.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/react-switch-button.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions example/dist/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@
margin-left: 24px;
background-color: #d5d5d5;
}
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label:after,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-round.rsbc-mode-select input[type="checkbox"] + label {
background-color: #579fcb !important;
}
/**
* React Switch Button control style square.
*
Expand Down Expand Up @@ -222,6 +227,11 @@
margin-left: 24px;
background-color: #d5d5d5;
}
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label:after,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select:hover input[type="checkbox"]:checked + label,
.rsbc-switch-button.rsbc-switch-button.rsbc-switch-button-flat-square.rsbc-mode-select input[type="checkbox"] + label {
background-color: #579fcb !important;
}
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
Expand Down
Loading

0 comments on commit 16cda41

Please sign in to comment.