Skip to content

Commit

Permalink
fix(Button): disable timeout onUnmount 87d9ac4
Browse files Browse the repository at this point in the history
  • Loading branch information
Utzel-Butzel committed Dec 18, 2019
1 parent 82c702d commit 53e5bf7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"contributors:generate": "all-contributors generate",
"lint": "eslint src",
"precommit": "lint-staged && yarn lint",
"prepublish": "yarn build",
"prepare": "yarn build",
"prettier": "prettier --write \"**/*.{scss,css,js}\"",
"prettier:staged": "prettier",
"prettier:diff": "prettier --list-different \"**/*.{scss,css,js}\"",
Expand Down
11 changes: 9 additions & 2 deletions src/components/Button/Button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import Icon from '../Icon';
import classNames from 'classnames';
import { ButtonTypes } from '../../prop-types/types';
Expand All @@ -21,6 +21,13 @@ const Button = ({
}) => {
const [count, setCount] = useState(0);

useEffect(() => {
let timer = setTimeout(() => endAnimation(), 500);
return () => {
clearTimeout(timer);
};
}, [count]);

const buttonClasses = classNames(className, {
'wfp--btn': true,
'wfp--btn--sm': small,
Expand Down Expand Up @@ -60,7 +67,6 @@ const Button = ({
onClick(e);
}
setCount(true);
setTimeout(endAnimation, 500);
};

const button = (
Expand All @@ -73,6 +79,7 @@ const Button = ({
ref={other.inputref}>
{children}
{buttonImage}
{count}
</button>
);

Expand Down
6 changes: 5 additions & 1 deletion src/documentation/Intro/_intro.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ $css--reset: false;
align-items: center;
justify-content: center;
position: relative;
margin-top: -5vw;
background: rgba(#fff, 0.02);
box-shadow: 0px 15px 15px -7px rgba(#000, 0.2);
.intro-animation--mobile & {
width: 15vw;
height: 25vw;
Expand All @@ -48,6 +51,7 @@ $css--reset: false;
color: #fff;
position: absolute;
top: 50%;
margin-top: -3vw;
transition: all 0.5s;
transition-timing-function: ease-in-out;
display: flex;
Expand Down Expand Up @@ -92,7 +96,7 @@ $css--reset: false;

.intro__links {
position: absolute;
bottom: 10vh;
bottom: 13vh;
left: 0;
width: 100%;
display: flex;
Expand Down
3 changes: 2 additions & 1 deletion src/documentation/Usage/UsageDevelopers-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ storiesOf(' Design|Getting started', module)
.add('Developers', () => (
<Page title="Usage for Developers" subTitle="How to use the UI Kit">
<p>
The UI Kit provides developers with React.js components, scss, css, html
The UI Kit provides developers with React.js components, scss,{' '}
<Link onClick={linkTo('Design|Getting started', 'CSS')}>css</Link>, html
and assets.
</p>
<h3>Getting started with react.js</h3>
Expand Down

0 comments on commit 53e5bf7

Please sign in to comment.