Skip to content

Commit

Permalink
Merge pull request #10 from Anubhavprogramer/Anubhav
Browse files Browse the repository at this point in the history
added functionality to components
  • Loading branch information
theDeviser authored Oct 5, 2023
2 parents 170ceb0 + 30456d8 commit 5a7590a
Show file tree
Hide file tree
Showing 20 changed files with 17,406 additions and 69 deletions.
90 changes: 34 additions & 56 deletions countries/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,46 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countries | Technojam</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="next_page.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito+Sans&display=swap">

</head>
<body>

<div class="container">

<h2 class="heading">Where in the World?</h2>

<div class="container">
<h2 class="heading">Where in the World?</h2>
<div class="mode-container ">
<img class="night-mode"src="noun-dark-mode-4066359.png" alt="">
<button class="mode">Dark mode</button>
<img class="night-mode moon" src="noun-dark-mode-4066359.png" alt="">
<button class="mode">Dark mode</button>
</div>
</div>
<div class="container-2">
<div class="card2 ">
<div class="search-bar">
<button id="searchButton"><img src="searchbar.png" alt="Search"></button>
<input type="text" id="searchInput" placeholder="search for a country...">
<button id="searchButton" "><img src="searchbar.png" alt="Search"></button>
<input type="text" class="searcharea" id="searchInput" placeholder="search for a country...">
</div>
</div>
<select id="continentSelect">
<option value="Africa">Africa</option>
<option value="Asia">Asia</option>
<option value="Europe">India</option>
<option value="America">North America</option>
<option value="Ocenia">South America</option>
</select>

</div>




<!-- card part -->
<div class="card-container">
<div class="card">
<div class="flag-container">
<img src="germany-flag.png" alt="">
</div>
<div class="country-container">
<h4>Germany</h4>
<span><strong>Population:</strong>999999999</span>
<span><strong>Region:</strong>Europe</span>
<span><strong>Capital:</strong>Berlin</span>
</div>
</div>
<div class="card">
<div class="flag-container">
<img src="germany-flag.png" alt="">
</div>
<div class="country-container">
<h4>Germany</h4>
<span><strong>Population:</strong>999999999</span>
<span><strong>Region:</strong>Europe</span>
<span><strong>Capital:</strong>Berlin</span>
</div>
</div>
<div class="card">
<div class="flag-container">
<img src="germany-flag.png" alt="">
</div>
<div class="country-container">
<h4>Germany</h4>
<span><strong>Population:</strong>999999999</span>
<span><strong>Region:</strong>Europe</span>
<span><strong>Capital:</strong>Berlin</span>
<div class="dropdowncol">
<div class="dropdown">
<p>Filter by region</p>
<button><i class="fas fa-chevron-down"></i></button>
</div>
<div class="drop showdropdown">
<p class="region">Asia</p>
<p class="region">Africa</p>
<p class="region">America</p>
<p class="region">Europe</p>
<p class="region">All</p>
</div>
</div>

</div>
<div class="countries">

</div>

<div class="countrymodle show">

<div class="card">
<div class="flag-container">
<img src="germany-flag.png" alt="">
Expand Down Expand Up @@ -130,11 +101,18 @@ <h4>Germany</h4>
</div>
</div>
</div>



</div>


<!-- card part -->
<div class="card-container">

</div>

<!-- js link -->
<script src="index.js"></script>
<script src="script.js"></script>
</body>
</html>
Empty file removed countries/src/index.js
Empty file.
22 changes: 21 additions & 1 deletion countries/src/next_page.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@
height: 70vh;
}



.flag-container {

width: 500px;
overflow: hidden;
}



.flag-container>img {
width: 100%;
height: 100%;
Expand Down Expand Up @@ -136,7 +141,7 @@
padding-right: 60px;
}

