Skip to content

Conversation

@OfekSagiv
Copy link

No description provided.

@Tamir198 Tamir198 self-requested a review December 27, 2024 15:31
Copy link
Member

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

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

Generally do not comment out unused code- remove it

Do not add comments that explain variable and function, the name should explain what they do.

Do not ad Hebrew comments ( I saw that you did it a lot inside your css file)

Save your css colors inside variables

Other than that I left you comments regarding other stuff as well

"no-unused-vars": [
"warn",
{ "varsIgnorePattern": "^_" } // מתעלם ממשתנים שמתחילים ב-_.
],
Copy link
Member

Choose a reason for hiding this comment

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

Please don`t use comments in hebrew

function App() {
const [theme, setTheme] = useState(() => {
const savedTheme = localStorage.getItem("theme");

Copy link
Member

Choose a reason for hiding this comment

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

You can extract all logic related to the localStorage into storageService that will expose methods to use, for example :

storageSession.getIemFromLocalStora(id)

etc...


if (savedTheme) {
document.body.classList.toggle("dark-theme", savedTheme === "dark");
return savedTheme;
Copy link
Member

Choose a reason for hiding this comment

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

Good usage of the second argument of toggle function

* Resets the countries list to show all available countries.
*/
const showAllCountries = () => {
setCountries(countriesData);
Copy link
Member

Choose a reason for hiding this comment

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

It is not a good practice too add comment that explain what a function of a variable is doing, the code should explain itself

<section className="filters">
<div className="container">
{countries.length === 1 && (
<button className="button-all-countries" onClick={showAllCountries}>
Copy link
Member

Choose a reason for hiding this comment

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

Do not use magic numbers, extract them into variable with meaningful name.

For some one else that does not know your context of what you are working on, they don't know what 1 represents

*/
const Country = ({country}) => {

return (
Copy link
Member

Choose a reason for hiding this comment

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

Destruct your props :

const Country = ({ country: { flag, name, population, region, capital } }) => {
    return (
        <>
            <div className="country-flag">


return (
<div className={`dropdown-wrapper ${isOpen ? "open" : ""}`}>
<div className="dropdown-header flex flex-jc-sb flex-ai-c" onClick={toggleDropdown}>
Copy link
Member

Choose a reason for hiding this comment

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

Here is a shorter syntax :

<div className={`dropdown-wrapper ${isOpen && "open"}`}>

<div className="dropdown-body">
<ul onClick={action}>
<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.

use map instead :

const regions = ["All", "Africa", "Americas", "Asia", "Europe", "Oceania"];

<ul onClick={action}>
    {regions.map((region) => (
        <li key={region} data-region={region}>{region}</li>
    ))}
</ul>

onClick={toggleTheme}>
<i className={`fa-regular ${theme === "dark" ? "fa-sun" : "fa-moon"} theme-icon`}></i>
<span className="theme-text">{theme === "dark" ? "Light Mode" : "Dark Mode"}</span>
</button>
Copy link
Member

Choose a reason for hiding this comment

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

Extract theme === "dark" into a variable to avoid code duplication

- Removed Hebrew comments and unused code.
- Defined CSS colors as variables.
- Extracted magic numbers into named variables.
- Refactored theme logic and localStorage into reusable functions.
- Used map for regions list and applied shorter syntax where applicable.
- Applied destructuring to props for better readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants