-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Quiz Layour applied, svgs added with wrong z-indexes * flashcards route * Control bar arrows and jotai state for quizes set up * GetQuizData custom hook integrated with atoms * dynamic Flashcards page setup * Styled arrows for control bar (no server) * Flashcard and control bar jotai implementation * Flashcards page functionalities, name and length atoms * loading, error, 401, 404 pages
- Loading branch information
1 parent
7afe77b
commit 2778716
Showing
32 changed files
with
556 additions
and
174 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { api } from "@/api/axios"; | ||
import { QuizResponse } from "@/api/types/quiz"; | ||
import { atom } from "jotai"; | ||
import { atomWithQuery } from "jotai-tanstack-query"; | ||
|
||
interface updateParamsAtom { | ||
newName: string | undefined; | ||
newSlug: string | undefined; | ||
} | ||
|
||
interface updateCurrTermProps { | ||
value: number; | ||
length: number; | ||
} | ||
|
||
export const userNameAtom = atom<string | undefined>(""); | ||
export const quizSlugAtom = atom<string | undefined>(""); | ||
export const currTermAtom = atom<number>(0); | ||
|
||
export const quizNameAtom = atom<string>( | ||
get => get(quizAtom).data?.data.name ?? "Go Back" | ||
); | ||
|
||
export const quizLengthAtom = atom<number>( | ||
get => get(quizAtom).data?.data.questions.length ?? 0 | ||
); | ||
|
||
export const quizAtom = atomWithQuery(get => ({ | ||
queryKey: ["quiz", get(userNameAtom), get(quizSlugAtom)], | ||
queryFn: () => | ||
api.get<QuizResponse>( | ||
`/api/v1/Quiz/${get(userNameAtom)}/${get(quizSlugAtom)}` | ||
), | ||
})); | ||
|
||
export const updateParamsAtom = atom( | ||
null, | ||
(get, set, { newName, newSlug }: updateParamsAtom) => { | ||
if (newName !== get(userNameAtom) || newSlug !== get(quizSlugAtom)) { | ||
set(userNameAtom, newName); | ||
set(quizSlugAtom, newSlug); | ||
set(currTermAtom, 0); | ||
} | ||
} | ||
); | ||
|
||
export const updateCurrTermAtom = atom( | ||
null, | ||
(get, set, { value, length }: updateCurrTermProps) => { | ||
const prev = get(currTermAtom); | ||
value > 0 | ||
? prev === length - 1 | ||
? set(currTermAtom, 0) | ||
: set(currTermAtom, prev + 1) | ||
: prev === 0 | ||
? set(currTermAtom, length - 1) | ||
: set(currTermAtom, prev - 1); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Left from "./Left"; | ||
import Right from "./Right"; | ||
|
||
export default function Background() { | ||
return ( | ||
<> | ||
<div className="absolute top-0 w-full h-full bg-primary z-[-100]" /> | ||
<Right /> | ||
<Left /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export default function Left() { | ||
return ( | ||
<svg | ||
width="287" | ||
height="254" | ||
viewBox="0 0 287 254" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
className="absolute z-10 left-0 top-[50vh]" | ||
> | ||
<path | ||
opacity="0.1" | ||
d="M286.5 0.5L-14.5 254.5V69.5L286.5 0.5Z" | ||
fill="url(#paint0_linear_111:578)" | ||
></path> | ||
<defs> | ||
<linearGradient | ||
id="paint0_linear_111:578" | ||
x1="-40.5" | ||
y1="117" | ||
x2="301.926" | ||
y2="-97.1485" | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<stop stopColor="#4A6CF7"></stop> | ||
<stop offset="1" stopColor="#4A6CF7" stopOpacity="0"></stop> | ||
</linearGradient> | ||
</defs> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export default function Right() { | ||
return ( | ||
<svg | ||
width="628" | ||
height="258" | ||
viewBox="0 0 628 258" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
className="absolute z-10 right-0 top-0" | ||
> | ||
<path | ||
opacity="0.1" | ||
d="M669.125 257.002L345.875 31.9983L524.571 -15.8832L669.125 257.002Z" | ||
fill="url(#paint0_linear_0:1)" | ||
></path> | ||
<path | ||
opacity="0.1" | ||
d="M0.0716344 182.78L101.988 -15.0769L142.154 81.4093L0.0716344 182.78Z" | ||
fill="url(#paint1_linear_0:1)" | ||
></path> | ||
<defs> | ||
<linearGradient | ||
id="paint0_linear_0:1" | ||
x1="644" | ||
y1="221" | ||
x2="429.946" | ||
y2="37.0429" | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<stop stopColor="#4A6CF7"></stop> | ||
<stop offset="1" stopColor="#4A6CF7" stopOpacity="0"></stop> | ||
</linearGradient> | ||
<linearGradient | ||
id="paint1_linear_0:1" | ||
x1="18.3648" | ||
y1="166.016" | ||
x2="105.377" | ||
y2="32.3398" | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<stop stopColor="#4A6CF7"></stop> | ||
<stop offset="1" stopColor="#4A6CF7" stopOpacity="0"></stop> | ||
</linearGradient> | ||
</defs> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.