.flag-container {
.flag-container-details-details {
width: 400px;
overflow: hidden;
}
Expand All @@ -157,6 +162,7 @@
@media screen and (max-width:1007px) {

.flag-container {

width: 400px;
overflow: hidden;
}
Expand Down Expand Up @@ -190,7 +196,9 @@
}

@media screen and (max-width:680px) {

.flag-container {

width: 400px;
}

Expand Down Expand Up @@ -220,7 +228,9 @@
}

@media screen and (max-width:430px) {

.flag-container {

width: 300px;
height: 300px;

Expand All @@ -241,7 +251,17 @@
margin-bottom: 20px;
}


.flag-container-details {
width: 95%;
}
}

.show{
display: none;

.flag-container {
width: 95%;
}

}
17 changes: 7 additions & 10 deletions countries/src/next_page.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="next_page.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito+Sans&display=swap">

</head>

<body>
<div class="container">

<h2 class="heading">Where in the World?</h2>

<div class="mode-container ">
<img class="night-mode" src="noun-dark-mode-4066359.png" alt="">
<button class="mode">Dark mode</button>
Expand All @@ -23,7 +18,7 @@ <h2 class="heading">Where in the World?</h2>
<div class="container-2">
<button class="back">Back</button>
</div>
<div class="data-container">
<div class="data-container show">
<div class="flag-container">
<img src="germany-flag.png" alt="">
</div>
Expand All @@ -44,12 +39,14 @@ <h4>Belgium</h4>
</div>
<div class="footer">
<strong>Border Countries: </strong>
<span>France</span>
<span>France</span>
<span>France</span>
<span>France</span>
<span>France</span>
<span>France</span>
</div>
</div>
</div>
</body>

<!-- js link -->
<script src="script.js"></script>
</body>
</html>
125 changes: 125 additions & 0 deletions countries/src/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
document.addEventListener("DOMContentLoaded", () => {
const cardAdder = document.querySelector(".card-container");
const droptoshow = document.querySelector(".drop");
const dropelem = document.querySelector(".dropdown");
const region = document.querySelectorAll(".region");
const search = document.querySelector(".searcharea");
const mode = document.querySelector(".mode");
const searchbar = document.querySelector(".search-bar");
const searcharea = document.querySelector(".searcharea");


async function getcountry() {
const url = await fetch("https://restcountries.com/v3.1/all");
const res = await url.json();
console.log(res);
const countriesToShow = res.slice(0, 6);
countriesToShow.forEach((element) => {
showcountry(element);
});
}

function showcountry(data) {
const country = document.createElement("div");
country.classList.add("country");
country.innerHTML = `
<div class="flag-container">
<img src="${data.flags.png}" alt="">
</div>
<div class="country-container">
<h4 class="countryname">${data.name.common}</h4>
<span><strong>Population:</strong>${data.population}</span>
<span class="regionname"><strong>Region:</strong>${data.region}</span>
<span><strong>Capital:</strong>${data.capital}</span>
</div>`;
cardAdder.appendChild(country); // Append the country element inside the showcountry function
country.addEventListener("click",()=>{
showcountrydetails(data)
})


}

getcountry();

dropelem.addEventListener("click", () => {
droptoshow.classList.toggle("showdropdown");
});
const regionname = document.getElementsByClassName("regionname");
region.forEach((element) => {
element.addEventListener("click", () => {
Array.from(regionname).forEach(elem =>{
if(elem.innerText.includes(element.innerText) || element.innerText == "All")
{
elem.parentElement.parentElement.style.display="grid"
}
else
{
elem.parentElement.parentElement.style.display="none"
}
})
});
});
const countryname = document.getElementsByClassName("countryname");
search.addEventListener("input",()=>{
Array.from(countryname).forEach(elem =>{
if(elem.innerText.toLowerCase().includes(search.value.toLowerCase()))
{
elem.parentElement.parentElement.style.display="grid"
}
else
{
elem.parentElement.parentElement.style.display="none"
}
})
})

mode.addEventListener("click",()=>{
document.body.classList.toggle("light")

})
});

const countrymodle=document.querySelector(".countrymodle")

function showcountrydetails(data){
if (!data || !data.name || !data.name.common) {
console.error("Invalid data format:", data);
return;
}


countrymodle.classList.toggle("show")
countrymodle.innerHTML=`
<div class="container-2">
<button class="back">Back</button>
</div>
<div class="data-container">
<div class="flag-container-details">
<img src="${data.flags.png}" alt="">
</div>
<div class="country-data">
<h4>${data.name.common}</h4>
<div class="data">
<span><strong>Native Name :</strong>${data.name.nativeName.fra.common}</span>
<span><strong>Population :</strong>${data.population}</span>
<span><strong>Region :</strong>${data.region}</span>
<span><strong>Sub-region :</strong>${data.subregion}</span>
<span><strong>Capital :</strong>${data.capital}</span>
<span><strong>Currencies :</strong>${data.currencies.XPF.name}</span>
<span><strong>Languages :</strong>${data.languages.fra}</span>
</div>
<div class="footer">
<strong>Border Countries: </strong>
${Array.isArray(data.borders) && data.borders.length > 0
? data.borders.map((border) => `<span>${border}</span>`).join("")
: "N/A"}
</div>
</div>
</div>
`
const back=countrymodle.querySelector(".back")
back.addEventListener("click",()=>{
countrymodle.classList.toggle("show")
})
}
Loading

0 comments on commit 5a7590a

Please sign in to comment.