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
41 changes: 30 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<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/main.css" />

<title>Countries Info</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>

</html>
1 change: 1 addition & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "../src/assets/css/common.css";
import "../src/assets/css/details.css";
import "../src/assets/css/main.css";
import "../src/assets/scss/common.scss";

import Home from "./pages/Home";

function App() {
Expand Down
32 changes: 27 additions & 5 deletions src/components/Country.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
import React from 'react'

const Country = () => {
export const Country = ({ countryData ,onClick }) => {
return (
// TODO: Country component
<div>Country</div>
<div className='country' onClick={onClick}>
Copy link
Member

Choose a reason for hiding this comment

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

Use destruction in here


<img src={countryData.flag} className='country-flag'></img>

<div className='country-info'>
<h2 className='country-title'>{countryData.countryName}</h2>
<ul className='country-brief'>

<li>
<strong>Population: </strong>
<span className='country-population'>{countryData.population}</span>
</li>
Copy link
Member

Choose a reason for hiding this comment

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

Style via css and not via html tags


<li>
<strong>region: </strong>
<span className='country-region'>{countryData.region}</span>
</li>

<li>
<strong>capital: </strong>
<span className='country-capital'>{countryData.capital}</span>
</li>

</ul>
</div>
</div>
)
}

export default Country
29 changes: 29 additions & 0 deletions src/components/Filters.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";

export const Filters = () => {
return (

<div className="container">
<div className="search-wrapper">
<i className="fa-regular fa-magnifying-glass search-icon"></i>
<input type="text" className="search-input" placeholder="Search for a country..." />
</div>
<div className="dropdown-wrapper">
<div className="dropdown-header flex flex-jc-sb flex-ai-c">
<span>Filter by Region</span>
<i className="fa-regular fa-chevron-down icon"></i>
</div>
<div className="dropdown-body">
<ul>
<li data-region="all">All</li>
<li data-region="africa">Africa</li>
Copy link
Member

Choose a reason for hiding this comment

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

Consider change this hardcoded tags into a map function

<li data-region="america">America</li>
<li data-region="asia">Asia</li>
<li data-region="europe">Europe</li>
<li data-region="oceania">Oceania</li>
</ul>
</div>
</div>
</div>
)
}
19 changes: 19 additions & 0 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { ThemeToggle } from "./ThemeToggle";

export const Header = () => {
return (
<div className="container flex flex-jc-sb flex-ai-c">
<div className="logo">
<a href="Home.jsx">
<h1>Where in the world?</h1>
</a>
</div>
<ThemeToggle></ThemeToggle>
</div>
)
}




33 changes: 33 additions & 0 deletions src/components/Modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import "./modal.css";



export const Modal = ({ countryData, onClose }) => {
if (!countryData) return null;

Copy link
Member

Choose a reason for hiding this comment

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

Why would a component return null? Wouldn't it be better to return fallback jsx?

const { countryName, flag, region, population, capital } = countryData;

return (
<div className="modal-overlay" onClick={onClose}>
<div className="modal-content" onClick={(e) => e.stopPropagation()}>
{/* <button class="close-button" onclick="closeModal()">X</button> */}
<div className="country-flag">
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment

<img src={flag} alt={`${countryName} flag`} />
</div>
<div className="country-info">
<h1>{countryName}</h1>
<ul>
<li><strong>Population: </strong>{population}</li>
<li><strong>Region: </strong>{region}</li>
Copy link
Member

Choose a reason for hiding this comment

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

Same here do not add style like this - use css instead

<li><strong>Capital: </strong>{capital}</li>

</ul>
</div>

</div>
</div>
)


}
26 changes: 26 additions & 0 deletions src/components/ThemeToggle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import { useState } from "react";


export const ThemeToggle = () => {
const [isDarkMode, setIsDarkMode] = useState(false);

const toggleTheme = () => {
setIsDarkMode(!isDarkMode);
document.body.classList.toggle("dark-theme", isDarkMode);
};

return (
<button
type="button"
aria-label="Theme Switcher Button"
className="theme-toggle flex flex-jc-sb flex-ai-c"
onClick={toggleTheme}>

<i className={`fa-${isDarkMode ? "solid" : "regular"} fa-moon theme-icon`}></i>
<span className="theme-text">{isDarkMode ? "Light Mode" : "Dark Mode"}</span>

</button>

)
}
115 changes: 115 additions & 0 deletions src/components/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why z-index to high?


.modal-content {
background-color: #fff;
border-radius: 10px;
padding: 20px 30px;
width: 90%;
height: 90vh;
max-width: 500px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
animation: fadeIn 0.3s ease-out;
}

.country-flag img {
max-width: 100%;
height: 250px;
border-radius: 5px;
margin-right: 15px;
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.813);

}

.country-flag {
display: flex;
align-items: center;
justify-content: center;

}

.country-info h1 {
font-size: 30px;
margin-top: -15px;
color: #333;
margin-bottom: 30px;
Copy link
Member

Choose a reason for hiding this comment

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

Save colors inside variables

text-align: center;

}

.country-info ul {
list-style: none;
padding: 0;
}

.country-info li {
margin: 8px 0;
font-size: 16px;
color: #555;
}

.country-info li strong {
color: #333;
}

.close-button {
position: absolute;
top: 15px;
right: 15px;
background-color: transparent;
border: none;
font-size: 20px;
cursor: pointer;
color: #999;
transition: color 0.3s ease;
}

.close-button:hover {
color: #333;
}

/* אנימציות */
@keyframes fadeIn {
Copy link
Member

Choose a reason for hiding this comment

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

Never add comments in Hebrew. Or any comment on simple css line

from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}




/* design for dark mode */


.dark-theme .modal-overlay {
background-color: #5757577d;
}

.dark-theme .modal-content {
background-color: #202c37;
color: #f5f5f5;
border: 1px solid #444;
}

.dark-theme .close-button {
color: #f5f5f5;
}

.dark-theme .close-button:hover {
color: #ddd;
}
Loading