mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
simple checkbox component implemented and exported as a common module
This commit is contained in:
parent
67f3668166
commit
7077b89f6a
4 changed files with 47 additions and 0 deletions
32
src/common/checkbox/checkbox.js
Normal file
32
src/common/checkbox/checkbox.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import styles from './styles';
|
||||
|
||||
class Checkbox extends Component {
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
return nextProps.checked !== this.props.checked;
|
||||
}
|
||||
|
||||
onPress = () => {
|
||||
if (typeof this.props.onPress === 'function') {
|
||||
this.props.onPress();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div style={styles.root} onClick={this.onPress} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Checkbox.propTypes = {
|
||||
enabled: PropTypes.bool.isRequired,
|
||||
checked: PropTypes.bool.isRequired,
|
||||
onPress: PropTypes.func
|
||||
};
|
||||
Checkbox.defaultProps = {
|
||||
enabled: true
|
||||
};
|
||||
|
||||
export default Checkbox;
|
||||
3
src/common/checkbox/index.js
Normal file
3
src/common/checkbox/index.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import Checkbox from './checkbox';
|
||||
|
||||
export default Checkbox;
|
||||
7
src/common/checkbox/styles.js
Normal file
7
src/common/checkbox/styles.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export default {
|
||||
root: {
|
||||
width: 300,
|
||||
height: 300,
|
||||
backgroundColor: 'red'
|
||||
},
|
||||
};
|
||||
5
src/common/index.js
Normal file
5
src/common/index.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import Checkbox from './checkbox';
|
||||
|
||||
export {
|
||||
Checkbox
|
||||
};
|
||||
Loading…
Reference in a new issue