Skip to content

Commit

Permalink
[ButtonBase] Remove some code (mui#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 3, 2017
1 parent 584c5bf commit 0cc28a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ that you can use to tag your questions.

# [Material-Next](https://material-ui-next.com/)
[![npm package](https://img.shields.io/npm/v/@material-next/core.svg)](https://www.npmjs.org/package/@material-next/core)
![npm](https://img.shields.io/npm/dm/@material-next/core.svg)
[![npm download](https://img.shields.io/npm/dm/@material-next/core.svg)](https://www.npmjs.com/package/@material-next/core)
[![CircleCI](https://img.shields.io/circleci/project/github/material-next/material-next/master.svg)](https://circleci.com/gh/material-next/material-next/tree/master)
[![Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/MwT5uvA)
[![Coverage Status](https://img.shields.io/codecov/c/github/material-next/material-next/master.svg)](https://codecov.io/gh/material-next/material-next/branch/master)
Expand Down
24 changes: 8 additions & 16 deletions src/ButtonBase/ButtonBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,21 +311,6 @@ class ButtonBase extends React.Component<ProvidedProps & Props, State> {
}
};

renderRipple() {
if (!this.props.disableRipple && !this.props.disabled) {
return (
<TouchRipple
innerRef={node => {
this.ripple = node;
}}
center={this.props.centerRipple}
/>
);
}

return null;
}

render() {
const {
centerRipple,
Expand Down Expand Up @@ -403,7 +388,14 @@ class ButtonBase extends React.Component<ProvidedProps & Props, State> {
ref={rootRef}
>
{children}
{this.renderRipple()}
{!disableRipple && !disabled ? (
<TouchRipple
innerRef={node => {
this.ripple = node;
}}
center={centerRipple}
/>
) : null}
</ComponentProp>
);
}
Expand Down
20 changes: 8 additions & 12 deletions src/ButtonBase/Ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ class Ripple extends React.Component<ProvidedProps & Props, State> {
rippleLeaving: false,
};

getRippleStyles = props => {
const { rippleSize, rippleX, rippleY } = props;

return {
width: rippleSize,
height: rippleSize,
top: -(rippleSize / 2) + rippleY,
left: -(rippleSize / 2) + rippleX,
};
};

handleEnter = () => {
this.setState({
rippleVisible: true,
Expand Down Expand Up @@ -99,10 +88,17 @@ class Ripple extends React.Component<ProvidedProps & Props, State> {
[classes.rippleFast]: pulsate,
});

const rippleStyles = {
width: rippleSize,
height: rippleSize,
top: -(rippleSize / 2) + rippleY,
left: -(rippleSize / 2) + rippleX,
};

return (
<Transition onEnter={this.handleEnter} onExit={this.handleExit} {...other}>
<span className={className}>
<span className={rippleClassName} style={this.getRippleStyles(this.props)} />
<span className={rippleClassName} style={rippleStyles} />
</span>
</Transition>
);
Expand Down
2 changes: 1 addition & 1 deletion src/ButtonBase/TouchRipple.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class TouchRipple extends React.Component<ProvidedProps & Props, State> {
const { pulsate, rippleX, rippleY, rippleSize, cb } = params;
let ripples = this.state.ripples;

// Add a ripple to the ripples array
// Add a ripple to the ripples array.
ripples = [
...ripples,
<Ripple
Expand Down

0 comments on commit 0cc28a7

Please sign in to comment.