Skip to content

Commit 5c63d65

Browse files
committed
Fixed all eslint issues
1 parent 546381d commit 5c63d65

File tree

11 files changed

+96
-64
lines changed

11 files changed

+96
-64
lines changed

package-lock.json

Lines changed: 9 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"babel-preset-es2017": "^6.24.1",
5050
"babel-preset-stage-3": "^6.24.1",
5151
"classnames": "^2.2.6",
52+
"prop-types": "^15.6.2",
5253
"ramda": "^0.25.0",
5354
"react": "^16.3.2",
5455
"react-css-themr": "^2.1.2",

src/button/Button.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,42 @@ import rippleFactory from '../ripple/Ripple';
88

99
const factory = (ripple, FontIcon) => {
1010
class Button extends Component {
11+
static propTypes = {
12+
children: PropTypes.node.isRequired,
13+
type: PropTypes.string,
14+
size: PropTypes.string,
15+
className: PropTypes.string,
16+
href: PropTypes.string,
17+
icon: PropTypes.oneOfType([
18+
PropTypes.string,
19+
PropTypes.element,
20+
]),
21+
iconAlignment: PropTypes.string,
22+
theme: PropTypes.shape({}),
23+
disabled: PropTypes.bool,
24+
onClick: PropTypes.func,
25+
};
26+
1127
static defaultProps = {
1228
type: 'default',
1329
size: 'medium',
1430
className: '',
1531
href: '',
32+
icon: null,
1633
iconAlignment: 'left',
34+
theme: {},
35+
disabled: false,
36+
onClick: null,
1737
};
1838

1939
getIcon = (icon, iconAlignment, theme) => {
2040
const iconClasses = classnames(theme.icon, theme[`icon-${iconAlignment}`]);
2141
return <FontIcon className={iconClasses} value={icon} />;
2242
}
2343

24-
handleMouseUp = (event) => {
25-
this.buttonNode.blur();
26-
if (this.props.onMouseUp) this.props.onMouseUp(event);
27-
};
28-
2944
handleMouseLeave = (event) => {
3045
this.buttonNode.blur();
31-
if (this.props.onMouseLeave) this.props.onMouseLeave(event);
46+
if (this.props.onClick) this.props.onClick(event);
3247
};
3348

3449
render() {

src/button/readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ The base button component.
1010
| `size` | `String` | `medium` | Defines the size of the button. Possible values are 'small', 'medium', and 'large' |
1111
| `className` | `String` | `''` | Set a class to style the Component |
1212
| `href` | `String` | `null` | Creates a link for the button. |
13-
| `icon` | `String`/`Element` | | Value of the icon |
13+
| `icon` | `String`/`Element` | `null` | Value of the icon |
1414
| `iconAlignment` | `String` | `left` | Set an alignment of the icon. Possible values are 'left', 'right' |
15+
| `onClick` | `Function` | | Callback to be called when the button is clicked |
1516

1617
### Theme
1718

src/card/index.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ const Card = ({
1313
noPadding,
1414
header, ...other
1515
}) => {
16-
const classes = classnames(theme.card, theme[`elevation-${elevation}`],{
16+
const classes = classnames(theme.card, theme[`elevation-${elevation}`], {
1717
[theme.wrapContent]: wrapContent,
1818
[theme.noPadding]: noPadding,
1919
}, className);
2020
const headerClass = classnames(theme.cardHeader);
21+
2122
let cardHeader;
2223
if (typeof header === 'string') {
23-
cardHeader = (<div className={headerClass}>
24-
<span>{header}</span>
25-
</div>)
26-
} else if(typeof header === 'function') {
24+
cardHeader = (
25+
<div className={headerClass}>
26+
<span>{header}</span>
27+
</div>
28+
);
29+
} else if (typeof header === 'function') {
2730
cardHeader = header();
2831
}
2932

@@ -35,16 +38,29 @@ const Card = ({
3538
);
3639
};
3740

38-
Card.prototype = {
39-
theme: PropTypes.object,
41+
Card.propTypes = {
42+
children: PropTypes.node.isRequired,
43+
className: PropTypes.string,
44+
theme: PropTypes.shape({
45+
card: PropTypes.string,
46+
cardHeader: PropTypes.string,
47+
}),
4048
wrapContent: PropTypes.bool,
4149
noPadding: PropTypes.bool,
4250
elevation: PropTypes.oneOf(['low', 'medium', 'high']),
43-
header: PropTypes.oneOf([PropTypes.string, PropTypes.func]),
44-
}
51+
header: PropTypes.oneOf([
52+
PropTypes.string,
53+
PropTypes.func,
54+
]),
55+
};
4556

4657
Card.defaultProps = {
58+
className: null,
4759
elevation: 'low',
48-
}
60+
theme: {},
61+
wrapContent: false,
62+
noPadding: false,
63+
header: null,
64+
};
4965

50-
export default themr('CBCard', defaultTheme)(Card);
66+
export default themr('CBCard', defaultTheme)(Card);

src/font_icon/FontIcon.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import classnames from 'classnames';
4-
import { themr } from 'react-css-themr';
54

65
import iconTheme from './theme.scss';
76

87
const FontIcon = ({ alt, children, className, theme, value, ...other}) => { // eslint-disable-line
9-
const _classNames = classnames({
8+
const classNames = classnames({
109
[iconTheme.materialIcons]: typeof value === 'string' || typeof children === 'string',
1110
}, className);
1211

1312
return (
1413
<span
1514
aria-label={alt}
16-
className={_classNames}
15+
className={classNames}
1716
{...other}
1817
>
1918
{value}
@@ -30,10 +29,11 @@ FontIcon.propTypes = {
3029
value: PropTypes.oneOfType([
3130
PropTypes.string,
3231
PropTypes.element,
33-
]),
32+
]).isRequired,
3433
};
3534

3635
FontIcon.defaultProps = {
36+
children: null,
3737
alt: '',
3838
className: '',
3939
};

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import ReactDOM from 'react-dom';
33
import Card from './card';
44
import customTheme from './customcard.scss';
55

6-
import Button from './button';
6+
import Button from './button'; // eslint-disable-line
77

88
const Index = () => (
99
<div>
1010
<Card
11-
header='Card String header'
11+
header="Card String header"
1212
wrapContent
13-
theme={customTheme}>
13+
theme={customTheme}
14+
>
1415
<span>Card Content</span>
1516
<span>Card Content</span>
1617
<span>Card Content</span>

src/ripple/Ripple.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const rippleFactory = (options = {}) => {
3030
return (ComposedComponent) => {
3131
class RippledComponent extends Component {
3232
static propTypes = {
33-
children: PropTypes.node,
33+
children: PropTypes.node.isRequired,
3434
disabled: PropTypes.bool,
3535
onMouseDown: PropTypes.func,
3636
onRippleEnded: PropTypes.func,
@@ -55,6 +55,10 @@ const rippleFactory = (options = {}) => {
5555
rippleClassName: defaultClassName,
5656
rippleMultiple: defaultMultiple,
5757
rippleSpread: defaultSpread,
58+
onMouseDown: null,
59+
onRippleEnded: null,
60+
onTouchStart: null,
61+
theme: {},
5862
};
5963

6064
state = {
@@ -86,7 +90,7 @@ const rippleFactory = (options = {}) => {
8690
getDescriptor(x, y) {
8791
const {
8892
left, top, height, width,
89-
} = ReactDOM.findDOMNode(this).getBoundingClientRect();
93+
} = ReactDOM.findDOMNode(this).getBoundingClientRect(); // eslint-disable-line
9094
const { rippleCentered: centered, rippleSpread: spread } = this.props;
9195
return {
9296
left: centered ? 0 : x - left - (width / 2),
@@ -253,14 +257,14 @@ const rippleFactory = (options = {}) => {
253257
}) {
254258
const scale = restarting ? 0 : 1;
255259
const transform = `translate3d(${(-width / 2) + left}px, ${(-width / 2) + top}px, 0) scale(${scale})`;
256-
const _className = classnames(this.props.theme.ripple, {
260+
const classNames = classnames(this.props.theme.ripple, {
257261
[this.props.theme.rippleActive]: active,
258262
[this.props.theme.rippleRestarting]: restarting,
259263
}, className);
260264
return (
261265
<span key={key} data-react-toolbox="ripple" className={this.props.theme.rippleWrapper} {...props}>
262266
<span
263-
className={_className}
267+
className={classNames}
264268
ref={(node) => { if (node) this.rippleNodes[key] = node; }}
265269
style={prefixer({ transform }, { width, height: width })}
266270
/>

src/utils/events.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import keys from 'ramda/src/keys';
22

3+
const TRANSITIONS = {
4+
transition: 'transitionend',
5+
OTransition: 'oTransitionEnd',
6+
MozTransition: 'transitionend',
7+
WebkitTransition: 'webkitTransitionEnd',
8+
};
9+
10+
function transitionEventNamesFor(element) {
11+
return keys(TRANSITIONS).reduce((result, transition) => (
12+
!result && (element && element.style[transition] !== undefined)
13+
? TRANSITIONS[transition]
14+
: result
15+
), null);
16+
}
17+
318
export default {
419
getMousePosition(event) {
520
return {
@@ -55,18 +70,3 @@ export default {
5570
return true;
5671
},
5772
};
58-
59-
const TRANSITIONS = {
60-
transition: 'transitionend',
61-
OTransition: 'oTransitionEnd',
62-
MozTransition: 'transitionend',
63-
WebkitTransition: 'webkitTransitionEnd',
64-
};
65-
66-
function transitionEventNamesFor(element) {
67-
return keys(TRANSITIONS).reduce((result, transition) => (
68-
!result && (element && element.style[transition] !== undefined)
69-
? TRANSITIONS[transition]
70-
: result
71-
), null);
72-
}

src/utils/prefixer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ function addPrefixesTo(style, property, value) {
2828
}
2929

3030
function prefixer(style, defaultValue = {}) {
31-
const _style = defaultValue;
31+
const newStyle = defaultValue;
3232
for (const property in style) { // eslint-disable-line no-restricted-syntax
3333
if ({}.hasOwnProperty.call(style, property)) {
34-
_style[property] = style[property];
34+
newStyle[property] = style[property];
3535
if (properties[property]) {
36-
addPrefixesTo(_style, property, style[property]);
36+
addPrefixesTo(newStyle, property, style[property]);
3737
}
3838
}
3939
}
4040

41-
return _style;
41+
return newStyle;
4242
}
4343

4444
export default prefixer;

0 commit comments

Comments
 (0)