Skip to content

Commit

Permalink
add end widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Batleram committed Sep 29, 2024
1 parent 80cf8f5 commit ac0deb0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion App/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function generateConfig(): Promise<React.ReactNode[]> {
})
.then(data => data.json())
.then(suggestions => {
const widgets = generateWidgets({ config: suggestions, numberOfWidgets: 15 })
const widgets = generateWidgets({ config: suggestions, numberOfWidgets: CONFIG.MAX_WIDGETS })
resolve(widgets);
})
.catch(reject)
Expand Down
4 changes: 2 additions & 2 deletions App/src/components/categories/Affirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Affirmation = (props: AffirmationProps) => {

useEffect(() => {
if (affRef.current && writeRef.current) {
gsap.fromTo(affRef.current, { opacity: 0 }, { opacity: 1, duration: 2, ease: "power2.inOut" });
gsap.fromTo(affRef.current, { opacity: 0 }, { opacity: 1, duration: 0.5, ease: "power2.inOut" });
gsap.fromTo(writeRef.current, { scale: 0.9 }, { scale: 1.1, duration: 1, yoyo: true, repeat: -1, ease: "bounce.in" });
}
}, []);
Expand All @@ -34,4 +34,4 @@ const Affirmation = (props: AffirmationProps) => {
);
}

export default Affirmation;
export default Affirmation;
31 changes: 31 additions & 0 deletions App/src/components/categories/EndCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useEffect, useRef } from "react";
import { FaCrown } from "react-icons/fa";
import { gsap } from 'gsap';

const EndCard = () => {
const affRef = useRef<HTMLDivElement>(null);
const writeRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (affRef.current && writeRef.current) {
gsap.fromTo(affRef.current, { opacity: 0 }, { opacity: 1, duration: 0.5, ease: "power2.inOut" });
gsap.fromTo(writeRef.current, { scale: 0.9 }, { scale: 1.1, duration: 1, yoyo: true, repeat: -1, ease: "bounce.in" });
}
}, []);

return (
<div className="flex justify-center items-center h-full bg-slate-900">
<div>
<div ref={affRef} className="pb-8 text-2xl text-slate-200">
Good Job!!<br />
<small>You're all done</small>
</div>
<div ref={writeRef} className="flex justify-center items-center text-slate-200">
<FaCrown size={148} />
</div>
</div>
</div>
)
}

export default EndCard;
2 changes: 1 addition & 1 deletion App/src/components/categories/Exercise.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ const Exercise = (props: ExerciseProps) => {
);
}

export default Exercise;
export default Exercise;
2 changes: 1 addition & 1 deletion App/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const CONFIG = {
/**
* @brief The max widgets that the app will generate for a given day
*/
MAX_WIDGETS: 4,
MAX_WIDGETS: 15,
/**
* @brief The time after which it is considered the end of day (military time)
*/
Expand Down
3 changes: 3 additions & 0 deletions App/src/utils/generateWidgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Social from "../components/categories/Social";
import Water from "../components/categories/Water";
import Widget from "../components/Widget";
import Affirmation from "../components/categories/Affirmation";
import EndCard from "../components/categories/EndCard"
import { Affirmations } from "./constants";

export interface Widget {
Expand Down Expand Up @@ -62,5 +63,7 @@ export const generateWidgets = (props: Widget): React.ReactNode[] => {
widgets.push(<Widget><Affirmation affirmation={affirmation}></Affirmation></Widget>);
}
}

widgets.push(<Widget><EndCard></EndCard></Widget>)
return widgets;
}

0 comments on commit ac0deb0

Please sign in to comment.