-
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.
- Loading branch information
1 parent
2568a80
commit fa1d674
Showing
24 changed files
with
490 additions
and
230 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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,17 @@ | ||
import React from 'react'; | ||
|
||
const AboutPage: React.FC = () => { | ||
return ( | ||
<div className="container mx-auto px-4 py-8"> | ||
<h1 className="text-3xl font-bold mb-4">About Digital Memory Playground</h1> | ||
<p className="text-lg mb-4"> | ||
Digital Memory Playground is designed to enhance memory and cognitive skills through interactive and themed exercises. | ||
</p> | ||
<p className="text-lg"> | ||
Whether you're in the Kitchen, Farm, Library, or Office, Digital Memory Playground offers enjoyable and stimulating challenges to keep your mind sharp. | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AboutPage; |
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,78 @@ | ||
'use client'; | ||
|
||
import React, { useState, useEffect } from 'react'; | ||
import Image from 'next/image'; | ||
|
||
const DisplayImagesPage = () => { | ||
// Assuming all images are in the public/images folder | ||
const images = ['/images/kitchen.png', '/images/farm.png', '/images/placeholder.png']; | ||
|
||
const [imageStates, setImageStates] = useState(images.map(() => ({ x: 0, y: 0, dragging: false, offsetX: 0, offsetY: 0 }))); | ||
|
||
const handleMouseDown = (index, e) => { | ||
e.stopPropagation(); | ||
const offsetX = e.clientX - imageStates[index].x; | ||
const offsetY = e.clientY - imageStates[index].y; | ||
setImageStates((prevState) => | ||
prevState.map((state, i) => (i === index ? { ...state, dragging: true, offsetX, offsetY } : state)) | ||
); | ||
}; | ||
|
||
const handleMouseMove = (e) => { | ||
setImageStates((prevState) => | ||
prevState.map((state) => { | ||
if (state.dragging) { | ||
return { | ||
...state, | ||
x: e.clientX - state.offsetX, | ||
y: e.clientY - state.offsetY, | ||
}; | ||
} | ||
return state; | ||
}) | ||
); | ||
}; | ||
|
||
const handleMouseUp = () => { | ||
setImageStates((prevState) => prevState.map((state) => ({ ...state, dragging: false }))); | ||
}; | ||
|
||
useEffect(() => { | ||
document.addEventListener('mousemove', handleMouseMove); | ||
document.addEventListener('mouseup', handleMouseUp); | ||
return () => { | ||
document.removeEventListener('mousemove', handleMouseMove); | ||
document.removeEventListener('mouseup', handleMouseUp); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className="container mx-auto px-4 py-8 text-center"> | ||
<h2 className="text-2xl font-semibold mb-4">Images</h2> | ||
<p className="mb-6">Drag the images into your own groupings!</p> | ||
<div className="relative"> | ||
{images.map((imageUrl, index) => ( | ||
<Image | ||
key={index} | ||
src={imageUrl} | ||
alt={`Image ${index}`} | ||
width={200} | ||
height={200} | ||
className="generated-image" | ||
style={{ | ||
position: 'absolute', | ||
left: `${imageStates[index].x}px`, | ||
top: `${imageStates[index].y}px`, | ||
cursor: imageStates[index].dragging ? 'grabbing' : 'grab', | ||
userSelect: 'none', | ||
transition: 'transform 0.1s', | ||
}} | ||
onMouseDown={(e) => handleMouseDown(index, e)} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DisplayImagesPage; |
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,110 @@ | ||
'use client'; | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import { useParams, useRouter } from 'next/navigation'; | ||
import Image from 'next/image'; | ||
import { environments } from '../../../data/environments'; | ||
import Button from '../../../components/common/Button'; | ||
|
||
const EnvironmentPage: React.FC = () => { | ||
const { id } = useParams(); | ||
const router = useRouter(); | ||
const [input, setInput] = useState<string>(''); | ||
const [submittedWords, setSubmittedWords] = useState<string[]>([]); | ||
|
||
const environmentId = Number(id); | ||
const environment = environments.find((env) => env.id === environmentId); | ||
|
||
useEffect(() => { | ||
// Load submitted words from localStorage when the component mounts | ||
const storedWords = localStorage.getItem(`submittedWords-${environmentId}`); | ||
if (storedWords) { | ||
setSubmittedWords(JSON.parse(storedWords)); | ||
} | ||
}, [environmentId]); | ||
|
||
useEffect(() => { | ||
// Save submitted words to localStorage whenever they change | ||
localStorage.setItem(`submittedWords-${environmentId}`, JSON.stringify(submittedWords)); | ||
}, [submittedWords, environmentId]); | ||
|
||
if (!environment) { | ||
return ( | ||
<div className="container mx-auto px-4 py-8 text-center"> | ||
<h1 className="text-3xl font-bold mb-4">Environment Not Found</h1> | ||
<Button variant="primary" size="medium" onClick={() => router.push('/')}> | ||
Go Back Home | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
const handleSubmit = (e: React.FormEvent) => { | ||
e.preventDefault(); | ||
if (input.trim() !== '' && isValidWord(input, environment.name)) { | ||
setSubmittedWords((prevWords) => [...prevWords, input.trim()]); | ||
setInput(''); | ||
} else { | ||
alert('Please enter a valid word related to the environment.'); | ||
} | ||
}; | ||
|
||
// Simple word validation (this can be extended further) | ||
const isValidWord = (word: string, environmentName: string): boolean => { | ||
const validWords = { | ||
Kitchen: ['knife', 'refrigerator', 'spoon', 'oven'], | ||
Farm: ['tractor', 'cow', 'barn', 'hay'], | ||
Library: ['book', 'shelf', 'lamp', 'table'], | ||
Office: ['computer', 'desk', 'chair', 'printer'], | ||
}; | ||
|
||
const normalizedWord = word.toLowerCase().trim(); | ||
return validWords[environmentName as keyof typeof validWords]?.includes(normalizedWord) ?? false; | ||
}; | ||
|
||
return ( | ||
<div className="container mx-auto px-4 py-8 flex flex-col items-center"> | ||
<h1 className="text-3xl font-bold mb-6">{environment.name}</h1> | ||
<div className="w-full max-w-md"> | ||
<Image | ||
src={environment.image} | ||
alt={`${environment.name} Image`} | ||
width={600} | ||
height={400} | ||
className="w-full h-auto rounded-lg shadow-md" | ||
/> | ||
</div> | ||
<form onSubmit={handleSubmit} className="w-full max-w-md mt-6"> | ||
<label htmlFor="word-input" className="block text-lg font-medium mb-2"> | ||
Type a word related to {environment.name}: | ||
</label> | ||
<input | ||
type="text" | ||
id="word-input" | ||
value={input} | ||
onChange={(e) => setInput(e.target.value)} | ||
className="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary" | ||
placeholder={`e.g., Knife, Refrigerator`} | ||
required | ||
/> | ||
<Button variant="primary" size="medium" type="submit" className="mt-4 w-full"> | ||
Submit | ||
</Button> | ||
</form> | ||
{submittedWords.length > 0 && ( | ||
<div className="w-full max-w-md mt-6"> | ||
<h2 className="text-2xl font-semibold mb-2">Your Words:</h2> | ||
<ul className="list-disc list-inside"> | ||
{submittedWords.map((word, index) => ( | ||
<li key={index} className="text-lg"> | ||
{word} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default EnvironmentPage; |
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,25 @@ | ||
import React from 'react'; | ||
|
||
const InstructionPage: React.FC = () => { | ||
return ( | ||
<div className="container mx-auto px-4 py-8"> | ||
<h1 className="text-3xl font-bold mb-4">How to Use Digital Memory Playground</h1> | ||
<ol className="list-decimal list-inside text-lg"> | ||
<li className="mb-2"> | ||
<strong>Select a Scene:</strong> Choose a scene (Kitchen, Farm, Library, Office) by clicking the "Select" button. | ||
</li> | ||
<li className="mb-2"> | ||
<strong>Engage with Exercises:</strong> Complete the exercises shown for each scene. | ||
</li> | ||
<li className="mb-2"> | ||
<strong>Monitor Your Progress:</strong> Track your progress as you go through the scenes. | ||
</li> | ||
<li> | ||
<strong>Explore Different Scenes:</strong> Try different scenes to experience varied cognitive activities. | ||
</li> | ||
</ol> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InstructionPage; |
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.