-
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
Showing
4 changed files
with
99 additions
and
31 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
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
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,41 +1,67 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import Display from './display'; | ||
import Question from './question'; | ||
|
||
|
||
// testing the components - it displays the first component for 5 seconds and then shows the second component | ||
|
||
const images = [ | ||
'large_black_triangle.png', | ||
'large_green_triangle.png', | ||
'large_red_triangle.png', | ||
'large_grey_triangle.png', | ||
'small_blue_triangle.png', | ||
'small_orange_triangle.png', | ||
'small_purple_triangle.png' | ||
], | ||
dimension = 4, | ||
display = document.getElementById('display'), | ||
question = document.getElementById('question'); | ||
'large_black_triangle.png', // months: 0, 7 | ||
'large_green_triangle.png', // months: 1, 8 | ||
'large_red_triangle.png', // months: 2, 9 | ||
'large_grey_triangle.png', // months: 3, 10 | ||
'small_blue_triangle.png', // months: 4, 11 | ||
'small_orange_triangle.png', // month: 5 | ||
'small_purple_triangle.png' // month: 6 | ||
]; | ||
const dimension = 4; | ||
const display = document.getElementById('display'); | ||
const question = document.getElementById('question'); | ||
|
||
const imageSetCombined = [...images, ...images]; // extend out the image set so we have enough to cover 12 months | ||
const currentMonth = new Date().getMonth(); | ||
const currentImageIndex = images.findIndex(img => img === imageSetCombined[currentMonth]); | ||
|
||
// handler everytime the user clicks on a box in the second component | ||
let handleQSelect = (data) => { | ||
console.log(data); | ||
} | ||
}; | ||
|
||
// handler for when the second component stops displaying | ||
let handleQComplete = (data) => { | ||
console.log(data); | ||
} | ||
}; | ||
|
||
// handler for when the first component that displays the grid is done displaying | ||
let handleDComplete = (data) => { | ||
console.log(data); | ||
ReactDOM.render(<Question showLabels={true} data={data} onComplete={handleQComplete} onSelect={handleQSelect}/>, question); | ||
} | ||
ReactDOM.render( | ||
<Question | ||
data={data} | ||
onComplete={handleQComplete} | ||
onSelect={handleQSelect} | ||
showLabels | ||
/>, | ||
question | ||
); | ||
}; | ||
|
||
ReactDOM.render(<Display showLabels={false} dimension={dimension} images={images} onComplete={handleDComplete}/>, display); | ||
ReactDOM.render( | ||
<Display | ||
currentImageIndex={currentImageIndex} | ||
dimension={dimension} | ||
images={images} | ||
onComplete={handleDComplete} | ||
showLabels={false} | ||
/>, | ||
display | ||
); | ||
|
||
// stop displaying the first component after 5 seconds | ||
setTimeout(() => { ReactDOM.unmountComponentAtNode(display) }, 5000); | ||
setTimeout( | ||
() => { | ||
ReactDOM.unmountComponentAtNode(display); | ||
}, | ||
5000 | ||
); |