This is a solution to the REST Countries API with color theme switcher challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Note: Delete this note and update the table of contents based on what sections you keep.
Users should be able to:
- See all countries from the API on the homepage
- Search for a country using an
input
field - Filter countries by region
- Click on a country to see more detailed information on a separate page
- Click through to the border countries on the detail page
- Toggle the color scheme between light and dark mode
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Desktop-first workflow
- Vanilla Javascript
- REST API
I learnt a lot while working on this challenge, especially on APIs. I also implemented the search and filter feature beautifully, i was amazed.
Code snippets i was amazed about:
//Search feature
let searchInput = document.getElementById('search')
searchInput.addEventListener('input', () => {
let searchValue = searchInput.value.toUpperCase()
let cardsDB = document.querySelectorAll(".cards");
for(let i = 0; i < cardsDB.length; i++) {
let countryName = cardsDB[i].querySelector('h2').innerHTML
if (countryName.toUpperCase().indexOf(searchValue) > -1) {
cardsDB[i].style.display = ""
} else {
cardsDB[i].style.display = "none"
}
}
})
let region = document.getElementById("region")
region.addEventListener("input", () => {
let regionValue = region.value
let selectedRegion = data.filter(country => country.region == regionValue)
renderDB(selectedRegion)
})
I've gotten a lot of experience while working with web based technologies like HTML, CSS, Bootstrap, and JavaScript. It's time to take on a JavaScript framework/library, and ReactJS it is.
- Website - Udhe Austine Ogaga
- Frontend Mentor - @austinet
- Twitter - @yourusername
I will like to acknowledge God for giving me the grace to be patient with myself while going through the huddles of carrying out this project. And also Frontend mentor, KodeCamp team for this tasks where i got to consume data from APIs.