Skip to content
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

feat (#319): progress tracking update #340

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
34 changes: 29 additions & 5 deletions src/components/ChonkyFooter.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
import styles from './ChonkyFooter.module.css';
import { useUserState } from '@context/user';
import FloatingAstronaut from '@components/FloatingAstronaut';

export default function Layout({ mission, currentStage }) {
const { user } = useUserState();
const missionTotal =
mission.stages && mission.stages.length ? mission.stages.length : 1;

const currentMission = () => {
const currentStageIndex = () => {
if (!mission.stages) return 0;
return mission.stages.findIndex((el) => {
return el.slug.current === currentStage;
});
};

const missionProgress = () => {
const progressDecimal = user.activity.userMissions?.find(
(userMission) => userMission.title === mission.title
).progress;

return `${Math.ceil(progressDecimal * 100)}%`;
};

const progressIndicator = () => {
if (currentStage) {
return (
<div className={styles.progress}>
<h3>your progress</h3>
<h3>Current Stage</h3>

<svg
xmlns="http://www.w3.org/2000/svg"
width="130"
width="300"
height="100"
viewBox="0 0 130 100"
viewBox="0 0 300 100"
>
<g fill="white">
<line
Expand All @@ -34,7 +44,7 @@ export default function Layout({ mission, currentStage }) {
strokeWidth="2"
/>
<text x="50" y="40" fontSize="50px">
{currentMission() + 1}
{currentStageIndex() + 1}
</text>
<line
x1="110"
Expand All @@ -47,6 +57,20 @@ export default function Layout({ mission, currentStage }) {
<text x="90" y="70" fontSize="30px">
{missionTotal}
</text>
<line
x1="140"
x2="140"
y1="3"
y2="80"
stroke="currentColor"
strokeWidth="2"
/>
<text x="150" y="40" fontSize="50px">
{missionProgress()}
</text>
<text x="150" y="70" fontSize="25px">
Complete
</text>
</g>
</svg>
</div>
Expand Down