-
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
caae869
commit e70e6ae
Showing
13 changed files
with
212 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body{ | ||
background-color: rgb(82, 77, 77); | ||
} |
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,38 +1,14 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
#header-div{ | ||
background-color: rgb(28, 27, 27); | ||
padding: 20px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
#heading-title{ | ||
color: aliceblue; | ||
font-size: 30px; | ||
margin-left: 6%; | ||
display: inline-block; | ||
} |
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 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,54 @@ | ||
.card { | ||
display: inline-block; | ||
border: 1px solid #ccc; | ||
border-radius: 8px; | ||
padding: 16px; | ||
text-align: center; | ||
width: 600px; | ||
height: 380px; | ||
background-color: rgb(40, 38, 38); | ||
margin : 10px; | ||
border-color: rgba(0, 0, 0, 0); | ||
} | ||
|
||
.card:hover{ | ||
box-shadow: 10px 10px 50px black; | ||
} | ||
|
||
.card-img { | ||
margin-top: 20px; | ||
width: 450px; | ||
height: 250px; | ||
} | ||
|
||
.card-title { | ||
margin-top: 16px; | ||
font-size: 1.5em; | ||
margin-bottom: 10px; | ||
} | ||
|
||
|
||
.cardFrame{ | ||
display: inline-block; | ||
margin-left: 5%; | ||
} | ||
|
||
.card-title{ | ||
color: aquamarine; | ||
font-size: 25px; | ||
font-family:'Times New Roman', Times, serif; | ||
} | ||
|
||
#btnDelete{ | ||
width: 450px; | ||
font-size: 20px; | ||
background-color: red; | ||
color: yellow; | ||
padding: 10px; | ||
font-weight: bold; | ||
border-radius: 20px; | ||
} | ||
|
||
#btnDelete:hover{ | ||
box-shadow: 5px 5px 1000px 20px red; | ||
} |
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,23 @@ | ||
import React from 'react'; | ||
import './Card.css'; | ||
|
||
const Card = ({ flag, countryName,onRemoveCountry}) => { | ||
|
||
const deleteHandler=(name)=>{ | ||
onRemoveCountry(name); | ||
} | ||
|
||
return ( | ||
<div class="cardFrame"> | ||
<div class="card"> | ||
<img src={flag} alt="Country" class="card-img" /> | ||
<h2 className="card-title">{countryName}</h2> | ||
<button id='btnDelete' onClick={()=>{ | ||
deleteHandler(countryName) | ||
}}>Delete</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Card; |
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,73 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import Card from './Card'; | ||
import Search from './Search'; | ||
|
||
const Countries = () => { | ||
const [isLoading, setLoading] = useState(true); | ||
const [error, setError] = useState(null); | ||
const [countries, setCountries] = useState([]); | ||
const [filterCountries, setFilterCountries] = useState(countries); | ||
|
||
const url = "https://restcountries.com/v3.1/all"; | ||
|
||
const FetchData = async (url) => { | ||
setLoading(true); | ||
try { | ||
const response = await fetch(url); | ||
const data = await response.json(); | ||
setCountries(data); | ||
setFilterCountries(data); | ||
setLoading(false); | ||
setError(null); | ||
console.log(data); | ||
} catch (err) { | ||
setError(err.message); | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
FetchData(url); | ||
}, []); | ||
|
||
const loadingMessage = <h2>Data is loading...</h2>; | ||
const errorMessage = <h2>{error}</h2>; | ||
|
||
const removeHandler=(name)=>{ | ||
const filter = filterCountries.filter((country)=> country.name.common !== name); | ||
setFilterCountries(filter); | ||
} | ||
|
||
const searchHandler = (searchData) =>{ | ||
let value = searchData.toLowerCase(); | ||
const newCountries = countries.filter((country)=>{ | ||
const countryName = country.name.common.toLowerCase(); | ||
return countryName.startsWith(value); | ||
}); | ||
setFilterCountries(newCountries) | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div id="header-div"> | ||
<h1 id="heading-title">Where is your Country?</h1> | ||
<Search onSearch={searchHandler}/> | ||
</div> | ||
<div> | ||
{isLoading && loadingMessage} | ||
{error && errorMessage} | ||
{filterCountries.map((countriesData, index) => ( | ||
<Card | ||
key={index} | ||
flag={countriesData.flags.png} | ||
countryName={countriesData.name.common} | ||
onRemoveCountry={removeHandler} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
|
||
); | ||
}; | ||
|
||
export default Countries; |
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,21 @@ | ||
|
||
|
||
#searchDiv{ | ||
display: inline-block; | ||
margin-left: 40%; | ||
} | ||
|
||
#searchBox{ | ||
font-size: 20px; | ||
background-color: rgba(126, 125, 125, 0.364); | ||
width: 370px; | ||
color: rgb(197, 195, 192); | ||
border-radius: 20px; | ||
border-color: antiquewhite; | ||
padding: 3px; | ||
margin-top: 10px; | ||
} | ||
|
||
#search-title{ | ||
color: antiquewhite; | ||
} |
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,18 @@ | ||
import React from 'react' | ||
import './Search.css'; | ||
|
||
const Search = ({onSearch}) => { | ||
|
||
const searchHandler = (e) =>{ | ||
onSearch(e.target.value); | ||
} | ||
|
||
return ( | ||
<div id="searchDiv"> | ||
<h1 id='search-title'>Search Country as Name : </h1> | ||
<input type='text' id="searchBox" onChange={searchHandler} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Search |
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 was deleted.
Oops, something went wrong.