Skip to content

Commit

Permalink
Merge pull request #44 from microsoft/anpethel/modifyingResultScreen
Browse files Browse the repository at this point in the history
modifying result screen
  • Loading branch information
andrewpethel committed Sep 19, 2024
2 parents c5ffb47 + 3411da5 commit d81f80c
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 48 deletions.
Binary file added Client/public/AwardRibbon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/public/favicon.ico
Binary file not shown.
6 changes: 3 additions & 3 deletions Client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="%PUBLIC_URL%/CC_Logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/CC_Logo.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
<title>CareerCraft</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
6 changes: 3 additions & 3 deletions Client/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"name": "CareerCraft",
"icons": [
{
"src": "favicon.ico",
"src": "CC_Logo.png",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"src": "CC_Logo.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"src": "CC_Logo.png",
"type": "image/png",
"sizes": "512x512"
}
Expand Down
3 changes: 3 additions & 0 deletions Client/src/components/Confetti/Confetti.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.confetti-fade {
transition: opacity 6s ease-out;
}
37 changes: 30 additions & 7 deletions Client/src/components/Confetti/Confetti.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import Confetti from 'react-confetti';
import "./Confetti.scss";

interface ConfettiProps {
width: number;
Expand All @@ -9,21 +10,43 @@ interface ConfettiProps {

export const ConfettiComponent: React.FC<ConfettiProps> = ({ width, height, run }) => {
const [confettiRun, setConfettiRun] = useState(false);
const [confettiOpacity, setConfettiOpacity] = useState(1);
const timeoutRef = useRef<NodeJS.Timeout | null>(null);

useEffect(() => {
if (run) {
setConfettiRun(true);
const timer = setTimeout(() => setConfettiRun(false), 5000); // Run confetti for 5 seconds
return () => clearTimeout(timer);
setConfettiOpacity(1); // Reset opacity to 1 when confetti starts
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
timeoutRef.current = setTimeout(() => {
setConfettiOpacity(0); // Start fading out
setTimeout(() => {
setConfettiRun(false);
}, 5000); // Wait for the fade to complete before setting confettiRun to false
}, 10000); // 3 seconds before starting to fade
} else {
setConfettiRun(false);
setConfettiOpacity(0); // Ensure confetti is invisible when run is false
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
}

return () => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
};
}, [run]);

return confettiRun ? (
<Confetti
width={width}
height={height}
/>
<div className="confetti-fade" style={{ opacity: confettiOpacity }}>
<Confetti
width={width}
height={height}
/>
</div>
) : null;
};
4 changes: 3 additions & 1 deletion Client/src/components/Form/Button/button.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "../../../variables.scss";

@mixin base-button-style {
display: block;
display: inline-block;
padding: 0.5rem 1rem;
border: none;
border-radius: 0.5rem;
Expand All @@ -19,6 +19,8 @@
background-color: $primary-color;
border: 2px solid $primary-color;
color: white;
display: block;
justify-content: space-between;
}

.default-button {
Expand Down
2 changes: 1 addition & 1 deletion Client/src/components/Layout/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function Footer(): React.ReactElement {
return (
<footer className="footer">
<div>
<img src="slogan.png" alt="CareerCraft logo" className="ms-nav-logo" />
<img src="slogan.png" alt="CareerCraft is a Microsoft Hackathon project" className="ms-nav-logo" />
</div>
</footer>
);
Expand Down
20 changes: 7 additions & 13 deletions Client/src/components/Layout/Layout.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.header-container {

}

.content-container {
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -30,15 +26,6 @@
height: 100%;
}

// .game-screen-center {
// display: flex;
// flex-direction: column;
// align-items: center;
// justify-content: center;
// height: 100%;
// margin: 50px 0;
// }

.game-screen-margin-top {
margin-top: 50px;
}
Expand All @@ -56,3 +43,10 @@
height: auto;
margin-bottom: 100px;
}

.careercraft-award-logo {
max-width: 160px;
height: auto;
margin-bottom: 20px;
margin-top: 50px;
}
2 changes: 1 addition & 1 deletion Client/src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function Layout(props: LayoutProps): React.ReactElement {
return (
<>
<SkipToMain />
<div className="header-container">
<div>
<Header />
</div>
<div className="content-container">
Expand Down
20 changes: 10 additions & 10 deletions Client/src/screens/GameScreen/GameScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ export function GameScreen(): React.ReactElement {
</ButtonBar>

<div className="game-screen-margin-top">
<div className="game-screen-content-margin">
<div>
<H2>Outcome</H2>
<p>{round.outcome}</p>
</div>

<div>
<div className="game-screen-content-margin">
<H2>Scenario</H2>
<p>{round.scenario}</p>
</div>
Expand All @@ -107,19 +107,19 @@ export function GameScreen(): React.ReactElement {
<H2>Options</H2>
<ButtonBar>
{round.options.map((option, index) => (
<PrimaryButton
key={index}
onClick={() => handleOptionSelected(option)}
title={`Select ${option}`}
label={option}
disabled={isRoundCompleted}
/>
<PrimaryButton
key={index}
onClick={() => handleOptionSelected(option)}
title={`Select ${option}`}
label={option}
disabled={isRoundCompleted}
/>
))}
</ButtonBar>
</div>
</div>

<Spinner show={isLoading}/>
<Spinner show={isLoading} />
</div>
);
}
40 changes: 32 additions & 8 deletions Client/src/screens/ResultScreen/ResultScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { H1 } from "../../components/Typography";
import { AppContext } from "../../context/AppContext";
import { usePageTracking } from "../../hooks/usePageTracking";
import { IAppContext } from "../../models/IAppContext";
import Confetti from 'react-confetti';
import { ConfettiComponent } from "../../components/Confetti/Confetti";

export function ResultScreen(): React.ReactElement {
usePageTracking("ResultScreen");
const { finalMessage, userName } = React.useContext<IAppContext>(AppContext);
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
const [windowHeight, setWindowHeight] = useState(window.innerHeight);
const [showConfetti, setShowConfetti] = useState(true);
const [confettiOpacity, setConfettiOpacity] = useState(1);

useEffect(() => {
const handleResize = () => {
Expand All @@ -19,17 +21,39 @@ export function ResultScreen(): React.ReactElement {

window.addEventListener('resize', handleResize);

return () => window.removeEventListener('resize', handleResize);
// Set timer to start fading confetti after 6 seconds
const fadeTimer = setTimeout(() => {
setShowConfetti(false);
setConfettiOpacity(0); // Start fading out
}, 15000);

return () => {
window.removeEventListener('resize', handleResize);
clearTimeout(fadeTimer);
};
}, []);

return (
<div>
<H1>Great work, {userName}!</H1>
{finalMessage}
<Confetti
width={windowWidth}
height={windowHeight}
/>
<div className="start-screen-center">
<img
src="AwardRibbon.png"
alt="Award Ribbon"
className="careercraft-award-logo"
/>
<H1>Great work, {userName}!</H1>
{finalMessage}
</div>

{showConfetti && (
<div style={{ opacity: confettiOpacity }} className="confetti-fade">
<ConfettiComponent
width={windowWidth}
height={windowHeight}
run={showConfetti}
/>
</div>
)}
</div>
);
}
2 changes: 1 addition & 1 deletion Client/src/variables.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Primary colors
$primary-color: #1F76A7;
$primary-color-dark: #4dabf5;
$primary-color-dark: white;
$default-color: white;
$error-color: #d32f2f;

Expand Down

0 comments on commit d81f80c

Please sign in to comment.