Skip to content

Commit

Permalink
Merge pull request #33 from negativetwelve/mark/switch/remove-css
Browse files Browse the repository at this point in the history
[Switch] Remove css installation from the README and explicitly update the version of react-ios-switch
  • Loading branch information
negativetwelve committed Sep 11, 2017
2 parents 97f10eb + fd7eec9 commit 16c6a4a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 66 deletions.
20 changes: 0 additions & 20 deletions packages/react-x-switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,6 @@ Install `react-x-switch` using `yarn`:
yarn add react-x-switch
```

## Setup

### React DOM

If using Webpack, you need to add a way to compile the css for the web version. Simply whitelist the `react-ios-switch` module using `include`:

```javascript
module.exports = {
module: {
rules: [{
test: /\.css$/,
include: [
'node_modules/react-ios-switch',
],
use: ['style-loader', 'css-loader'],
}],
},
};
```

## Usage

```javascript
Expand Down
2 changes: 1 addition & 1 deletion packages/react-x-switch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"dependencies": {
"prop-types": "^15.5.10",
"react-ios-switch": "^0.1.12"
"react-ios-switch": "^0.1.18"
},
"peerDependencies": {
"react": "*"
Expand Down
69 changes: 25 additions & 44 deletions packages/react-x-switch/src/SwitchX.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,31 @@ import PropTypes from 'prop-types';
import SwitchIOS from 'react-ios-switch';


class SwitchX extends React.Component {

// --------------------------------------------------
// Props
// --------------------------------------------------
static propTypes = {
onTintColor: PropTypes.string.isRequired,
isOn: PropTypes.bool.isRequired,
isDisabled: PropTypes.bool.isRequired,
onChange: PropTypes.func,
tintColor: PropTypes.string,
thumbTintColor: PropTypes.string,
};

static defaultProps = {
onChange: null,
tintColor: null,
thumbTintColor: null,
};

// --------------------------------------------------
// Lifecycle
// --------------------------------------------------
constructor(props, context) {
super(props, context);
require('react-ios-switch/build/bundle.css');
}

// --------------------------------------------------
// Render
// --------------------------------------------------
render() {
const {isOn, onTintColor, onChange} = this.props;

return (
<SwitchIOS
checked={isOn}
onColor={onTintColor}
onChange={onChange}
/>
);
}

}
const SwitchX = (props) => (
<SwitchIOS
checked={props.isOn}
onColor={props.onTintColor}
onChange={props.onChange}
/>
);

// --------------------------------------------------
// Props
// --------------------------------------------------
SwitchX.propTypes = {
onTintColor: PropTypes.string.isRequired,
isOn: PropTypes.bool.isRequired,
isDisabled: PropTypes.bool.isRequired,
onChange: PropTypes.func,
tintColor: PropTypes.string,
thumbTintColor: PropTypes.string,
};

SwitchX.defaultProps = {
onChange: null,
tintColor: null,
thumbTintColor: null,
};


export default SwitchX;
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5222,7 +5222,7 @@ react-dom@16.0.0-alpha.12:
object-assign "^4.1.0"
prop-types "^15.5.6"

react-ios-switch@^0.1.12:
react-ios-switch@^0.1.18:
version "0.1.18"
resolved "https://registry.yarnpkg.com/react-ios-switch/-/react-ios-switch-0.1.18.tgz#f68371157ca83796610dc1a60a5f6cbf5742c65a"
dependencies:
Expand Down

0 comments on commit 16c6a4a

Please sign in to comment.