-
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.
Merge pull request #12 from fac30/Jason-Warren/Mood-Data
Jason warren/mood data
- Loading branch information
Showing
4 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
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,23 @@ | ||
'use client' | ||
|
||
import { useContext } from 'react' | ||
import { NeurochemContext } from '../page' | ||
|
||
export function Cube() { | ||
const context = useContext(NeurochemContext) | ||
|
||
if (!context) { | ||
throw new Error('Cube must be used within a NeurochemContext Provider') | ||
} | ||
|
||
const { neuroState } = context | ||
|
||
return ( | ||
<div className="p-4 border rounded"> | ||
<h3 className="text-white">Coordinates:</h3> | ||
<p className="text-white">x (dopamine): {neuroState.dopamine}</p> | ||
<p className="text-white">y (serotonin): {neuroState.serotonin}</p> | ||
<p className="text-white">z (adrenaline): {neuroState.adrenaline}</p> | ||
</div> | ||
) | ||
} |
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,38 @@ | ||
'use client' | ||
|
||
import { useContext } from 'react' | ||
import { NeurochemContext } from '../page' | ||
|
||
interface SliderProps { | ||
chem: 'dopamine' | 'serotonin' | 'adrenaline' | ||
} | ||
|
||
export function Slider({ chem }: SliderProps) { | ||
const context = useContext(NeurochemContext) | ||
|
||
if (!context) { | ||
throw new Error('Slider must be used within a NeurochemContext Provider') | ||
} | ||
|
||
const { neuroState, setNeuroState } = context | ||
|
||
const handleChange = (value: number) => { | ||
setNeuroState((prev) => ({ | ||
...prev, | ||
[chem]: value | ||
})) | ||
} | ||
|
||
return ( | ||
<div> | ||
<label className="text-white">{chem}</label> | ||
<input | ||
type="range" | ||
min="0" | ||
max="10" | ||
value={neuroState[chem]} | ||
onChange={(e) => handleChange(parseInt(e.target.value))} | ||
/> | ||
</div> | ||
) | ||
} |
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,13 @@ | ||
'use client' | ||
|
||
import { Slider } from './Slider' | ||
|
||
export function SliderBox() { | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<Slider chem="dopamine" /> | ||
<Slider chem="serotonin" /> | ||
<Slider chem="adrenaline" /> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,7 +1,35 @@ | ||
export default function Page() { | ||
'use client' | ||
|
||
import { createContext, useState } from 'react' | ||
import { Cube } from './components/Cube' | ||
import { SliderBox } from './components/SliderBox' | ||
|
||
interface NeurochemState { | ||
dopamine: number; | ||
serotonin: number; | ||
adrenaline: number; | ||
} | ||
|
||
interface NeurochemContextType { | ||
neuroState: NeurochemState; | ||
setNeuroState: React.Dispatch<React.SetStateAction<NeurochemState>>; | ||
} | ||
|
||
export const NeurochemContext = createContext<NeurochemContextType | null>(null) | ||
|
||
export default function MoodsPage() { | ||
const [neuroState, setNeuroState] = useState({ | ||
dopamine: 5, | ||
serotonin: 5, | ||
adrenaline: 5 | ||
}) | ||
|
||
return ( | ||
<> | ||
<h1 className="text-white">this is the moods page</h1> | ||
</> | ||
); | ||
<NeurochemContext.Provider value={{ neuroState, setNeuroState }}> | ||
<div className="flex flex-col gap-4"> | ||
<Cube /> | ||
<SliderBox /> | ||
</div> | ||
</NeurochemContext.Provider> | ||
) | ||
} |