Skip to content
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

open pr to cr #33

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<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>
<title>Countries</title>
</head>
<body>
<div id="root"></div>
Expand Down
100 changes: 100 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.7.9",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
2 changes: 2 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import "../src/assets/css/details.css";
import "../src/assets/css/main.css";
import "../src/assets/scss/common.scss";
import Home from "./pages/Home";
import Header from "./components/Header";

function App() {
return (
<>
<Header />
<Home />
</>
);
Expand Down
22 changes: 21 additions & 1 deletion src/assets/scss/_dark-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,29 @@ body {
li {
color: $dark-gray;
}

strong {
color: $white;
}
}

#modal-content {
background-color: $bg-very-dark-blue;
li {
color: $dark-gray;
}

strong {
color: $white;
}

h2 {
color: $white;
}

a {
color: $white;
}
}
}
}
}
37 changes: 31 additions & 6 deletions src/components/Country.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
import React from 'react'
import Modal from "./Modal/Modal";
import { useState } from "react";

const Country = () => {
const Country = ({card}) => {
const { flags, name, population, region, capital } = card;
const [ isOpen, setOpen ] = useState(false)

const openModal = () => {
setOpen(true)
}

const closeModal = () => {
setOpen(false)
}
return (
// TODO: Country component
<div>Country</div>
)
}
<>
<a className="country scale-effect" data-country-name={name.common} onClick={openModal}>
<div className="country-flag">
<img src={flags.png} alt="Belize FLag" />
</div>
<div className="country-info">
<h2 className="country-title">{name.common}</h2>
<ul className="country-brief">
<li><strong>population: </strong>{population.toLocaleString()}</li>
<li><strong>Region: </strong>{region}</li>
<li><strong>capital: </strong>{capital}</li>
</ul>
</div>
</a>
<Modal isOpen={isOpen} Close={closeModal} countryData={card} />
</>
);
};

export default Country
54 changes: 54 additions & 0 deletions src/components/Filter/filter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { useState } from "react"

const Filter = ({ onSearch }) => {
const regions = ["all", "africa", "americas", "asia", "europe", "oceania"];
const [displayDropdown, setDisplayDropdown] = useState(false);

const regionValue = (region) => {
onSearch(region);
setDisplayDropdown(false);
}

const toggleDropdown = () => {
setDisplayDropdown(!displayDropdown);
};

return (
<section className="filters">
<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..."
onChange={(e) => { onSearch(e.target.value) }}
/>
</div>
<div className={`dropdown-wrapper ${displayDropdown ? "open" : ""}`}>
<div
className="dropdown-header flex flex-jc-sb flex-ai-c"
onClick={toggleDropdown}
>
<span>Filter by Region</span>
<i className="fa-regular fa-chevron-down icon"></i>
</div>
<div className="dropdown-body">
<ul>
{regions.map((region) => (
<li
key={region}
onClick={() => regionValue(region)}
data-region={region}
>
{region}
</li>
))}
</ul>
</div>
</div>
</div>
</section>
);
};
export default Filter;
36 changes: 36 additions & 0 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useState, useEffect } from "react";
import { HardCodedStrings } from "./constants";

const Header = () => {
const [toggleDarkMode, setDispalayDarkMode] = useState(false);

const handleDarkModeClick = () => {
setDispalayDarkMode(!toggleDarkMode)
}

useEffect(() => {
document.body.classList.toggle("dark-theme", toggleDarkMode);
}, [toggleDarkMode]);

return (
<header className="header">
<div className="container flex flex-jc-sb flex-ai-c">
<div className="logo">
<a href="/">
<h1>{HardCodedStrings.logoText}</h1>
</a>
</div>
<button
type="button"
aria-label="Theme Switcher Button"
className="theme-toggle flex flex-jc-sb flex-ai-c"
>
<i className="fa-regular fa-moon theme-icon"></i>
<span className="theme-text" onClick={handleDarkModeClick}>{HardCodedStrings.darkModeText}</span>
</button>
</div>
</header>
);
};

export default Header;
Loading