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.
- π 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
Visit the live application: View Demo
- React - UI library
- TypeScript - Type safety
- Vite - Build tool and dev server
- React Router - Client-side routing
- Tailwind CSS v4 - Utility-first CSS framework with CSS-based configuration
- Nunito Sans - Google Font
- REST Countries API v3.1 - Country data source
- Axios - HTTP client for API requests
- React Context API - Global theme state management
This project was significantly enhanced using GenAI assistance (GitHub Copilot) to refactor and modernize the codebase. Below are the key improvements made:
- 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/postcssv4 - Created CSS-based theme configuration using
@themedirective - Implemented utility-first approach for all components
- 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%)
- Dark Mode Background:
- Smart Theme Toggle: Class-based dark mode with React Context
- Inline Styles: Used for precise color control with Tailwind v4
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
- Type safety enhancements
- Removed redundant code
- Improved component structure
- Better error handling
- Cleaner imports and exports
- Tailwind CSS v4 for smaller bundle size
- Proper image loading
- Efficient re-renders with React Context
- Optimized PostCSS configuration
- β 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
- Node.js (v14 or higher)
- npm or yarn
- Clone the repository
git clone https://github.com/mileine/frontendmentor-rest-countries-api.git
cd frontendmentor-rest-countries-api- Install dependencies
npm install- Start the development server
npm run dev- Open your browser and navigate to
http://localhost:5173/
npm run buildPreview production build:
npm run previewwebapp-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
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}
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%)
- Font Family: Nunito Sans
- Weights: 300 (Light), 600 (Semi-bold), 800 (Extra-bold)
- Homepage Font Size: 14px
- Detail Page Font Size: 16px
- Light Mode:
0 2px 9px rgba(0, 0, 0, 0.05) - Dark Mode:
0 2px 4px rgba(0, 0, 0, 0.15)
- Consumindo uma API com React.JS e Axios
- Using Axios to set request headers
- A Complete Guide to React Router
- How to Import SVGs in a React and Vite app
- Tailwind CSS v4 Documentation
Mileine
This project is open source and available under the MIT License.
- 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