-
Notifications
You must be signed in to change notification settings - Fork 22
Adi countries react api #21
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
base: main
Are you sure you want to change the base?
Changes from all commits
a82c0cf
1781bab
66a48db
e0811c3
5cbcd00
c527b2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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> |
| 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}> | ||
|
|
||
| <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> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
| ) | ||
| } | ||
| 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> | ||
| ) | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
| 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; | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
| ) | ||
|
|
||
|
|
||
| } | ||
| 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> | ||
|
|
||
| ) | ||
| } |
| 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; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
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.
Use destruction in here