Skip to content

Commit 77b2b5d

Browse files
author
Peter Bengtsson
authored
reuse EllipsisLoading component (#70)
1 parent deb360f commit 77b2b5d

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

src/Common.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
3+
export class EllipsisLoading extends React.PureComponent {
4+
state = { dots: 0 };
5+
static defaultProps = {
6+
text: 'Loading',
7+
animationMs: 400,
8+
maxDots: 5
9+
};
10+
componentDidMount() {
11+
this.interval = window.setInterval(() => {
12+
this.setState(state => {
13+
return { dots: (state.dots + 1) % this.props.maxDots };
14+
});
15+
}, this.props.animationMs);
16+
}
17+
componentWillUnmount() {
18+
window.clearInterval(this.interval);
19+
}
20+
render() {
21+
let dots = '.'.repeat(this.state.dots + 1);
22+
return `${this.props.text}${dots}`;
23+
}
24+
}

src/DeployPage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import classNames from 'classnames';
77
import AutoProgressBar from './AutoProgressBar';
88
import shortUrls from './shortUrls';
99
import { withRouter } from './Routes';
10+
import { EllipsisLoading } from './Common';
1011

1112
const BORS_LOGIN = 'bors[bot]';
1213

@@ -561,7 +562,7 @@ class Culprits extends React.PureComponent {
561562
<>
562563
<h3 className="page-header culprits">Culprits</h3>
563564
{error && <div className="alert alert-danger">{error.toString()}</div>}
564-
{loading && 'loading culprits...'}
565+
{loading && <EllipsisLoading text="loading culprits" />}
565566
{culprits && (
566567
<div className="culprits">
567568
{culprits.map(group => (

src/SetupPage.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { withRouter, Link } from 'react-router-dom';
33

44
import shortUrls from './shortUrls';
5+
import { EllipsisLoading } from './Common';
56

67
export default class SetupPage extends React.Component {
78
render() {
@@ -187,29 +188,6 @@ class PreviousEnvironments extends React.Component {
187188
}
188189
}
189190

190-
class EllipsisLoading extends React.PureComponent {
191-
state = { dots: 0 };
192-
static defaultProps = {
193-
text: 'Loading',
194-
animationMs: 400,
195-
maxDots: 5
196-
};
197-
componentDidMount() {
198-
this.interval = window.setInterval(() => {
199-
this.setState(state => {
200-
return { dots: (state.dots + 1) % this.props.maxDots };
201-
});
202-
}, this.props.animationMs);
203-
}
204-
componentWillUnmount() {
205-
window.clearInterval(this.interval);
206-
}
207-
render() {
208-
let dots = '.'.repeat(this.state.dots + 1);
209-
return `${this.props.text}${dots}`;
210-
}
211-
}
212-
213191
class WhatIsIt extends React.Component {
214192
render() {
215193
return (

0 commit comments

Comments
 (0)