Skip to content

Commit

Permalink
update 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gfazioli committed Mar 1, 2017
1 parent 9a9bf98 commit 2df213c
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 106 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

A Switch control built with and for [React](http://facebook.github.io/react/index.html)

## New version 2.1.0

Add square theme.

## Demo & Example

Example: [http://gfazioli.github.io/react-switch-button](http://gfazioli.github.io/react-switch-button)
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-switch-button",
"main": "dist/react-switch-button.min.js",
"version": "2.0.0",
"version": "2.2.1",
"homepage": "http://gfazioli.github.io/react-switch-button/",
"authors": [
"Giovambattista Fazioli"
Expand Down
49 changes: 30 additions & 19 deletions dist/react-switch-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@
(function (global){
'use strict';

var React = typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null;
Object.defineProperty(exports, '__esModule', {
value: true
});

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { 'default': obj };
}

var _react = typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null;

var _react2 = _interopRequireDefault(_react);

var SwitchButton = React.createClass({
var SwitchButton = _react2['default'].createClass({

// Display name
displayName: 'Switch Button',

// Version
version: '2.2.0',
version: '2.2.1',

/**
* The props types.
*/
propTypes: {
id: React.PropTypes.string,
name: React.PropTypes.string,
title: React.PropTypes.string,
label: React.PropTypes.string,
labelRight: React.PropTypes.string,
defaultChecked: React.PropTypes.bool,
disabled: React.PropTypes.bool,
theme: React.PropTypes.string,
checked: React.PropTypes.string,
mode: React.PropTypes.string,
onChange: React.PropTypes.func
id: _react2['default'].PropTypes.string,
name: _react2['default'].PropTypes.string,
title: _react2['default'].PropTypes.string,
label: _react2['default'].PropTypes.string,
labelRight: _react2['default'].PropTypes.string,
defaultChecked: _react2['default'].PropTypes.bool,
disabled: _react2['default'].PropTypes.bool,
theme: _react2['default'].PropTypes.string,
checked: _react2['default'].PropTypes.string,
mode: _react2['default'].PropTypes.string,
onChange: _react2['default'].PropTypes.func
},

/**
Expand Down Expand Up @@ -71,28 +81,29 @@ var SwitchButton = React.createClass({
}

if (this.props.label !== '') {
label = React.createElement('label', { htmlFor: id }, this.props.label);
label = _react2['default'].createElement('label', { htmlFor: id }, this.props.label);
}

if (this.props.labelRight !== '') {
labelRight = React.createElement('label', { htmlFor: id }, this.props.labelRight);
labelRight = _react2['default'].createElement('label', { htmlFor: id }, this.props.labelRight);
}

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,
return _react2['default'].createElement('div', { className: 'rsbc-switch-button rsbc-mode-' + mode + ' ' + this.props.theme + (this.props.disabled ? " disabled" : "") }, label, _react2['default'].createElement('input', { onChange: this.props.onChange,
defaultChecked: this.props.defaultChecked,
disabled: this.props.disabled,
id: id, name: this.props.name,
type: 'checkbox',
value: '1' }), React.createElement('label', { htmlFor: id }), labelRight);
value: '1' }), _react2['default'].createElement('label', { htmlFor: id }), labelRight);
}

});

module.exports = SwitchButton;
exports['default'] = SwitchButton;
module.exports = exports['default'];

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}]},{},[1])(1)
Expand Down
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.

78 changes: 49 additions & 29 deletions example/dist/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
"use strict";

var React = require('react'),
ReactDom = require('react-dom'),
SwitchButton = require('react-switch-button');
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { "default": obj };
}

var App = React.createClass({
displayName: 'App',
var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _reactDom = require("react-dom");

var _reactDom2 = _interopRequireDefault(_reactDom);

var _reactSwitchButton = require("react-switch-button");

var _reactSwitchButton2 = _interopRequireDefault(_reactSwitchButton);

var App = _react2["default"].createClass({
displayName: "App",

onChange: function onChange(e) {
var theme = this.state.theme === 'rsbc-switch-button-flat-square' ? 'rsbc-switch-button-flat-round' : 'rsbc-switch-button-flat-square';
Expand All @@ -27,75 +39,83 @@ var App = React.createClass({

var code = [{
label: "Simple usage",
code: '<SwitchButton name="switch-1" />', object: React.createElement(SwitchButton, { theme: this.state.theme, name: 'switch-1' })
code: '<SwitchButton name="switch-1" />',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { theme: this.state.theme,
name: "switch-1" })
}, {
label: "Set Theme",
code: '<SwitchButton name="switch-1t" theme="rsbc-switch-button-flat-square" defaultChecked={true} />',
object: React.createElement(SwitchButton, { name: 'switch-1t',
theme: 'rsbc-switch-button-flat-square',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-1t",
theme: "rsbc-switch-button-flat-square",
defaultChecked: true })
}, {
label: "Set initial status",
code: '<SwitchButton name="switch-2" defaultChecked={true} />',
object: React.createElement(SwitchButton, { name: 'switch-2',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-2",
theme: this.state.theme,
defaultChecked: true })
}, {
label: "Add left label",
code: '<SwitchButton name="switch-3" label="Click me" defaultChecked={true} />',
object: React.createElement(SwitchButton, { name: 'switch-3',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-3",
theme: this.state.theme,
label: 'Click me',
label: "Click me",
defaultChecked: true })
}, {
label: "Add right label",
code: '<SwitchButton name="switch-4" labelRight="Click me" defaultChecked={true} />',
object: React.createElement(SwitchButton, { name: 'switch-4',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-4",
theme: this.state.theme,
labelRight: 'Click me',
labelRight: "Click me",
defaultChecked: true })
}, {
label: "Add left and right label",
code: '<SwitchButton name="switch-5" label="Both" label_right="Click me" defaultChecked={true} />',
object: React.createElement(SwitchButton, { name: 'switch-5',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-5",
theme: this.state.theme,
label: 'Both',
labelRight: 'Click me',
label: "Both",
labelRight: "Click me",
defaultChecked: true })
}, {
label: "Disabled when On",
code: '<SwitchButton name="switch-6" label="Disabled" disabled={true} defaultChecked={true} />',
object: React.createElement(SwitchButton, { name: 'switch-6',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-6",
theme: this.state.theme,
label: 'Disabled',
label: "Disabled",
disabled: true,
defaultChecked: true })
}, {
label: "Disabled when Off",
code: '<SwitchButton name="switch-7" label="Disabled" disabled={true} />',
object: React.createElement(SwitchButton, { name: 'switch-7',
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-7",
theme: this.state.theme,
label: 'Disabled',
label: "Disabled",
disabled: true })
}, {
label: "New in v2.2.0 Mode select",
code: '<SwitchButton name="switch-8" label="Switch mode" mode="select"/>',
object: React.createElement(SwitchButton, { name: 'switch-8',
mode: 'select',
labelRight: 'Turn right',
label: 'Turn left' })
object: _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-8",
mode: "select",
theme: this.state.theme,
labelRight: "Turn right",
label: "Turn left" })
}];

var rows = code.map(function (o, i) {

return React.createElement('div', { className: 'example',
key: i }, React.createElement('h3', null, o.label), React.createElement('pre', null, o.code), React.createElement('div', { className: 'result' }, o.object));
return _react2["default"].createElement("div", { className: "example",
key: i }, _react2["default"].createElement("h3", null, o.label), _react2["default"].createElement("pre", null, o.code), _react2["default"].createElement("div", { className: "result" }, o.object));
});

return React.createElement('div', { className: 'examples' }, React.createElement('h1', null, 'Say Hello, React Switch Button'), React.createElement('div', { className: 'example' }, React.createElement('h3', null, 'New in v.2.1.0')), React.createElement(SwitchButton, { name: 'switch-theme', label: 'Switch Theme', onChange: this.onChange }), React.createElement('hr', null), rows);
return _react2["default"].createElement("div", { className: "examples" }, _react2["default"].createElement("h1", null, "Say Hello, React Switch Button"), _react2["default"].createElement("div", { className: "example" }, _react2["default"].createElement("h3", null, "New in v.2.2.0")), _react2["default"].createElement(_reactSwitchButton2["default"], { name: "new-mode-select",
mode: "select",
labelRight: "Turn right",
label: "Turn left" }), _react2["default"].createElement("div", { className: "example" }, _react2["default"].createElement("h3", null, "New in v.2.1.0")), _react2["default"].createElement(_reactSwitchButton2["default"], { name: "switch-theme",
label: "Switch Theme",
onChange: this.onChange }), _react2["default"].createElement("hr", null), rows);
}
});

ReactDom.render(React.createElement(App, null), document.getElementById('app'));
_reactDom2["default"].render(_react2["default"].createElement(App, null), document.getElementById('app'));

},{"react":undefined,"react-dom":undefined,"react-switch-button":undefined}]},{},[1]);
49 changes: 30 additions & 19 deletions example/dist/bundle.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"react-switch-button":[function(require,module,exports){
'use strict';

var React = require('react');
Object.defineProperty(exports, '__esModule', {
value: true
});

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { 'default': obj };
}

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var SwitchButton = React.createClass({
var SwitchButton = _react2['default'].createClass({

// Display name
displayName: 'Switch Button',

// Version
version: '2.2.0',
version: '2.2.1',

/**
* The props types.
*/
propTypes: {
id: React.PropTypes.string,
name: React.PropTypes.string,
title: React.PropTypes.string,
label: React.PropTypes.string,
labelRight: React.PropTypes.string,
defaultChecked: React.PropTypes.bool,
disabled: React.PropTypes.bool,
theme: React.PropTypes.string,
checked: React.PropTypes.string,
mode: React.PropTypes.string,
onChange: React.PropTypes.func
id: _react2['default'].PropTypes.string,
name: _react2['default'].PropTypes.string,
title: _react2['default'].PropTypes.string,
label: _react2['default'].PropTypes.string,
labelRight: _react2['default'].PropTypes.string,
defaultChecked: _react2['default'].PropTypes.bool,
disabled: _react2['default'].PropTypes.bool,
theme: _react2['default'].PropTypes.string,
checked: _react2['default'].PropTypes.string,
mode: _react2['default'].PropTypes.string,
onChange: _react2['default'].PropTypes.func
},

/**
Expand Down Expand Up @@ -70,27 +80,28 @@ var SwitchButton = React.createClass({
}

if (this.props.label !== '') {
label = React.createElement('label', { htmlFor: id }, this.props.label);
label = _react2['default'].createElement('label', { htmlFor: id }, this.props.label);
}

if (this.props.labelRight !== '') {
labelRight = React.createElement('label', { htmlFor: id }, this.props.labelRight);
labelRight = _react2['default'].createElement('label', { htmlFor: id }, this.props.labelRight);
}

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,
return _react2['default'].createElement('div', { className: 'rsbc-switch-button rsbc-mode-' + mode + ' ' + this.props.theme + (this.props.disabled ? " disabled" : "") }, label, _react2['default'].createElement('input', { onChange: this.props.onChange,
defaultChecked: this.props.defaultChecked,
disabled: this.props.disabled,
id: id, name: this.props.name,
type: 'checkbox',
value: '1' }), React.createElement('label', { htmlFor: id }), labelRight);
value: '1' }), _react2['default'].createElement('label', { htmlFor: id }), labelRight);
}

});

module.exports = SwitchButton;
exports['default'] = SwitchButton;
module.exports = exports['default'];

},{"react":undefined}]},{},[]);
Loading

0 comments on commit 2df213c

Please sign in to comment.