Skip to content

Commit 689ff29

Browse files
committed
Add a visualization page for chido-25
1 parent 7c4e136 commit 689ff29

34 files changed

+12957
-0
lines changed

app/src/App/routes/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,21 @@ const preparednessOperationalLearning = customWrapRoute({
11871187
},
11881188
});
11891189

1190+
// Temporary Routes
1191+
const chidoTwentyFive = customWrapRoute({
1192+
parent: rootLayout,
1193+
path: 'chido-25',
1194+
component: {
1195+
render: () => import('#views/ChidoTwentyFive'),
1196+
props: {},
1197+
},
1198+
wrapperComponent: Auth,
1199+
context: {
1200+
title: 'Chido-25',
1201+
visibility: 'anything',
1202+
},
1203+
});
1204+
11901205
const wrappedRoutes = {
11911206
fourHundredFour,
11921207
rootLayout,
@@ -1267,6 +1282,7 @@ const wrappedRoutes = {
12671282
threeWProjectDetail,
12681283
termsAndConditions,
12691284
operationalLearning,
1285+
chidoTwentyFive,
12701286
...regionRoutes,
12711287
...countryRoutes,
12721288
...surgeRoutes,

app/src/declarations/geojson.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.geojson' {
2+
const content: object;
3+
export default content;
4+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import {
2+
useEffect,
3+
useRef,
4+
useState,
5+
} from 'react';
6+
import {
7+
NumberOutput,
8+
type NumberOutputProps,
9+
} from '@ifrc-go/ui';
10+
import {
11+
bound,
12+
isNotDefined,
13+
} from '@togglecorp/fujs';
14+
15+
const ANIMATION_DURATION = 800;
16+
17+
function useAnimationFrame<VALUE>(
18+
value: VALUE,
19+
interpolationFn: (
20+
initialValue: VALUE,
21+
finalValue: VALUE,
22+
progress: number,
23+
) => VALUE,
24+
initialValue = value,
25+
): VALUE {
26+
const [transitionValue, setTransitionValue] = useState(initialValue);
27+
const startTimestampRef = useRef<number>(0);
28+
const animationFrameRef = useRef<number>();
29+
const initialValueRef = useRef(initialValue);
30+
31+
useEffect(() => {
32+
function step(timestamp?: number) {
33+
if (!timestamp) {
34+
animationFrameRef.current = window.requestAnimationFrame(step);
35+
return;
36+
}
37+
38+
if (!startTimestampRef.current) {
39+
startTimestampRef.current = timestamp;
40+
}
41+
42+
const diff = timestamp - startTimestampRef.current;
43+
const progress = bound(
44+
diff / ANIMATION_DURATION,
45+
0,
46+
1,
47+
);
48+
const newValue = interpolationFn(initialValueRef.current, value, progress);
49+
setTransitionValue(newValue);
50+
51+
if (diff < ANIMATION_DURATION) {
52+
animationFrameRef.current = window.requestAnimationFrame(step);
53+
}
54+
}
55+
56+
step();
57+
58+
return () => {
59+
startTimestampRef.current = 0;
60+
initialValueRef.current = value;
61+
if (animationFrameRef.current) {
62+
window.cancelAnimationFrame(animationFrameRef.current);
63+
}
64+
};
65+
}, [value, interpolationFn]);
66+
67+
return transitionValue;
68+
}
69+
70+
function interpolateNumber(
71+
initialValue: number | null | undefined,
72+
finalValue: number | null | undefined,
73+
progress: number,
74+
) {
75+
if (isNotDefined(initialValue) || isNotDefined(finalValue)) {
76+
return undefined;
77+
}
78+
79+
return Math.round(initialValue + (finalValue - initialValue) * progress);
80+
}
81+
82+
function AnimatedNumberOutput(props: NumberOutputProps) {
83+
const {
84+
value,
85+
...otherProps
86+
} = props;
87+
88+
const modifiedValue = useAnimationFrame(
89+
value,
90+
interpolateNumber,
91+
);
92+
93+
return (
94+
<NumberOutput
95+
value={modifiedValue}
96+
// eslint-disable-next-line react/jsx-props-no-spreading
97+
{...otherProps}
98+
/>
99+
);
100+
}
101+
102+
export default AnimatedNumberOutput;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type":"FeatureCollection","metadata":{},"features":[]}

app/src/views/ChidoTwentyFive/data/geojson_1001131_10.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_11.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_12.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_13.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_14.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_15.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_16.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_17.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_18.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_19.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type":"FeatureCollection","metadata":{},"features":[]}

app/src/views/ChidoTwentyFive/data/geojson_1001131_20.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_21.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_22.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_23.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_24.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_25.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_26.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_27.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_28.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_29.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/src/views/ChidoTwentyFive/data/geojson_1001131_3.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)