Skip to content

Commit 51855ab

Browse files
authored
Implemented the main backend for the Facial Recongtion Game (#113)
1 parent ee09670 commit 51855ab

File tree

2 files changed

+50
-27
lines changed

2 files changed

+50
-27
lines changed

website/src/caseStudies/FacialRecognition.js

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import React from "react";
22
import "../main.css";
33
import teachLogo from "../assets/teachla-logo.svg";
44
import PostsList from "../components/mainContent/PostsList";
5+
import CounterFrame from "../components/posts/FacialRecognition/CounterFrame";
56
import { VisibilityProvider } from "../components/mainContent/commonLogic";
67

8+
79
export default function FacialRecognition() {
810
return (
911
<VisibilityProvider>
@@ -39,35 +41,11 @@ const FacialRecognitionInfo = [
3941
post: {
4042
profilePic: teachLogo,
4143
profilePicName: "Profile Picture - Frame 1",
42-
header: "Frame 1",
43-
subheader: "Why Is This Important?",
44+
header: "Facial Recognition Game",
45+
subheader: "Understanding Bias Through Categorization",
4446
bodyText: [
4547
{
46-
body: (
47-
<p className="bold">
48-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
49-
eiusmod tempor incididunt ut labore et dolore magna aliqua.
50-
</p>
51-
),
52-
},
53-
{
54-
body: (
55-
<p>
56-
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
57-
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
58-
reprehenderit in voluptate velit esse cillum dolore eu fugiat
59-
nulla pariatur.
60-
</p>
61-
),
62-
},
63-
{
64-
body: (
65-
<p>
66-
<mark className="bold">{`TODO: `} </mark>Excepteur sint occaecat
67-
cupidatat non proident, sunt in culpa qui officia deserunt mollit
68-
anim id est laborum.
69-
</p>
70-
),
48+
body: <CounterFrame />
7149
},
7250
],
7351
},
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, { useState } from 'react';
2+
3+
function CounterFrame() {
4+
const numbers = [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15];
5+
const [currentIndex, setCurrentIndex] = useState(0);
6+
const [counters, setCounters] = useState([0, 0, 0, 0]);
7+
const [processedLast, setProcessedLast] = useState(false);
8+
9+
10+
const handleButtonClick = (counterIndex) => {
11+
//Checks to make sure we haven't iterated through the last element yet
12+
if(!processedLast) {
13+
// Makes a copy of the current counters array
14+
const updatedCounters = [...counters];
15+
updatedCounters[counterIndex] = updatedCounters[counterIndex] + 1;
16+
setCounters(updatedCounters);
17+
18+
if (currentIndex < numbers.length - 1) {
19+
setCurrentIndex(currentIndex + 1);
20+
}
21+
else {
22+
setProcessedLast(true);
23+
}
24+
}
25+
};
26+
27+
return (
28+
<div>
29+
<h2>Current Number: {numbers[currentIndex]}</h2>
30+
<div>
31+
{counters.map((count, index) => (
32+
<button
33+
key={index}
34+
onClick={() => handleButtonClick(index)}
35+
style={{ marginRight: '10px', marginTop: '10px' }}
36+
>
37+
Counter {index + 1}: {count}
38+
</button>
39+
))}
40+
</div>
41+
</div>
42+
);
43+
}
44+
45+
export default CounterFrame;

0 commit comments

Comments
 (0)