Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 59453d6

Browse files
committed
Merge branch 'develop'
2 parents 7cfaf2b + 6d87102 commit 59453d6

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

__tests__/shared/__snapshots__/index.jsx.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
exports[`Matches shallow snapshot 1`] = `
44
<div>
55
<Connect(MetaTags)
6-
description="Yet another webapp based on Topcoder React Starter Kit"
7-
title="Topcoder React Starter"
6+
description="Topcoder Payment Tool"
7+
title="Topcoder Payment Tool"
88
/>
99
<Routes />
1010
</div>
@@ -13,8 +13,8 @@ exports[`Matches shallow snapshot 1`] = `
1313
exports[`Matches shallow snapshot in dev mode 1`] = `
1414
<div>
1515
<Connect(MetaTags)
16-
description="Yet another webapp based on Topcoder React Starter Kit"
17-
title="Topcoder React Starter"
16+
description="Topcoder Payment Tool"
17+
title="Topcoder Payment Tool"
1818
/>
1919
<Routes />
2020
<DevTools />

config/webpack/default.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
const publicPath = '';
99

1010
module.exports = {
11+
entry: {
12+
'loading-indicator-animation': './src/client/loading-indicator-animation',
13+
},
1114
externals: {
1215
/* NodeJS library for https://logentries.com. It is server-side only. Exclude it as null. */
1316
le_node: 'null',
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Client-side loading indicator animation. <LoadingIndicator> will often be rendered
3+
* server-side and animation code contained in the React component will not be loaded into
4+
* the browser. The following approach should animate any <LoadingIndicators> present
5+
* regardless of how they were rendered.
6+
* It might be possible to change the code to be class based rather than id based
7+
* so that multiple LoadingIndicators could be animated simulataneously
8+
* however it's difficult to determine what the class names will be due to the
9+
* automatic React class namespacing.
10+
*/
11+
12+
/* eslint-env browser */
13+
14+
function animateLoadingIndicators(timestamp) {
15+
const updateCircle = (circle, offset) => {
16+
const phase1 = ((timestamp / 1000 / 2) + offset) % 1;
17+
circle.setAttribute('r', 28 * phase1 * (2.0 - phase1));
18+
circle.setAttribute('opacity', 1.0 - (phase1 * phase1));
19+
};
20+
21+
const circle1 =
22+
document.querySelectorAll('circle[id="loading-indicator-circle1"]');
23+
const circle2 =
24+
document.querySelectorAll('circle[id="loading-indicator-circle2"]');
25+
26+
circle1.forEach(x => updateCircle(x, 0));
27+
circle2.forEach(x => updateCircle(x, 0.5));
28+
29+
window.requestAnimationFrame(animateLoadingIndicators);
30+
}
31+
32+
window.requestAnimationFrame(animateLoadingIndicators);

src/server/index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,33 @@
33
*/
44

55
import Application from 'shared';
6+
import fs from 'fs';
7+
import moment from 'moment';
8+
import path from 'path';
69
import { factory as reducerFactory } from 'reducers';
710
import { redux, server as serverFactory } from 'topcoder-react-utils';
811

912
import webpackConfigFactory from '../../webpack.config';
1013

1114
const mode = process.env.BABEL_ENV;
1215

16+
let ts = path.resolve(__dirname, '../../.build-info');
17+
ts = JSON.parse(fs.readFileSync(ts));
18+
ts = moment(ts.timestamp).valueOf();
19+
20+
const EXTRA_SCRIPTS = [
21+
`<script
22+
src="/loading-indicator-animation-${ts}.js"
23+
type="application/javascript"
24+
></script>`,
25+
];
26+
1327
async function beforeRender(req) {
1428
const store = await redux.storeFactory({
1529
getReducerFactory: () => reducerFactory,
1630
httpRequest: req,
1731
});
18-
return { store };
32+
return { extraScripts: EXTRA_SCRIPTS, store };
1933
}
2034

2135
global.KEEP_BUILD_INFO = true;

src/shared/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default function Application() {
1717
return (
1818
<div>
1919
<MetaTags
20-
title="Topcoder React Starter"
21-
description="Yet another webapp based on Topcoder React Starter Kit"
20+
title="Topcoder Payment Tool"
21+
description="Topcoder Payment Tool"
2222
/>
2323
<Routes />
2424
{ isomorphy.isDevBuild() ? <DevTools /> : undefined }

0 commit comments

Comments
 (0)