Skip to content

mileine/frontendmentor-rest-countries-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌍 REST Countries API with Color Theme Switcher

Frontend Mentor Challenge React TypeScript Tailwind CSS Vite

A responsive web application that allows users to browse information about countries from around the world with a beautiful dark/light theme switcher. Built as a Frontend Mentor challenge.

✨ Features

  • πŸ” Search Functionality - Search for countries by name
  • 🌍 Filter by Region - Browse countries by continent (Africa, Americas, Asia, Europe, Oceania)
  • πŸ“± Responsive Design - Optimized for mobile, tablet, and desktop
  • πŸŒ“ Dark/Light Mode - Toggle between themes with smooth transitions
  • 🎨 Modern UI - Clean interface following Frontend Mentor design specifications
  • ⚑ Fast Performance - Built with Vite for optimal loading speeds
  • πŸ”— Detailed Country View - See in-depth information including borders, currencies, and languages

πŸš€ Live Demo

Visit the live application: View Demo

πŸ› οΈ Technologies Used

Core

  • React - UI library
  • TypeScript - Type safety
  • Vite - Build tool and dev server
  • React Router - Client-side routing

Styling

  • Tailwind CSS v4 - Utility-first CSS framework with CSS-based configuration
  • Nunito Sans - Google Font

API & Data

  • REST Countries API v3.1 - Country data source
  • Axios - HTTP client for API requests

State Management

  • React Context API - Global theme state management

πŸ€– GenAI-Assisted Development

This project was significantly enhanced using GenAI assistance (GitHub Copilot) to refactor and modernize the codebase. Below are the key improvements made:

Major Refactoring (November 2025)

1. Complete UI Overhaul with Tailwind CSS v4

  • Before: Used SCSS modules for styling
  • After: Migrated to Tailwind CSS v4 with CSS-based configuration
  • Changes:
    • Removed all SCSS files and dependencies
    • Installed @tailwindcss/postcss v4
    • Created CSS-based theme configuration using @theme directive
    • Implemented utility-first approach for all components

2. Enhanced Dark Mode Implementation

  • Accurate Color Palette: Matched Frontend Mentor design specifications
    • Dark Mode Background: hsl(207, 26%, 17%)
    • Dark Mode Elements: hsl(209, 23%, 22%)
    • Light Mode Background: hsl(0, 0%, 98%)
    • Light Mode Elements: hsl(0, 0%, 100%)
    • Light Mode Text: hsl(200, 15%, 8%)
  • Smart Theme Toggle: Class-based dark mode with React Context
  • Inline Styles: Used for precise color control with Tailwind v4

3. Component Refactoring

Header Component

  • Responsive typography (text-sm to text-2xl)
  • Shadow effects for depth
  • Proper color transitions

Home Page

  • Modern search input with icon
  • Dropdown filter with custom styling
  • Responsive grid layout (1-4 columns based on screen size)
  • Improved placeholder styling

Country Cards

  • Hover effects with scale transformation
  • Proper image aspect ratio
  • Consistent padding and spacing
  • Shadow variations for light/dark modes

Country Details Page

  • Two-column responsive layout
  • Back button with navigation
  • Border countries as interactive buttons
  • Comprehensive country information display

4. Code Quality Improvements

  • Type safety enhancements
  • Removed redundant code
  • Improved component structure
  • Better error handling
  • Cleaner imports and exports

5. Performance Optimizations

  • Tailwind CSS v4 for smaller bundle size
  • Proper image loading
  • Efficient re-renders with React Context
  • Optimized PostCSS configuration

GenAI Contribution Summary

  • βœ… Automated migration from SCSS to Tailwind CSS
  • βœ… Implemented responsive design patterns
  • βœ… Enhanced accessibility and UX
  • βœ… Improved code organization and maintainability
  • βœ… Added comprehensive type definitions
  • βœ… Modernized build configuration

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Installation

  1. Clone the repository
git clone https://github.com/mileine/frontendmentor-rest-countries-api.git
cd frontendmentor-rest-countries-api
  1. Install dependencies
npm install
  1. Start the development server
npm run dev
  1. Open your browser and navigate to http://localhost:5173/

Build for Production

npm run build

Preview production build:

npm run preview

πŸ—‚οΈ Project Structure

webapp-countries/
β”œβ”€β”€ public/              # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/         # Images, icons, SVGs
β”‚   β”œβ”€β”€ components/     # Reusable components
β”‚   β”‚   β”œβ”€β”€ CountriesContainer/
β”‚   β”‚   β”œβ”€β”€ CountryCard/
β”‚   β”‚   β”œβ”€β”€ Header/
β”‚   β”‚   └── SwitchButton/
β”‚   β”œβ”€β”€ context/        # React Context for state management
β”‚   β”œβ”€β”€ data/           # Mock data
β”‚   β”œβ”€β”€ pages/          # Route pages
β”‚   β”‚   β”œβ”€β”€ Home/
β”‚   β”‚   └── CountryDetails/
β”‚   β”œβ”€β”€ services/       # API configuration
β”‚   β”œβ”€β”€ styles/         # Global styles & Tailwind config
β”‚   β”œβ”€β”€ utils/          # Helper functions
β”‚   β”œβ”€β”€ App.tsx         # Root component
β”‚   └── main.tsx        # Entry point
β”œβ”€β”€ design/             # Design reference files
β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ postcss.config.js   # PostCSS configuration
β”œβ”€β”€ tailwind.config.js  # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json       # TypeScript configuration
└── vite.config.ts      # Vite configuration

🌐 API Reference

REST COUNTRIES API

Endpoints Used:

Country by code:

https://restcountries.com/v3.1/alpha/{code}

Country by name:

https://restcountries.com/v3.1/name/{name}

Countries by region:

https://restcountries.com/v3.1/region/{region}

🎨 Design System

Colors

Dark Mode

  • Background: hsl(207, 26%, 17%)
  • Elements: hsl(209, 23%, 22%)
  • Text: hsl(0, 0%, 100%)

Light Mode

  • Background: hsl(0, 0%, 98%)
  • Elements: hsl(0, 0%, 100%)
  • Text: hsl(200, 15%, 8%)
  • Input: hsl(0, 0%, 52%)

Typography

  • Font Family: Nunito Sans
  • Weights: 300 (Light), 600 (Semi-bold), 800 (Extra-bold)
  • Homepage Font Size: 14px
  • Detail Page Font Size: 16px

Shadows

  • Light Mode: 0 2px 9px rgba(0, 0, 0, 0.05)
  • Dark Mode: 0 2px 4px rgba(0, 0, 0, 0.15)

🌐 Resources & References

Frontend Mentor Challenge

Learning Resources

πŸ‘©β€πŸ’» Author

Mileine

πŸ“„ License

This project is open source and available under the MIT License.

πŸ™ Acknowledgments

  • Frontend Mentor for the challenge and design
  • REST Countries API for the comprehensive country data
  • GitHub Copilot for AI-assisted development and refactoring
  • The React and Tailwind CSS communities for excellent documentation

Made with ❀️ using React, TypeScript, and Tailwind CSS

Enhanced with πŸ€– GitHub Copilot

About

A challenge by Frontend Mentor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors