Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CountriesData.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,6 @@
"region": "Europe",
"capital": "Luxembourg"
}
]
]


30 changes: 5 additions & 25 deletions css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,6 @@ button {
font-size: 16px;
}

.loader {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #fafafa;
display: flex;
justify-content: center;
align-items: center;
z-index: 9;
transition: 0.2s linear, opacity 0.2s linear, visibility 0.3s linear;
}

.loader.close {
opacity: 0;
visibility: hidden;
}

.loader .spinner .icon {
font-size: 80px;
color: #111517;
}

.scroll-top {
position: fixed;
bottom: 20px;
Expand Down Expand Up @@ -192,7 +168,6 @@ button {
.header .logo h1 {
font-size: 20px;
}

@media (max-width: 400px) {
.header .logo h1 {
font-size: 16px;
Expand Down Expand Up @@ -307,3 +282,8 @@ body.dark-theme .country-info li {
body.dark-theme .country-info strong {
color: white;
}

.body {
background-color: white;
}

47 changes: 41 additions & 6 deletions css/details.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
html {
width: 100%;
height: 100%;
margin: 0;
}
body {
font-size: 16px;
}
Expand Down Expand Up @@ -36,15 +41,17 @@ body {

@media (min-width: 64em) {
.country-flag,
.country-info {
.country-info
.dark-country-info {
flex: 1 0 calc(50% - 30px);
}
}

.country-flag {
flex-shrink: 0;
width: 450px;
width: 600px;
max-width: 450px;
height: 300px;
max-height: 350px;
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
overflow: hidden;
Expand All @@ -65,10 +72,6 @@ body {
object-fit: cover;
}

.country-info {
padding: 40px 0;
}

.country-info h1 {
color: #111517;
margin-bottom: 30px;
Expand Down Expand Up @@ -133,3 +136,35 @@ body {
gap: 8px;
flex-wrap: wrap;
}

.mainCountryFlag {
width: 50%;
height: 70%;
}


.country-container , .main{
display: flex;
justify-content: center;
align-items: center;
height: 80%;
}
.country-info {
padding: 40px 0;
padding-left: 10%;
width: 300px;
}
.country-name {
font-weight: bold;
font-size: 5vh;
}
.country-name, .country-region, .country-capital, .country-population {
padding-top: 20px;
font-weight: bold;
}

.dark-country-info {
padding: 40px 0;
padding-left: 10%;
width: 300px;
}
33 changes: 26 additions & 7 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.filters {
margin: 40px 0 50px 0;
padding: 40px 0 50px 0;
}

@media (min-width: 40em) {
.filters {
margin: 50px 0 60px 0;
padding: 50px 0 60px 0;
}
}

Expand Down Expand Up @@ -109,7 +109,6 @@
cursor: pointer;
z-index: 2;
}

.filters .dropdown-header .icon {
font-size: 13px;
transition: transform 0.2s linear;
Expand Down Expand Up @@ -190,9 +189,12 @@
}

.countries-grid .country-flag {
height: 200px;
height: 50%;
width: 100%;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}

@media (max-width: 400px) {
Expand All @@ -205,21 +207,38 @@
display: block;
width: 100%;
max-width: 100%;
height: 100%;
object-fit: cover;
}

.countries-grid .country-info {
position: relative;
padding: 30px 25px;
background-color: white;
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will want to save your colors into a css variables

}
.dark-country-info {
background-color: #2b3945;
color: white;
padding: 30px 25px;
}

.countries-grid .country-title {

.countries-grid {
margin-bottom: 20px;
}

.countries-grid .country-brief li {
.country-title {
margin-bottom: 20px;
background-color: white;
}
.dark-country-title {
margin-bottom: 20px;
background-color: #2b3945;
}

.countries-grid .country-brief li{
font-size: 16px;
text-transform: capitalize;
margin-bottom: 15px;
}

138 changes: 64 additions & 74 deletions details.html
Original file line number Diff line number Diff line change
@@ -1,80 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="description"
content="This is a simple project to display countries of the world with the ability to search for the country you want, be side the ability to show countries by continent."
/>
<meta name="author" content="Mohamed Aridah" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;600;800&display=swap"
rel="stylesheet"
/>
<!-- Fontawesome Library -->
<link
rel="stylesheet"
href="https://site-assets.fontawesome.com/releases/v6.0.0/css/all.css"
/>
<!-- Shared CSS Styles File -->
<link rel="stylesheet" href="./css/common.css" />
<!-- Page Custom CSS File -->
<link rel="stylesheet" href="./css/details.css" />
<title>Details Page</title>
</head>
<body>
<!-- Loader -->
<div class="loader">
<div class="spinner">
<i class="fa-regular fa-circle-notch fa-spin icon"></i>

<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description"
content="This is a simple project to display countries of the world with the ability to search for the country you want, be side the ability to show countries by continent." />
<meta name="author" content="Mohamed Aridah" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;600;800&display=swap" rel="stylesheet" />
<!-- Fontawesome Library -->
<link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.0.0/css/all.css" />
<!-- Shared CSS Styles File -->
<link rel="stylesheet" href="./css/common.css" />
<!-- Page Custom CSS File -->
<link rel="stylesheet" href="./css/details.css" />
<title>Details Page</title>
</head>

<body class="body">
<!-- Scroll Top -->
<button type="button" aria-label="Scroll Top Button" class="button scroll-top flex flex-ai-c flex-jc-c scale-effect">
<i class="fa-regular fa-chevron-up icon"></i>
</button>
<!-- Header -->
<header class="header">
<div class="container flex flex-jc-sb flex-ai-c">
<div class="logo">
<a href="index.html">
<h1>Where in the world?</h1>
</a>
</div>
<button onclick="makeDarkModePage()" type="button" aria-label="Theme Switcher Button" class="theme-toggle flex flex-jc-sb flex-ai-c">
<i class="fa-regular fa-moon theme-icon"></i>
<span class="theme-text">Dark Mode</span>
</button>
</div>
</header>
<!-- Back Button -->
<div class="back-button">
<div class="container">
<a href="index.html" class="btn btn-back btn-with-icon">
<i class="fa-regular fa-arrow-left icon"></i>
back
</a>
</div>
<!-- Scroll Top -->
<button
type="button"
aria-label="Scroll Top Button"
class="button scroll-top flex flex-ai-c flex-jc-c scale-effect"
>
<i class="fa-regular fa-chevron-up icon"></i>
</button>
<!-- Header -->
<header class="header">
<div class="container flex flex-jc-sb flex-ai-c">
<div class="logo">
<a href="index.html">
<h1>Where in the world?</h1>
</a>
</div>
<main class="main">
<div class="country-container">
<section class="country-details">
<div class="main-country-flag"></div>
<div class="country-info">
<div class="country-name"></div>
<div class="country-population"></div>
<div class="country-region"></div>
<div class="country-capital"></div>
</div>
<button
type="button"
aria-label="Theme Switcher Button"
class="theme-toggle flex flex-jc-sb flex-ai-c"
>
<i class="fa-regular fa-moon theme-icon"></i>
<span class="theme-text">Dark Mode</span>
</button>
</div>
</header>
<!-- Back Button -->
<div class="back-button">
<div class="container">
<a href="index.html" class="btn btn-back btn-with-icon">
<i class="fa-regular fa-arrow-left icon"></i>
back
</a>
</div>
</section>
</div>
<main class="main">
<div class="container">
<section class="country-details"></section>
</div>
</main>
<script src="./js/common.js"></script>
<script src="./js/details.js"></script>
</body>
</html>
</main>
<!-- <script src="./js/common.js"></script> -->
<script src="details.js"></script>
<script src="index.js"></script>
</body>

</html>
18 changes: 18 additions & 0 deletions details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const getDetailsOfCountry = () => {
document.addEventListener("DOMContentLoaded", () => {
const countryDetails = JSON.parse(localStorage.getItem("countryDetails"));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concepts should be extracted into a service so you wont repeat your logic again and again

if (countryDetails) {
console.log("Country Details on details.html:", countryDetails);
document.querySelector(".main-country-flag").innerHTML = `<img class="country-flag" src="${countryDetails.flag}" alt="${countryDetails.name} flag" />`;
document.querySelector(".country-name").textContent = `${countryDetails.name}`;
document.querySelector(".country-population").textContent = `Population: ${countryDetails.population}`;
document.querySelector(".country-region").textContent = `Region: ${countryDetails.region}`;
document.querySelector(".country-capital").textContent = `Capital: ${countryDetails.capital}`;
} else {
console.error("No country details found in localStorage.");
}
});

}
getDetailsOfCountry()
Loading