-
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.
feat: ensure responsiveness on smaller screens. refactor: use css mod…
…ules. on narrow screens, everything is resized. at a certain breakpoint (super narrow mobile screens), we use two columns of 5 rows to better use the limited page space. even narrower portrait will remove the name of the pokemons entirely. css modules improves maintainability by preventing name clashing when scaling application, and also improves performance (better than using css-in-js alternative, or css libraries). fixes #11. note: there is some 'jumping' in the positioning of the header during loading states. i've hacked together a bunch of media queries to fix this as i don't know how to ensure the size of the main section, or the loadingScreen component outer element with css. i don't want to be generating placeholder Card components unnecessarily as this is not performant, but the <main> section essentially needs to be stretched out
- Loading branch information
1 parent
7dba2e9
commit f049d10
Showing
20 changed files
with
429 additions
and
182 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
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
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,27 @@ | ||
import PropTypes from "prop-types"; | ||
import styles from "../styles/header.module.css"; | ||
|
||
const Header = ({ currentScore, highScore }) => ( | ||
<header className={styles.header}> | ||
<div className={styles.left}> | ||
<h1 className={styles.heading}>Pokémems</h1> | ||
<p className={styles.explanation}> | ||
Earn points by clicking on a Pokemon... but not more than once! | ||
</p> | ||
</div> | ||
|
||
<article className={styles.scoreboard}> | ||
<p className={styles.label}>score:</p> | ||
<p className={styles.score}>{currentScore}</p> | ||
<p className={styles.label}>high score:</p> | ||
<p className={styles.score}>{highScore}</p> | ||
</article> | ||
</header> | ||
); | ||
|
||
Header.propTypes = { | ||
currentScore: PropTypes.number.isRequired, | ||
highScore: PropTypes.number.isRequired, | ||
}; | ||
|
||
export default Header; |
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,11 +1,15 @@ | ||
import masterBall from "../assets/masterball.png"; | ||
import "../styles/loadingScreen.css"; | ||
import styles from "../styles/loadingScreen.module.css"; | ||
|
||
export default function LoadingScreen() { | ||
return ( | ||
<div className="loadingScreen"> | ||
<img className="masterball" src={masterBall} alt="spinning master ball" /> | ||
<p>Catching them all...</p> | ||
</div> | ||
<article className={styles.loadingScreen}> | ||
<img | ||
className={styles.masterball} | ||
src={masterBall} | ||
alt="spinning master ball" | ||
/> | ||
<p className={styles.text}>Catching them all...</p> | ||
</article> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
.appBody { | ||
background-color: var(--primary-colour); | ||
height: 100dvh; | ||
} | ||
|
||
.inner { | ||
max-width: 92rem; | ||
height: 95%; | ||
padding: 48px; | ||
margin: 0 auto; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
gap: 4%; | ||
} | ||
|
||
/* MEDIA QUERIES */ | ||
@media (max-width: 999px) { | ||
.inner { | ||
max-width: 95dvw; | ||
padding: 4px; | ||
} | ||
} | ||
|
||
@media (max-width: 599px) { | ||
.inner { | ||
max-width: 100%; | ||
padding: 20px 12px; | ||
gap: 2%; | ||
} | ||
} | ||
|
||
@media (max-width: 399px) { | ||
.inner { | ||
padding: 24px 8px; | ||
} | ||
} | ||
|
||
/* small mobile screens, landscape */ | ||
@media (max-height: 419px) { | ||
.inner { | ||
max-width: 100%; | ||
padding: 16px 8px 0 8px; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,103 @@ | ||
.card { | ||
min-width: 100%; | ||
height: auto; | ||
background-color: var(--primary-colour-lighter); | ||
border-radius: 16px; | ||
padding: 24px 12px; | ||
box-shadow: 3px 2px 5px 0px rgba(0, 0, 0, 0.25); | ||
|
||
/* flexbox */ | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 24px; | ||
} | ||
|
||
.pokemonName { | ||
color: white; | ||
text-transform: uppercase; | ||
font-size: .8rem; | ||
letter-spacing: .1rem; | ||
} | ||
|
||
.imageContainer { | ||
width: 90%; | ||
height: auto; | ||
background-color: white; | ||
display: grid; | ||
place-items: center; | ||
} | ||
|
||
.image { | ||
width: 100%; | ||
} | ||
|
||
.card:not([disabled]):hover { | ||
box-shadow: 0 0 44px 8px var(--secondary-colour); | ||
transform: scale(1.1); | ||
} | ||
|
||
.card:active { | ||
transform: scale(1); | ||
} | ||
|
||
/* MEDIA QUERIES */ | ||
@media (max-width: 999px) { | ||
.card { | ||
padding: 16px 4px; | ||
gap: 16px; | ||
} | ||
|
||
.pokemonName { | ||
font-size: .5rem; | ||
} | ||
} | ||
|
||
@media (max-width: 599px) { | ||
.card { | ||
max-height: 20dvh; | ||
padding: 8px; | ||
gap: 12px; | ||
} | ||
|
||
.imageContainer { | ||
width: 100%; | ||
} | ||
|
||
.image { | ||
width: auto; | ||
} | ||
} | ||
|
||
@media (max-width: 389px) { | ||
.imageContainer { | ||
width: 100%; | ||
border-radius: 12px; | ||
} | ||
|
||
.image { | ||
width: auto; | ||
} | ||
|
||
.pokemonName { | ||
display: none; | ||
} | ||
} | ||
|
||
/* small mobile screens, landscape */ | ||
@media (max-height: 419px) { | ||
.card { | ||
max-height: fit-content; | ||
padding: 8px; | ||
gap: 8px; | ||
} | ||
|
||
.imageContainer { | ||
width: 100%; | ||
border-radius: 12px; | ||
} | ||
|
||
.image { | ||
width: auto; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.