diff --git a/src/App.tsx b/src/App.tsx index be5991b..e0a21d7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,6 +5,7 @@ import { useState, useEffect } from "react"; import ModeToggle from "@components/ModeToggle/ModeToggle"; import Review from "@components/Modes/Review/Review"; import Challenge from "@components/Modes/Challenge/Challenge"; +import ChallengeContextProvider from "@context/challenge"; import { Mode } from "@types"; @@ -15,15 +16,17 @@ function App() { const [activeMode, setActiveMode] = useState(Mode.review); return ( -
-
-

- Music Theory Practice -

- - {activeMode === Mode.review ? : } + +
+
+

+ Music Theory Practice +

+ + {activeMode === Mode.review ? : } +
-
+ ); } diff --git a/src/components/Modes/Challenge/Challenge.tsx b/src/components/Modes/Challenge/Challenge.tsx index ed1268e..7d349e7 100644 --- a/src/components/Modes/Challenge/Challenge.tsx +++ b/src/components/Modes/Challenge/Challenge.tsx @@ -1,10 +1,11 @@ -import { useState } from "react"; +import { useState, useContext } from "react"; import classNames from "classnames"; import { shuffle } from "lodash"; import { Note, Scale } from "@types"; import data from "@data"; +import { ChallengeContext } from "@context/challenge"; const { notes, scales } = data; // this stuff will need to be refs or go in an effect as we will lose it on renders... const shuffledNotes: Note[] = shuffle(notes); @@ -16,7 +17,7 @@ export default function Challenge() { const [notesFound, setNotesFound] = useState([]); const [inProgress, setInprogress] = useState(true); const notesLeftCount = notesLeft.length; - + console.log("context", useContext(ChallengeContext)); function handleClick(id: number): void { const index = notesLeft.indexOf(id); if (index > -1) { @@ -48,6 +49,7 @@ export default function Challenge() { onClick={() => { handleClick(note.id); }} + key={note.id} className={classNames("rounded-md m-2 basis-1/4 h-20", { "bg-green-500": notesFound.includes(note.id), "bg-sky-500/50": !notesFound.includes(note.id), diff --git a/src/components/Notes/Notes.tsx b/src/components/Notes/Notes.tsx index cae9758..304b5d6 100644 --- a/src/components/Notes/Notes.tsx +++ b/src/components/Notes/Notes.tsx @@ -31,10 +31,8 @@ export default function Notes({ activeNotes, activeScale }: NotesProps) { return (
{activeNotes.map((note, i) => ( -
- +
+
{mapNotesToLabelsMajor(i)}
))} diff --git a/src/context/challenge.tsx b/src/context/challenge.tsx new file mode 100644 index 0000000..04e8652 --- /dev/null +++ b/src/context/challenge.tsx @@ -0,0 +1,16 @@ +import React, { createContext, useState } from "react"; +export const ChallengeContext = createContext({}); + +type Props = { + children: React.ReactNode; +}; + +export default function ChallengeContextProvider({ children }: Props) { + const [foo, setFoo] = useState(false); + + return ( + + {children} + + ); +} diff --git a/tsconfig.json b/tsconfig.json index 2dbebfd..952382d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "@data":["src/data.json"], "@components/*": ["src/components/*"], "@utils/*": ["src/utils/*"], + "@context/*": ["src/context/*"], "@types": ["src/types.ts"], }, "target": "ES2020", diff --git a/vite.config.ts b/vite.config.ts index 0f02b48..577de4f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -16,6 +16,7 @@ export default defineConfig({ "@utils": path.resolve(__dirname, "./src/utils"), "@data": path.resolve(__dirname, "./src/data.json"), "@types": path.resolve(__dirname, "./src/types.ts"), + "@context": path.resolve(__dirname, "./src/context"), }, }, test: {