-
Notifications
You must be signed in to change notification settings - Fork 1
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
Issue 44 create quiz frontend #80
base: main
Are you sure you want to change the base?
Changes from all commits
83032be
bb05f21
5443092
9b56c68
2e63f32
5a1d074
73c29fe
5d954e2
aa50eda
b66551a
e55301f
4f608ea
a04fb7e
fb55341
51624b4
c7dfc42
b642702
e51a703
8839ae5
9d0a9c2
7badcda
9ea8e9b
54c7e9c
a2742dc
3f52f89
f88de48
9ea61f7
b9739f1
68510f7
b9b771c
b779516
7c62775
6c4c5fc
9952e1c
bdcb22d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
|
||
function Competition() { | ||
return ( | ||
<> | ||
<h1 className="text-center">Past Questions and Solutions</h1> | ||
<div className="flex flex-col items-center gap-5"> | ||
<Button className="h-[66px] w-[998px] rounded-[5px] border-[1.5px] border-black bg-[#FFE8A3] text-[22px]"> | ||
Competition Name (e.g 2024) | ||
</Button> | ||
<Button>Competition Name (e.g 2024)</Button> | ||
<Button>Competition Name (e.g 2024)</Button> | ||
</div> | ||
<h1 className="text-center">Practice Test</h1> | ||
<div className="flex flex-col items-center gap-4"> | ||
<Button>Practice Test Name (e.g.WAJO Practice Test A)</Button> | ||
<Button>Practice Test Name (e.g.WAJO Practice Test A)</Button> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default Competition; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from "react"; | ||
|
||
interface Props { | ||
answer: string; | ||
setAnswer: (value: string) => void; | ||
} | ||
|
||
const AutoSavingAnswer: React.FC<Props> = ({ answer, setAnswer }) => { | ||
return ( | ||
<input | ||
type="text" | ||
value={answer} | ||
onChange={(e) => setAnswer(e.target.value)} | ||
placeholder="Please input your answer" | ||
className="mt-4 h-10 w-full min-w-64 rounded-sm border border-slate-500 px-2" | ||
/> | ||
); | ||
}; | ||
|
||
export default AutoSavingAnswer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
|
||
interface ButtonListProps { | ||
currentPage: number; | ||
setCurrentPage: (page: number) => void; | ||
totalQuestions: number; | ||
} | ||
|
||
const ButtonList: React.FC<ButtonListProps> = ({ | ||
currentPage, | ||
setCurrentPage, | ||
totalQuestions, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
}) => { | ||
const [startIndex, setStartIndex] = useState(0); | ||
const [endIndex, setEndIndex] = useState(10); | ||
const buttonsPerPage = 10; | ||
|
||
const updateIndexes = () => { | ||
// if (currentPage > endIndex) { | ||
// setStartIndex(currentPage - 1); | ||
// setEndIndex(currentPage + 9); | ||
// } else if (currentPage < startIndex) { | ||
// setStartIndex(currentPage - 1); | ||
// setEndIndex(currentPage + 9); | ||
// } | ||
if (startIndex === 0) { | ||
if (currentPage < 10) { | ||
setStartIndex(0); | ||
setEndIndex(10); | ||
} else if (currentPage >= 10) { | ||
setStartIndex(6); | ||
setEndIndex(16); | ||
} | ||
} else if (currentPage === 7) { | ||
setStartIndex(0); | ||
setEndIndex(10); | ||
} | ||
}; | ||
Comment on lines
+18
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const handleClick = (num: number) => { | ||
setCurrentPage(num); | ||
updateIndexes(); | ||
|
||
console.log(startIndex); | ||
console.log(endIndex); | ||
}; | ||
|
||
useEffect(() => { | ||
updateIndexes(); | ||
}, [currentPage]); | ||
|
||
return ( | ||
<div> | ||
<div className="flex flex-wrap gap-1"> | ||
{Array.from({ length: endIndex - startIndex }, (_, i) => ( | ||
<Button | ||
className="m-2" | ||
variant={startIndex + i + 1 === currentPage ? "default" : "outline"} | ||
size="icon" | ||
onClick={() => handleClick(startIndex + i + 1)} | ||
key={startIndex + i} | ||
> | ||
{startIndex + i + 1} | ||
</Button> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ButtonList; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from "react"; | ||
|
||
interface CountdownDisplayProps { | ||
timeLeft: number | null; | ||
} | ||
|
||
const formatTime = (timeLeft: number) => { | ||
const hours = Math.floor(timeLeft / 3600); | ||
const minutes = Math.floor((timeLeft - hours * 3600) / 60); | ||
const secs = timeLeft % 60; | ||
return `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`; | ||
}; | ||
|
||
const CountdownDisplay: React.FC<CountdownDisplayProps> = ({ timeLeft }) => { | ||
return ( | ||
<div> | ||
{timeLeft !== null ? ( | ||
<div className="rounded-full bg-green-500 px-6 py-2 text-lg font-semibold text-white shadow-md"> | ||
Time Left: {formatTime(timeLeft)} | ||
</div> | ||
) : ( | ||
<h2>Click "Start Quiz" to begin</h2> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default CountdownDisplay; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in style-guide.md
Please update the file name to:
button-list.tsx