Skip to content

Commit 5682b00

Browse files
committed
re: minor refactor changes + bg patterns added
1 parent 40490a3 commit 5682b00

7 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import Header from "./components/Header";
33

44
function App() {
55
return (
6-
<div className="bg-background text-text-primary font-display min-h-dvh px-6 leading-none font-medium md:px-16 xl:px-[8.75rem]">
7-
<div className="mx-auto max-w-[1440px] gap-[2.5rem] md:gap-[4rem] xl:gap-[8rem] 2xl:max-w-[1650px]">
6+
<div className="bg-background text-text-primary font-display min-h-dvh bg-[image:var(--image-mobile)] bg-cover bg-center bg-no-repeat px-6 leading-none font-medium md:bg-[image:var(--image-tablet)] md:bg-size-[58%] md:bg-top-left md:px-16 xl:bg-[image:var(--image-desktop)] xl:bg-cover xl:bg-center xl:px-[8.75rem]">
7+
<div className="mx-auto max-w-[1440px] gap-[2.5rem] md:gap-[4rem] xl:gap-[8rem]">
88
<Header />
99
<main>
1010
<Outlet />

src/components/Header.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import Title from "./Title";
2-
import data from "../data/data.json";
32
import type { TitleType } from "../types";
43
import ThemeSwitcher from "./ThemeSwitcher";
54
import useQuiz from "../hooks/useQuiz";
65

76
export default function Header() {
8-
const { topic } = useQuiz();
7+
const { quiz } = useQuiz();
98

109
const title: TitleType = {
11-
title: data.quizzes.find((quiz) => quiz.title === topic)?.title || "",
12-
iconPath: data.quizzes.find((quiz) => quiz.title === topic)?.icon || "",
10+
title: quiz?.title ?? "",
11+
iconPath: quiz?.icon ?? "",
1312
};
1413

1514
return (
1615
<header className="pb- flex justify-between pt-4 pb-[48px] md:py-[3.125rem] xl:py-[83px]">
1716
<div>
18-
{topic ? <Title title={title.title} iconPath={title.iconPath} /> : ""}
17+
{quiz ? <Title title={title.title} iconPath={title.iconPath} /> : ""}
1918
</div>
2019
<ThemeSwitcher />
2120
</header>

src/components/QuizButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const QuizButton = ({ onClickHandler, children }: Props) => {
77
return (
88
<button
99
onClick={onClickHandler}
10+
type="button"
1011
className={`bg-primary relative isolate flex w-full cursor-pointer items-center justify-center overflow-hidden rounded-[12px] py-[19px] transition-colors duration-300 before:absolute before:inset-0 before:bg-white/50 before:opacity-0 before:transition-opacity before:duration-300 hover:before:opacity-100 focus:outline-0 focus:before:opacity-100 md:rounded-[24px] md:p-8`}
1112
>
1213
<div className="text-[1.125rem] text-white md:text-[1.75rem]">

src/components/quiz/QuestionArea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function QuestionArea({
1212
const totalQuestions = questions.length;
1313

1414
// Calculate the progress percentage
15-
const progressPercentage = (questionIndex / totalQuestions) * 100;
15+
const progressPercentage = ((questionIndex + 1) / totalQuestions) * 100;
1616

1717
return (
1818
<div className="flex flex-col gap-6 md:gap-10 xl:max-w-[472px] xl:gap-[11.5rem]">

src/components/quiz/VariantButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const VariantButton = ({
4444
},
4545
)}
4646
onClick={onClick}
47+
type="button"
4748
disabled={isAnswered ? true : false}
4849
>
4950
<div

src/index.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
--color-text-letter: var(--text-letter);
4141
--color-circle: var(--circle);
4242
--color-variant-foreground-text: var(--variant-foreground-text);
43+
--image-desktop: var(--bg-image-desktop);
44+
--image-tablet: var(--bg-image-tablet);
45+
--image-mobile: var(--bg-image-mobile);
4346
}
4447

4548
:root {
@@ -59,6 +62,9 @@
5962
--js-background: #ebf0ff;
6063
--accessibility-background: #f6e7ff;
6164
--variant-foreground-text: #626c7f;
65+
--bg-image-desktop: url("./assets/images/pattern-background-desktop-light.svg");
66+
--bg-image-tablet: url("./assets/images/pattern-background-tablet-light.svg");
67+
--bg-image-mobile: url("./assets/images/pattern-background-mobile-light.svg");
6268
}
6369

6470
.dark {
@@ -77,4 +83,7 @@
7783
--css-background: #e0fdef;
7884
--js-background: #ebf0ff;
7985
--accessibility-background: #f6e7ff;
86+
--bg-image-desktop: url("./assets/images/pattern-background-desktop-dark.svg");
87+
--bg-image-tablet: url("./assets/images/pattern-background-tablet-dark.svg");
88+
--bg-image-mobile: url("./assets/images/pattern-background-mobile-dark.svg");
8089
}

src/pages/QuizPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function QuizPage() {
2626
if (isLastQuestion) {
2727
navigate(`/result/${topic}`);
2828
} else {
29-
setIsAnswered((prev): boolean => !prev);
29+
setIsAnswered(false);
3030
setSelectedOption(null);
3131
setQuestionIndex((prev) => prev + 1);
3232
}
@@ -50,7 +50,7 @@ export default function QuizPage() {
5050
increaseScore();
5151
}
5252

53-
setIsAnswered((prev): boolean => !prev);
53+
setIsAnswered(true);
5454
};
5555

5656
const handleSelectedOption = (index: number) => {

0 commit comments

Comments
 (0)