-
Notifications
You must be signed in to change notification settings - Fork 28
Idanbarhom #13
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?
Idanbarhom #13
Conversation
…put. dont know how to import the content from the json file. didn't do the 'details page'
Tamir198
left a comment
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.
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> |
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.
Can you tell me what this refers to ?
| </div> | ||
| </a> | ||
| <section id="countries-grid" class="countries-grid"> | ||
|
|
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.
Why do you have both class and id and why both of them are with the same name ?
|
|
||
| const CountriesData=[ | ||
| { | ||
| "name": "Åland Islands", |
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.
This should be inside json file
| // console.log("hi"); | ||
| // import countries from './CountriesData.json' | ||
| //console.log(CountriesData) | ||
| let countriesGrid = document.querySelector(".countries-grid"); |
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.
Remove all of the comments they are not relevant
| //console.log(value) | ||
| const searchedCountries = CountriesData.filter( | ||
| (country) => country.name.toLowerCase().includes(value) | ||
| ); |
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.
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); | ||
|
|
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.
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)); |
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.
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
No description provided.