Skip to content

Conversation

@IdanBarhom
Copy link

No description provided.

…put. dont know how to import the content from the json file. didn't do the 'details page'
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.

Please remove all of your comments

Do not use innerHTML

<li data-region="europe">Europe</li>
<li data-region="oceania">Oceania</li>
<li data-region="all" onclick="filterRegion(this)">All</li>
<li data-region="africa" onclick="filterRegion(this)" >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.

Can you tell me what this refers to ?

</div>
</a>
<section id="countries-grid" class="countries-grid">

Copy link
Member

Choose a reason for hiding this comment

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

Why do you have both class and id and why both of them are with the same name ?


const CountriesData=[
{
"name": "Åland Islands",
Copy link
Member

Choose a reason for hiding this comment

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

This should be inside json file

// console.log("hi");
// import countries from './CountriesData.json'
//console.log(CountriesData)
let countriesGrid = document.querySelector(".countries-grid");
Copy link
Member

Choose a reason for hiding this comment

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

Remove all of the comments they are not relevant

//console.log(value)
const searchedCountries = CountriesData.filter(
(country) => country.name.toLowerCase().includes(value)
);
Copy link
Member

Choose a reason for hiding this comment

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

In case the value is "" do you want to filter everything? or maybe return the entire data as is?

);
//console.log(searchedCountries);
countriesGrid.innerHTML = renderCountries(searchedCountries);

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 innerHTML because it is a dangerous method


filter.visibility === "hidden"
? ((filter.visibility = "visible"), (filter.opacity = 1))
: ((filter.visibility = "hidden"), (filter.opacity = 0));
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 the repeating code into a function :

function toggleVisibility(filter, isVisible) {
  filter.visibility = isVisible ? "visible" : "hidden";
  filter.opacity = isVisible ? 1 : 0;
}


const isCurrentlyHidden = filter.visibility === "hidden";
toggleVisibility(filter, isCurrentlyHidden);

But generally use css classes to style elements and not from js

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