forked from reactplay/react-play
-
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
cbae899
commit d2e5087
Showing
6 changed files
with
324 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// import { Fragment, useState, useEffect } from "react"; | ||
|
||
// import "./modal.css"; | ||
// import close from './close.png' | ||
|
||
// const Modal = ({ showModal, toggle }) => { | ||
// const [currState, setCurrentState] = useState(0); | ||
|
||
|
||
|
||
// useEffect(() => { | ||
// setCurrentState(0); | ||
// }, [showModal]); | ||
|
||
// const buttonHandler = (val) => (e) => { | ||
// if ((currState === 0 && val < 0) || (currState === 3 && val > 0)) return; | ||
// setCurrentState(currState + val); | ||
// }; | ||
|
||
// if (!showModal) return false; | ||
|
||
// return ( | ||
// <Fragment> | ||
|
||
// <div className='memory-game-modal'> | ||
// <img src={close} alt="close" onClick={toggle} className="close-icon" /> | ||
// <div className='content'> | ||
// <h1 className='text'>How to Play!</h1> | ||
// <p>Yo</p> | ||
// <div className='button-section'> | ||
// {currState > 0 ? <button onClick={buttonHandler(-1)}>Prev</button> : <p></p>} | ||
// <button onClick={currState === 3 ? toggle : buttonHandler(1)}> | ||
// {currState === 3 ? "Done" : "Next"} | ||
// </button> | ||
// </div> | ||
// </div> | ||
// </div> | ||
// <div onClick={toggle} className='memory-game-backdrop' /> | ||
// </Fragment> | ||
// ); | ||
// }; | ||
|
||
// export default Modal; | ||
|
||
import { Fragment, useState, useEffect } from "react"; | ||
|
||
// css | ||
import "./modal.css"; | ||
|
||
// assets | ||
|
||
import close from './close.png' | ||
|
||
const Modal = ({ showModal, toggle }) => { | ||
const [currState, setCurrentState] = useState(0); | ||
|
||
const structuringData = [ | ||
{ | ||
info: "Click any of the box to unvail the the hidden image.", | ||
|
||
}, | ||
{ | ||
info: "Now Click another box to unvail another image. if its not the same the both of them will be hidden again.", | ||
|
||
}, | ||
{ | ||
info: "If the both images are matched they will stay visible and you want to uncover other images and also find their pair", | ||
|
||
}, | ||
{ | ||
info: "Lastly images position will be different on every 'reset' button click any you can keep continue memorise the glimpse of the images and find their pair. ", | ||
|
||
}, | ||
]; | ||
|
||
useEffect(() => { | ||
setCurrentState(0); | ||
}, [showModal]); | ||
|
||
const buttonHandler = (val) => (e) => { | ||
if ((currState === 0 && val < 0) || (currState === 3 && val > 0)) return; | ||
setCurrentState(currState + val); | ||
}; | ||
if (!showModal) return false; | ||
return ( | ||
<Fragment> | ||
<div className='memory-game-modal'> | ||
<img src={close} alt="clonse" onClick={toggle} className="close-icon" /> | ||
<div className='content'> | ||
<h1 className='text'>How to Play!</h1> | ||
<p>{structuringData[currState].info}</p> | ||
{/* <img | ||
className='guide-image' | ||
src={structuringData[currState].image} | ||
alt='pic' | ||
/> */} | ||
<div className='button-section'> | ||
{currState > 0 ? <button onClick={buttonHandler(-1)}>Prev</button> : <p></p>} | ||
<button onClick={currState === 3 ? toggle : buttonHandler(1)}> | ||
{currState === 3 ? "Done" : "Next"} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div onClick={toggle} className='memory-game-backdrop' /> | ||
</Fragment> | ||
); | ||
}; | ||
|
||
export default Modal; |
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,194 @@ | ||
.memory-game-backdrop { | ||
position: fixed; | ||
top: 10%; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
z-index: 10; | ||
} | ||
.memory-game-modal { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: #fff; | ||
width: 50vw; | ||
max-width: 800px; | ||
z-index: 11; | ||
border-radius: 10px; | ||
animation: modalApear 0.3s ease-in-out; | ||
} | ||
.memory-game-modal .close-icon { | ||
position: absolute; | ||
right: 1.5rem; | ||
top: 1.5rem; | ||
width: 30px; | ||
padding: 5px; | ||
filter: brightness(0.1); | ||
cursor: pointer; | ||
} | ||
@media screen and (max-width: 768px) { | ||
.memory-game-modal .close-icon { | ||
right: 1rem; | ||
top: 1rem; | ||
width: 30px; | ||
} | ||
} | ||
.memory-game-modal .content { | ||
margin: 0 2rem; | ||
padding: 2rem; | ||
} | ||
.memory-game-modal .content .text { | ||
text-align: center; | ||
font-size: 1.6rem; | ||
font-weight: bold; | ||
} | ||
.memory-game-modal .content p { | ||
margin: 0.6rem 0 1rem 0; | ||
text-align: center; | ||
} | ||
.memory-game-modal .content .guide-image { | ||
display: block; | ||
margin: 0 auto; | ||
max-width: 70%; | ||
height: auto; | ||
} | ||
.memory-game-modal .content .button-section { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 10px 32px; | ||
} | ||
.memory-game-modal .content .button-section button { | ||
padding: 0.5rem 2rem; | ||
font-size: 1rem; | ||
border-radius: 20px; | ||
border: none; | ||
background-color: rgba(81, 91, 212, 1); | ||
outline: none; | ||
color: #fff; | ||
font-weight: bold; | ||
} | ||
.memory-game-modal .content .button-section button:disabled { | ||
background-color: rgba(81, 91, 212, 0.5); | ||
pointer-events: none; | ||
} | ||
@media screen and (max-width: 768px) { | ||
.memory-game-modal .content .button-section { | ||
padding: 0; | ||
margin-top: 10px; | ||
} | ||
} | ||
@keyframes modalApear { | ||
0% { | ||
opacity: 0; | ||
top: 48%; | ||
} | ||
100% { | ||
opacity: 1; | ||
top: 50%; | ||
} | ||
} | ||
@media screen and (max-width: 768px) { | ||
.memory-game-modal { | ||
width: calc(100vw - 20px); | ||
} | ||
} | ||
.memory-game-backdrop { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
z-index: 10; | ||
} | ||
.memory-game-modal { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: #fff; | ||
width: 50vw; | ||
max-width: 800px; | ||
z-index: 11; | ||
border-radius: 10px; | ||
animation: modalApear 0.3s ease-in-out; | ||
} | ||
.memory-game-modal .close-icon { | ||
position: absolute; | ||
right: 1.5rem; | ||
top: 1.5rem; | ||
width: 30px; | ||
padding: 5px; | ||
filter: brightness(0.1); | ||
cursor: pointer; | ||
} | ||
@media screen and (max-width: 768px) { | ||
.memory-game-modal .close-icon { | ||
right: 1rem; | ||
top: 1rem; | ||
width: 30px; | ||
} | ||
} | ||
.memory-game-modal .content { | ||
margin: 0 2rem; | ||
padding: 2rem; | ||
} | ||
.memory-game-modal .content .text { | ||
text-align: center; | ||
font-size: 1.6rem; | ||
font-weight: bold; | ||
} | ||
.memory-game-modal .content p { | ||
margin: 0.6rem 0 1rem 0; | ||
text-align: center; | ||
} | ||
.memory-game-modal .content .guide-image { | ||
display: block; | ||
margin: 0 auto; | ||
max-width: 70%; | ||
height: auto; | ||
} | ||
.memory-game-modal .content .button-section { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 10px 32px; | ||
} | ||
.memory-game-modal .content .button-section button { | ||
padding: 0.5rem 2rem; | ||
font-size: 1rem; | ||
border-radius: 20px; | ||
border: none; | ||
background-color: rgba(81, 91, 212, 1); | ||
outline: none; | ||
color: #fff; | ||
font-weight: bold; | ||
} | ||
.memory-game-modal .content .button-section button:disabled { | ||
background-color: rgba(81, 91, 212, 0.5); | ||
pointer-events: none; | ||
} | ||
@media screen and (max-width: 768px) { | ||
.memory-game-modal .content .button-section { | ||
padding: 0; | ||
margin-top: 10px; | ||
} | ||
} | ||
@keyframes modalApear { | ||
0% { | ||
opacity: 0; | ||
top: 48%; | ||
} | ||
100% { | ||
opacity: 1; | ||
top: 50%; | ||
} | ||
} | ||
@media screen and (max-width: 768px) { | ||
.memory-game-modal { | ||
width: calc(100vw - 20px); | ||
} | ||
} |
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