Skip to content

Commit

Permalink
Add a visualization page for chido-25
Browse files Browse the repository at this point in the history
  • Loading branch information
frozenhelium committed Dec 31, 2024
1 parent 7c4e136 commit ed140cd
Show file tree
Hide file tree
Showing 34 changed files with 12,898 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/App/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,21 @@ const preparednessOperationalLearning = customWrapRoute({
},
});

// Temporary Routes
const chidoTwentyFive = customWrapRoute({
parent: rootLayout,
path: 'chido-25',
component: {
render: () => import('#views/ChidoTwentyFive'),
props: {},
},
wrapperComponent: Auth,
context: {
title: 'Chido-25',
visibility: 'anything',
},
});

const wrappedRoutes = {
fourHundredFour,
rootLayout,
Expand Down Expand Up @@ -1267,6 +1282,7 @@ const wrappedRoutes = {
threeWProjectDetail,
termsAndConditions,
operationalLearning,
chidoTwentyFive,
...regionRoutes,
...countryRoutes,
...surgeRoutes,
Expand Down
4 changes: 4 additions & 0 deletions app/src/declarations/geojson.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.geojson' {
const content: object;
export default content;
}
102 changes: 102 additions & 0 deletions app/src/views/ChidoTwentyFive/AnimatedNumberOutput/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import {
useEffect,
useRef,
useState,
} from 'react';
import {
NumberOutput,
type NumberOutputProps,
} from '@ifrc-go/ui';
import {
bound,
isNotDefined,
} from '@togglecorp/fujs';

const ANIMATION_DURATION = 800;

function useAnimationFrame<VALUE>(
value: VALUE,
interpolationFn: (
initialValue: VALUE,
finalValue: VALUE,
progress: number,
) => VALUE,
initialValue = value,
): VALUE {
const [transitionValue, setTransitionValue] = useState(initialValue);
const startTimestampRef = useRef<number>(0);
const animationFrameRef = useRef<number>();
const initialValueRef = useRef(initialValue);

useEffect(() => {
function step(timestamp?: number) {
if (!timestamp) {
animationFrameRef.current = window.requestAnimationFrame(step);
return;
}

if (!startTimestampRef.current) {
startTimestampRef.current = timestamp;
}

const diff = timestamp - startTimestampRef.current;
const progress = bound(
diff / ANIMATION_DURATION,
0,
1,
);
const newValue = interpolationFn(initialValueRef.current, value, progress);
setTransitionValue(newValue);

if (diff < ANIMATION_DURATION) {
animationFrameRef.current = window.requestAnimationFrame(step);
}
}

step();

return () => {
startTimestampRef.current = 0;
initialValueRef.current = value;
if (animationFrameRef.current) {
window.cancelAnimationFrame(animationFrameRef.current);
}
};
}, [value, interpolationFn]);

return transitionValue;
}

function interpolateNumber(
initialValue: number | null | undefined,
finalValue: number | null | undefined,
progress: number,
) {
if (isNotDefined(initialValue) || isNotDefined(finalValue)) {
return undefined;
}

return Math.round(initialValue + (finalValue - initialValue) * progress);
}

function AnimatedNumberOutput(props: NumberOutputProps) {
const {
value,
...otherProps
} = props;

const modifiedValue = useAnimationFrame(
value,
interpolateNumber,
);

return (
<NumberOutput
value={modifiedValue}
// eslint-disable-next-line react/jsx-props-no-spreading
{...otherProps}
/>
);
}

export default AnimatedNumberOutput;
1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"FeatureCollection","metadata":{},"features":[]}
1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_10.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_11.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_12.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_13.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_14.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_15.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_16.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_17.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_18.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_19.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"FeatureCollection","metadata":{},"features":[]}
1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_20.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_21.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_22.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_23.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_24.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_25.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_26.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_27.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_28.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_29.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/views/ChidoTwentyFive/data/geojson_1001131_3.json

Large diffs are not rendered by default.

Loading

0 comments on commit ed140cd

Please sign in to comment.