Skip to content

Visualization for CHIDO-25 #1619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading