Skip to content

Officialsammy2701/rest-countries-api

Repository files navigation

Frontend Mentor - REST Countries API with color theme switcher solution

This is my 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. The project focuses on building a responsive UI that allows users to explore country data with filtering, searching, and theme switching.


Table of contents


Overview

The challenge

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 (optional)

Screenshot


Links


My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties (variables)
  • Flexbox
  • CSS Grid
  • Vanilla JavaScript (modular structure)
  • Mobile-first workflow
  • REST Countries dataset (data.json)

What I learned

This project helped me improve my understanding of structuring a real-world frontend application without using a framework. One key thing I learned was how to separate logic into reusable modules instead of writing everything in one file. For example:

export function getCountriesByName(countries, query) {
  if (!query || !query.trim()) return countries;

  const q = query.trim().toLowerCase();

  return countries.filter((country) => {
    return (
      country.name.toLowerCase().includes(q) ||
      (country.capital || '').toLowerCase().includes(q)
    );
  });
}

I also improved my understanding of:

  • Managing UI state (search + region filter together)
  • Building a custom dropdown instead of relying on <select>.
  • Handling theme switching using localStorage
  • Structuring CSS into global styles and page-specific styles
  • Matching designs pixel-perfectly across desktop and mobile (especially 375px)

Continued development

In future projects, I want to focus on:

  • Improving UI consistency and spacing accuracy
  • Writing cleaner and more scalable CSS architecture
  • Adding accessibility improvements (ARIA roles, keyboard navigation)

Useful resources


Author


Acknowledgments

This project was built as part of my frontend development practice. Special thanks to Frontend Mentor for providing high-quality, real-world challenges.

Releases

No releases published

Packages

 
 
 

Contributors