-
Notifications
You must be signed in to change notification settings - Fork 7
Countries list complete #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
engineblog
wants to merge
16
commits into
codu-code:master
Choose a base branch
from
engineblog:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8456e26
reverted changes
8ac1c45
added axios and completed API utils
875cb31
pull and fix merge conflicts
bbac9fc
Added country list items
b7f77f7
Merge branch 'master' of https://github.com/codu-code/frontend-mentor…
c38a2c9
adjusted CSS and implemented grid layout. images are nearly styled co…
7022f13
another save point for image styling
38b1afd
another save point for image styling
4f9e8f3
another save point for image styling
6fac879
another save point for image styling
b29e731
Getting aspect ratio asynchronously now works. Moving on to styling …
260ba8b
now able to apply different styles, and eliminate empty space in the …
80cc754
centered grid in viewport
75a8a92
Merge branch 'countries-list'
7a08f27
fix merge conflict
selkasse 1deef74
clean up per PR comments
selkasse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 @@ | ||
| import React from "react"; | ||
|
|
||
| import styles from "./CardBottom.module.scss"; | ||
|
|
||
| const CardBottom = props => ( | ||
| <div className={styles.CardBottom}> | ||
| <h1>{props.name}</h1> | ||
| <ul> | ||
| <li key={props.alpha3Code}> | ||
| <strong>Population: </strong>{props.population}<br /> | ||
| </li> | ||
| <li key={props.alpha3Code}> | ||
| <strong>Region: </strong>{props.region}<br /> | ||
| </li> | ||
| <li key={props.alpha3Code}> | ||
| <strong>Capital: </strong>{props.capital}<br /> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| ) | ||
|
|
||
|
|
||
| export default CardBottom; |
This file contains hidden or 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,9 @@ | ||
| .CardBottom { | ||
| padding-top: 3em; | ||
| padding-bottom: 4em; | ||
| padding-left: 2em; | ||
| } | ||
|
|
||
| ul { | ||
| list-style-type: none; | ||
| } |
This file contains hidden or 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 hidden or 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,28 +1,42 @@ | ||
| @import '../../global.styles.scss'; | ||
|
|
||
| .Country { | ||
| margin: auto; | ||
| width: 80%; | ||
| padding-bottom: 20px; | ||
| display: grid; | ||
| border-radius: $border-radius; | ||
| box-shadow: $element-box-shadow-light; | ||
| overflow: hidden; | ||
| cursor: pointer; | ||
| img { | ||
| width: 100%; | ||
| } | ||
| h1 { | ||
| font-size: 1.1rem; | ||
| } | ||
| ul { | ||
| list-style-type: none; | ||
| margin-top: 0.5rem; | ||
| } | ||
| li { | ||
| font-size: 0.9rem; | ||
| display: flex; | ||
| } | ||
| strong { | ||
| font-weight: $medium; | ||
| } | ||
| } | ||
| h1 { | ||
| margin-left: 20px; | ||
| } | ||
| ul { | ||
| list-style-type: none; | ||
| } | ||
| li { | ||
| .infoBlock { | ||
| padding: 1rem 1.5rem 1.5rem 1.5rem; | ||
| display: flex; | ||
| margin-left: 20px; | ||
| flex-direction: column; | ||
| justify-content: space-around; | ||
| } | ||
| .light { | ||
| background-color: $white; | ||
| color: $very-dark-blue-text; | ||
| } | ||
|
|
||
| .dark { | ||
| color: $white; | ||
|
|
||
| background-color: $dark-blue; | ||
| color: $white; | ||
| box-shadow: $element-box-shadow-dark; | ||
| } |
This file contains hidden or 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,9 +1,66 @@ | ||
| import React from "react"; | ||
| import React, { useState, useEffect } from 'react'; | ||
| import axios from 'axios'; | ||
|
|
||
| import styles from "./Flag.module.scss"; | ||
|
|
||
| const Flag = props => ( | ||
| <img className={styles.Flag} src={props.flag} alt={props.name}/> | ||
| ) | ||
|
|
||
| function idealAspectRatio({width, height}) { | ||
| const aspectRatio = width / height; | ||
| if (aspectRatio > 1.5 && aspectRatio <= 1.8){ | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| function getMeta(url){ | ||
| return new Promise((resolve, reject) => { | ||
| let img = new Image(); | ||
| img.onload = () => resolve(img); | ||
| img.onerror = reject; | ||
| img.src = url; | ||
| }); | ||
| } | ||
|
|
||
| async function getImage(url){ | ||
| let img = await getMeta(url); | ||
| const dimensions = { | ||
| width: img.width, | ||
| height: img.height | ||
| } | ||
| return dimensions; | ||
| } | ||
|
|
||
| function Flag (props) { | ||
|
|
||
| const altText = `${props.name} flag`; | ||
| const [ratio, setRatio] = useState([]); | ||
|
|
||
| useEffect(() => { | ||
| getImage(props.flag).then(res => { | ||
| const response = res; | ||
| setRatio(response); | ||
| }); | ||
| // stop the component from re-rendering since props.flag does not change | ||
| },[props.flag]); | ||
|
|
||
|
|
||
| const ideal = (idealAspectRatio(ratio)); | ||
| const classNameText = (ideal ? 'standard' : 'standard'); | ||
| console.log(classNameText); | ||
|
|
||
|
|
||
|
|
||
| return ( | ||
|
|
||
| <img | ||
| className={ideal ? styles.standard : styles.standard} | ||
| src={props.flag} | ||
| alt={altText} | ||
| /> | ||
| ) | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| export default Flag; |
This file contains hidden or 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,5 +1,10 @@ | ||
| @import '../../global.styles.scss'; | ||
|
|
||
| .Flag { | ||
| .standard { | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
|
|
||
| .resize { | ||
| object-fit: cover; | ||
| } |
This file contains hidden or 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"; | ||
|
|
||
| import Country from "../Country/Country"; | ||
|
|
||
|
|
||
| import styles from "./Grid.module.scss"; | ||
|
|
||
| const Grid = props => ( | ||
| <div className={styles.Grid}> | ||
| {props.countries.map(country => ( | ||
| <Country | ||
| key={country.alpha3Code} | ||
| theme={props.theme} | ||
| flag={country.flag} | ||
| name={country.name} | ||
| population={country.population} | ||
| region={country.region} | ||
| capital={country.capital} | ||
| /> | ||
| ))} | ||
| </div> | ||
| ) | ||
|
|
||
|
|
||
| export default Grid; |
This file contains hidden or 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,8 @@ | ||
| @import '../../global.styles.scss'; | ||
|
|
||
| .Grid { | ||
| display: grid; | ||
| grid-gap: 3em; | ||
| grid-template-columns: repeat(4, 300px); | ||
| grid-auto-rows: 400px; | ||
| } | ||
This file contains hidden or 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,20 +1,25 @@ | ||
| /* css reset */ | ||
| * { | ||
| box-sizing: border-box; | ||
| padding: 0; | ||
| margin: 0; | ||
| max-width: 100%; | ||
| box-sizing: border-box; | ||
| padding: 0; | ||
| margin: 0; | ||
| max-width: 100%; | ||
| } | ||
|
|
||
| body { | ||
| margin: 0; | ||
| /* Global Font Family Set to Project Specified */ | ||
| font-family: 'Nunito Sans', sans-serif; | ||
| -webkit-font-smoothing: antialiased; | ||
| -moz-osx-font-smoothing: grayscale; | ||
| margin: 0; | ||
| /* Global Font Family Set to Project Specified */ | ||
| font-family: 'Nunito Sans', sans-serif; | ||
| -webkit-font-smoothing: antialiased; | ||
| -moz-osx-font-smoothing: grayscale; | ||
| box-sizing: border-box; | ||
|
|
||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } | ||
|
|
||
| code { | ||
| font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
| monospace; | ||
| font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
| monospace; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be responsive, please check comments on global.styles.scss