-
Notifications
You must be signed in to change notification settings - Fork 28
added html and js #7
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?
Conversation
yuvalbenshitrit
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.
The code structure is clear, and you've followed good practices
| const loader = document.querySelector('.loader'); | ||
| loader.style.display = 'none'; | ||
|
|
||
| detailsContainer.innerHTML = ` |
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.
Ensure the use of backticks (``) for the innerHTML content
| fetchCountryData(countryName); | ||
| } | ||
| else { | ||
| console.error('Country name not found'); |
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.
Provide feedback to user if country name is not found
| const displayCountryDetails = (country) => { | ||
| const detailsContainer = document.querySelector('.country-details'); | ||
| const loader = document.querySelector('.loader'); | ||
| loader.style.display = 'none'; |
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.
Hide loader after data is fetched
| const dropdownWrapper = document.querySelector('.dropdown-wrapper'); | ||
|
|
||
| if (dropdownWrapper.classList.contains('open')) { | ||
| dropdownWrapper.classList.remove('open'); |
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.
Close dropdown after selection
| }); | ||
|
|
||
| const fetchCountryData = (countryName) => { | ||
| fetch('./CountriesData.json') |
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.
Avoid calling fetch repeatedly for the same data (e.g., when filtering regions). Cache the data once:
| dropdownWrapper.classList.remove('open'); | ||
| } | ||
|
|
||
| const filterByRegion = (region) => { |
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.
Consider displaying a loader while filtering data by region. This ensures the user is aware that a background process is ongoing.
| } | ||
| }); | ||
|
|
||
| const fetchCountryData = (countryName) => { |
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.
Display a loader before fetching country data
No description provided.