Skip to content

Commit ba5e9f7

Browse files
committed
Merge branch 'release-1.0.4'
2 parents 99650af + aa0d5f5 commit ba5e9f7

18 files changed

+246
-97
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
/bower_components

assets/css/demo.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

bower.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"name": "react-switch-button",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"homepage": "https://github.com/gfazioli/react-switch-button",
55
"authors": [
6-
"Giovambattista Fazioli <g.fazioli@wpxtre.me>"
6+
"Giovambattista Fazioli <g.fazioli@undolog.com>"
77
],
88
"description": "Switch button React component",
9-
"main": "js/react-switch-button.js",
9+
"main": [
10+
"dist/react-switch-button.min.js",
11+
"dist/react-switch-button.min.css"
12+
],
1013
"keywords": [
1114
"react",
1215
"switch",
@@ -15,10 +18,16 @@
1518
"ui"
1619
],
1720
"license": "MIT",
21+
"dependencies": {
22+
"react": ">=0.13"
23+
},
1824
"ignore": [
1925
"**/.*",
20-
"node_modules",
2126
"bower_components",
27+
"node_modules",
28+
"package.json",
29+
"src",
30+
"exeample",
2231
"test",
2332
"tests"
2433
]

composer.json

Lines changed: 0 additions & 37 deletions
This file was deleted.

dist/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.module-cache

dist/react-switch-button.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/**
2+
* React Switch Control.
3+
* Simple React UI component used to display a switch button control.
4+
*
5+
* Usage: <SwitchButton {...props} />
6+
*
7+
* @class SwitchButton
8+
* @author =undo= <g.fazioli@wpxtre.me>
9+
* @date 2015-03-02
10+
* @version 1.0.4
11+
*
12+
* @history 1.0.0 First public release
13+
* @history 1.0.3 Minor fixes
14+
* @history 1.0.4 @deprecated since 1.0.4 - use labelRight instead - issue #5 https://github.com/gfazioli/react-switch-button/issues/5
15+
*/
16+
17+
"use strict";
18+
19+
var SwitchButton = React.createClass( {
20+
21+
// Display name
22+
displayName : 'Switch Button',
23+
24+
// Version
25+
version : '1.0.4',
26+
27+
/**
28+
* The props types.
29+
*/
30+
propTypes : {
31+
id : React.PropTypes.string,
32+
name : React.PropTypes.string,
33+
title : React.PropTypes.string,
34+
label : React.PropTypes.string,
35+
label_right : React.PropTypes.string,
36+
labelRight : React.PropTypes.string,
37+
defaultChecked : React.PropTypes.string,
38+
theme : React.PropTypes.string,
39+
checked : React.PropTypes.string,
40+
onChange : React.PropTypes.func
41+
},
42+
43+
44+
/**
45+
* Default propos.
46+
*
47+
* @returns {{id: string, name: string, title: string, label: string, label_right: string, defaultChecked: string, theme: string, checked: null, onChange: *}}
48+
*/
49+
getDefaultProps : function()
50+
{
51+
return {
52+
id : '',
53+
name : 'switch-button',
54+
title : '',
55+
label : '',
56+
label_right : '',
57+
labelRight : '',
58+
defaultChecked : '',
59+
theme : 'rsbc-switch-button-flat-round',
60+
checked : null,
61+
onChange : this.handleChange
62+
};
63+
},
64+
65+
// Handle change
66+
handleChange : function()
67+
{
68+
// Override
69+
},
70+
71+
/**
72+
* Render Switch Button control
73+
*
74+
* @returns {XML}
75+
*/
76+
render : function()
77+
{
78+
var id, label, labelRight;
79+
80+
if( this.props.id == '' && this.props.name != '' ) {
81+
id = this.props.name;
82+
}
83+
84+
if( this.props.label != '' ) {
85+
label = (
86+
React.createElement("label", {htmlFor: id}, this.props.label)
87+
);
88+
}
89+
90+
// @deprecated since 1.0.4 - use labelRight instead - issue #5 https://github.com/gfazioli/react-switch-button/issues/5
91+
if( 'undefined' !== this.props.label_right || this.props.label_right != '' ) {
92+
this.props.labelRight = this.props.label_right;
93+
}
94+
95+
if( this.props.labelRight != '' ) {
96+
labelRight = (
97+
React.createElement("label", {htmlFor: id}, this.props.labelRight)
98+
);
99+
}
100+
101+
return (
102+
React.createElement("div", {className: 'rsbc-switch-button ' + this.props.theme},
103+
label,
104+
React.createElement("input", {onChange: this.props.onChange, checked: this.props.checked, defaultChecked: this.props.defaultChecked,
105+
id: id, name: this.props.name, type: "checkbox", value: "1"}),
106+
React.createElement("label", {htmlFor: id}),
107+
labelRight
108+
)
109+
);
110+
}
111+
112+
} );

dist/react-switch-button.min.css

Lines changed: 1 addition & 0 deletions
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 & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/assets/demo.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Demo Switch Button control.
3+
*
4+
*/
5+
6+
var Demo = React.createClass( {displayName: "Demo",
7+
8+
render : function()
9+
{
10+
11+
var style = { textAlign : 'center' };
12+
13+
var code = [
14+
{ code : '<SwitchButton name="switch-1" />', object : React.createElement(SwitchButton, {name: "switch-1"}) },
15+
{ code : '<SwitchButton name="switch-2" defaultChecked="checked" />', object : React.createElement(SwitchButton, {name: "switch-2", defaultChecked: "checked"}) },
16+
{
17+
code : '<SwitchButton name="switch-3" label="Click me" defaultChecked="checked" />',
18+
object : React.createElement(SwitchButton, {name: "switch-3", label: "Click me", defaultChecked: "checked"})
19+
},
20+
{
21+
code : '<SwitchButton name="switch-4" label_right="Click me" defaultChecked="checked" />',
22+
object : React.createElement(SwitchButton, {name: "switch-4", label_right: "Click me", defaultChecked: "checked"})
23+
},
24+
{
25+
code : '<SwitchButton name="switch-5" label="Both" label_right="Click me" defaultChecked="checked" />',
26+
object : React.createElement(SwitchButton, {name: "switch-5", label: "Both", label_right: "Click me", defaultChecked: "checked"})
27+
}
28+
];
29+
30+
var rows = code.map( function( o, i )
31+
{
32+
33+
return (
34+
React.createElement("div", {key: i},
35+
React.createElement("pre", null, o.code),
36+
o.object
37+
)
38+
);
39+
40+
} );
41+
42+
return (
43+
React.createElement("div", {style: style},
44+
React.createElement("h1", null, "Hello, React Switch Button"),
45+
rows
46+
)
47+
);
48+
}
49+
50+
51+
} );
52+
53+
React.render(
54+
React.createElement(Demo, null),
55+
document.getElementById( 'content' )
56+
);

0 commit comments

Comments
 (0)