From 59b60ae0c978d1e33c04932711e1e6d7ae0a5bbb Mon Sep 17 00:00:00 2001 From: Oleksii Date: Tue, 17 May 2016 17:24:21 +0800 Subject: [PATCH 1/2] remove default-checked --- src/react-switch-button.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/react-switch-button.js b/src/react-switch-button.js index 31b3453..1fd3190 100644 --- a/src/react-switch-button.js +++ b/src/react-switch-button.js @@ -48,7 +48,6 @@ var SwitchButton = React.createClass( { title : React.PropTypes.string, label : React.PropTypes.string, labelRight : React.PropTypes.string, - defaultChecked : React.PropTypes.string, theme : React.PropTypes.string, checked : React.PropTypes.string, onChange : React.PropTypes.func @@ -58,7 +57,7 @@ var SwitchButton = React.createClass( { /** * Default propos. * - * @returns {{id: string, name: string, title: string, label: string, labelRight: string, defaultChecked: string, theme: string, checked: null, onChange: *}} + * @returns {{id: string, name: string, title: string, label: string, labelRight: string, theme: string, checked: null, onChange: *}} */ getDefaultProps : function() { @@ -68,7 +67,6 @@ var SwitchButton = React.createClass( { title : '', label : '', labelRight : '', - defaultChecked : '', theme : 'rsbc-switch-button-flat-round', checked : null, onChange : this.handleChange @@ -109,7 +107,7 @@ var SwitchButton = React.createClass( { return (
{label} - {labelRight} From 083843382ced22c56c2a326435554ae6593668f3 Mon Sep 17 00:00:00 2001 From: Oleksii Date: Tue, 17 May 2016 17:47:37 +0800 Subject: [PATCH 2/2] upd --- dist/react-switch-button.js | 6 ++---- dist/react-switch-button.min.js | 2 +- example/assets/react-switch-button.min.css | 1 + example/assets/react-switch-button.min.js | 2 +- javascripts/react-switch-button.js | 6 ++---- package.json | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 example/assets/react-switch-button.min.css diff --git a/dist/react-switch-button.js b/dist/react-switch-button.js index 70199be..bb11cbb 100644 --- a/dist/react-switch-button.js +++ b/dist/react-switch-button.js @@ -49,7 +49,6 @@ title: React.PropTypes.string, label: React.PropTypes.string, labelRight: React.PropTypes.string, - defaultChecked: React.PropTypes.string, theme: React.PropTypes.string, checked: React.PropTypes.string, onChange: React.PropTypes.func @@ -58,7 +57,7 @@ /** * Default propos. * - * @returns {{id: string, name: string, title: string, label: string, labelRight: string, defaultChecked: string, theme: string, checked: null, onChange: *}} + * @returns {{id: string, name: string, title: string, label: string, labelRight: string, theme: string, checked: null, onChange: *}} */ getDefaultProps: function () { return { @@ -67,7 +66,6 @@ title: '', label: '', labelRight: '', - defaultChecked: '', theme: 'rsbc-switch-button-flat-round', checked: null, onChange: this.handleChange @@ -111,7 +109,7 @@ 'div', { className: 'rsbc-switch-button ' + this.props.theme }, label, - React.createElement('input', { onChange: this.props.onChange, checked: this.props.checked, defaultChecked: this.props.defaultChecked, + React.createElement('input', { onChange: this.props.onChange, checked: this.props.checked, id: id, name: this.props.name, type: 'checkbox', value: '1' }), React.createElement('label', { htmlFor: id }), labelRight diff --git a/dist/react-switch-button.min.js b/dist/react-switch-button.min.js index 636b9f3..b2eb67a 100644 --- a/dist/react-switch-button.min.js +++ b/dist/react-switch-button.min.js @@ -1 +1 @@ -"use strict";(function(root,factory){if(typeof define==="function"&&define.amd){define(["react"],factory)}else if(typeof module==="object"&&module.exports){module.exports=factory(require("react"))}else{root.SwitchButton=factory(root.React)}})(this,function(React){var SwitchButton=React.createClass({displayName:"Switch Button",version:"1.0.4",propTypes:{id:React.PropTypes.string,name:React.PropTypes.string,title:React.PropTypes.string,label:React.PropTypes.string,labelRight:React.PropTypes.string,defaultChecked:React.PropTypes.string,theme:React.PropTypes.string,checked:React.PropTypes.string,onChange:React.PropTypes.func},getDefaultProps:function(){return{id:"",name:"switch-button",title:"",label:"",labelRight:"",defaultChecked:"",theme:"rsbc-switch-button-flat-round",checked:null,onChange:this.handleChange}},handleChange:function(){},render:function(){var id,label,labelRight;if(this.props.id==""&&this.props.name!=""){id=this.props.name}if(this.props.label!=""){label=React.createElement("label",{htmlFor:id},this.props.label)}if(this.props.labelRight!=""){labelRight=React.createElement("label",{htmlFor:id},this.props.labelRight)}return React.createElement("div",{className:"rsbc-switch-button "+this.props.theme},label,React.createElement("input",{onChange:this.props.onChange,checked:this.props.checked,defaultChecked:this.props.defaultChecked,id:id,name:this.props.name,type:"checkbox",value:"1"}),React.createElement("label",{htmlFor:id}),labelRight)}});return SwitchButton}); \ No newline at end of file +"use strict";(function(root,factory){if(typeof define==="function"&&define.amd){define(["react"],factory)}else if(typeof module==="object"&&module.exports){module.exports=factory(require("react"))}else{root.SwitchButton=factory(root.React)}})(this,function(React){var SwitchButton=React.createClass({displayName:"Switch Button",version:"1.0.4",propTypes:{id:React.PropTypes.string,name:React.PropTypes.string,title:React.PropTypes.string,label:React.PropTypes.string,labelRight:React.PropTypes.string,theme:React.PropTypes.string,checked:React.PropTypes.string,onChange:React.PropTypes.func},getDefaultProps:function(){return{id:"",name:"switch-button",title:"",label:"",labelRight:"",theme:"rsbc-switch-button-flat-round",checked:null,onChange:this.handleChange}},handleChange:function(){},render:function(){var id,label,labelRight;if(this.props.id==""&&this.props.name!=""){id=this.props.name}if(this.props.label!=""){label=React.createElement("label",{htmlFor:id},this.props.label)}if(this.props.labelRight!=""){labelRight=React.createElement("label",{htmlFor:id},this.props.labelRight)}return React.createElement("div",{className:"rsbc-switch-button "+this.props.theme},label,React.createElement("input",{onChange:this.props.onChange,checked:this.props.checked,id:id,name:this.props.name,type:"checkbox",value:"1"}),React.createElement("label",{htmlFor:id}),labelRight)}});return SwitchButton}); \ No newline at end of file diff --git a/example/assets/react-switch-button.min.css b/example/assets/react-switch-button.min.css new file mode 100644 index 0000000..bf3729e --- /dev/null +++ b/example/assets/react-switch-button.min.css @@ -0,0 +1 @@ +.rsbc-switch-button{position:relative;line-height:100%;display:inline-block;vertical-align:middle;margin:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.rsbc-switch-button label{cursor:pointer}.rsbc-switch-button input[type="checkbox"]{position:absolute;margin-left:-9999px;visibility:hidden}.rsbc-switch-button>label:first-child{display:inline-block;min-width:140px;text-align:right;margin:0 6px 0 12px}.rsbc-switch-button label+label{margin-left:6px}.rsbc-switch-button input[type="checkbox"]+label{display:inline-block;position:relative;margin:0;outline:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.rsbc-switch-button.rsbc-switch-button-flat-round input[type="checkbox"]+label{padding:2px;width:48px;height:24px;vertical-align:middle;background-color:#eee;-webkit-border-radius:60px;-moz-border-radius:60px;border-radius:60px;-webkit-transition:background .4s;-moz-transition:background .4s;-o-transition:background .4s;transition:background .4s}.rsbc-switch-button.rsbc-switch-button-flat-round:hover input[type="checkbox"]+label{background-color:#6f6f6f}.rsbc-switch-button.rsbc-switch-button-flat-round input[type="checkbox"]+label:before,.rsbc-switch-button.rsbc-switch-button-flat-round input[type="checkbox"]+label:after{display:inline-block;position:absolute;content:""}.rsbc-switch-button.rsbc-switch-button-flat-round input[type="checkbox"]+label:before{top:2px;left:2px;bottom:2px;right:2px;background-color:#fff;-webkit-border-radius:60px;-moz-border-radius:60px;border-radius:60px;-webkit-transition:background .4s;-moz-transition:background .4s;-o-transition:background .4s;transition:background .4s}.rsbc-switch-button.rsbc-switch-button-flat-round input[type="checkbox"]+label:after{top:4px;left:4px;bottom:4px;width:16px;background-color:#d5d5d5;-webkit-border-radius:52px;-moz-border-radius:52px;border-radius:52px;-webkit-transition:margin .4s,background .4s;-moz-transition:margin .4s,background .4s;-o-transition:margin .4s,background .4s;transition:margin .4s,background .4s}.rsbc-switch-button.rsbc-switch-button-flat-round input[type="checkbox"]:checked+label{background-color:#579fcb}.rsbc-switch-button.rsbc-switch-button-flat-round input[type="checkbox"]:checked+label:after{margin-left:24px;background-color:#3887b7} \ No newline at end of file diff --git a/example/assets/react-switch-button.min.js b/example/assets/react-switch-button.min.js index 80060ce..b2eb67a 100644 --- a/example/assets/react-switch-button.min.js +++ b/example/assets/react-switch-button.min.js @@ -1 +1 @@ -"use strict";var React=window.React||require("react");var SwitchButton=React.createClass({displayName:"Switch Button",version:"1.0.4",propTypes:{id:React.PropTypes.string,name:React.PropTypes.string,title:React.PropTypes.string,label:React.PropTypes.string,label_right:React.PropTypes.string,labelRight:React.PropTypes.string,defaultChecked:React.PropTypes.string,theme:React.PropTypes.string,checked:React.PropTypes.string,onChange:React.PropTypes.func},getDefaultProps:function(){return{id:"",name:"switch-button",title:"",label:"",label_right:"",labelRight:"",defaultChecked:"",theme:"rsbc-switch-button-flat-round",checked:null,onChange:this.handleChange}},handleChange:function(){},render:function(){var id,label,labelRight;if(this.props.id==""&&this.props.name!=""){id=this.props.name}if(this.props.label!=""){label=React.createElement("label",{htmlFor:id},this.props.label)}if("undefined"!==this.props.label_right||this.props.label_right!=""){this.props.labelRight=this.props.label_right}if(this.props.labelRight!=""){labelRight=React.createElement("label",{htmlFor:id},this.props.labelRight)}return React.createElement("div",{className:"rsbc-switch-button "+this.props.theme},label,React.createElement("input",{onChange:this.props.onChange,checked:this.props.checked,defaultChecked:this.props.defaultChecked,id:id,name:this.props.name,type:"checkbox",value:"1"}),React.createElement("label",{htmlFor:id}),labelRight)}});module.exports=SwitchButton; \ No newline at end of file +"use strict";(function(root,factory){if(typeof define==="function"&&define.amd){define(["react"],factory)}else if(typeof module==="object"&&module.exports){module.exports=factory(require("react"))}else{root.SwitchButton=factory(root.React)}})(this,function(React){var SwitchButton=React.createClass({displayName:"Switch Button",version:"1.0.4",propTypes:{id:React.PropTypes.string,name:React.PropTypes.string,title:React.PropTypes.string,label:React.PropTypes.string,labelRight:React.PropTypes.string,theme:React.PropTypes.string,checked:React.PropTypes.string,onChange:React.PropTypes.func},getDefaultProps:function(){return{id:"",name:"switch-button",title:"",label:"",labelRight:"",theme:"rsbc-switch-button-flat-round",checked:null,onChange:this.handleChange}},handleChange:function(){},render:function(){var id,label,labelRight;if(this.props.id==""&&this.props.name!=""){id=this.props.name}if(this.props.label!=""){label=React.createElement("label",{htmlFor:id},this.props.label)}if(this.props.labelRight!=""){labelRight=React.createElement("label",{htmlFor:id},this.props.labelRight)}return React.createElement("div",{className:"rsbc-switch-button "+this.props.theme},label,React.createElement("input",{onChange:this.props.onChange,checked:this.props.checked,id:id,name:this.props.name,type:"checkbox",value:"1"}),React.createElement("label",{htmlFor:id}),labelRight)}});return SwitchButton}); \ No newline at end of file diff --git a/javascripts/react-switch-button.js b/javascripts/react-switch-button.js index b97dff1..fcac5cf 100644 --- a/javascripts/react-switch-button.js +++ b/javascripts/react-switch-button.js @@ -27,7 +27,6 @@ var SwitchButton = React.createClass( { title : React.PropTypes.string, label : React.PropTypes.string, label_right : React.PropTypes.string, - defaultChecked : React.PropTypes.string, theme : React.PropTypes.string, checked : React.PropTypes.string, onChange : React.PropTypes.func @@ -37,7 +36,7 @@ var SwitchButton = React.createClass( { /** * Default propos. * - * @returns {{id: string, name: string, title: string, label: string, label_right: string, defaultChecked: string, theme: string, checked: null, onChange: *}} + * @returns {{id: string, name: string, title: string, label: string, label_right: string, theme: string, checked: null, onChange: *}} */ getDefaultProps : function() { @@ -47,7 +46,6 @@ var SwitchButton = React.createClass( { title : '', label : '', label_right : '', - defaultChecked : '', theme : 'rsbc-switch-button-flat-round', checked : null, onChange : this.hadleChange @@ -87,7 +85,7 @@ var SwitchButton = React.createClass( { return (
{label} - + {label_right}
diff --git a/package.json b/package.json index 23e0205..0b14f48 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-switch-button", - "version": "1.1.2", + "version": "1.1.3", "description": "A React UI Component to display an awesome Switch (swipe) Button control", "main": "dist/react-switch-button.min.js", "scripts": {