Skip to content

top-submissions/weather-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Weather App β˜€οΈπŸŒ§οΈ

GitHub License GitHub Issues GitHub Pull Requests GitHub Last Commit GitHub Stars Node Version Webpack Version

A dynamic weather forecast application that displays real-time weather data with temperature conversion and beautiful sky-inspired theming.

πŸ“– Table of Contents

🎯 About

This Weather App is a project from The Odin Project's JavaScript course. It demonstrates proficiency in working with external APIs, handling asynchronous JavaScript operations, and creating dynamic user interfaces.

The application fetches real-time weather data from the Visual Crossing Weather API and presents it in an intuitive, visually appealing format. Users can search for any location worldwide and view current conditions along with a forecast. The interface dynamically adapts its appearance based on weather conditions, creating an immersive experience.

Built with vanilla JavaScript, this project showcases modern web development practices including ES6 modules, async/await patterns, and responsive designβ€”all without relying on frameworks or libraries beyond Webpack for bundling.

✨ Features

  • πŸ” Location Search - Search weather for any city or location worldwide
  • 🌑️ Temperature Toggle - Seamlessly switch between Fahrenheit and Celsius
  • 🎨 Dynamic Theming - Background and colors change based on weather conditions (sunny, cloudy, rainy, night)
  • πŸ“Š Detailed Weather Data - Current temperature, feels like, humidity, wind speed, UV index, and more
  • πŸ“… 7-Day Forecast - View weather predictions for the week ahead
  • ⏰ Loading Indicator - Smooth spinner animation while fetching data
  • ❌ Error Handling - User-friendly error messages for invalid locations or API issues
  • πŸ“± Responsive Design - Works perfectly on desktop, tablet, and mobile devices
  • ☁️ Weather Icons - Beautiful weather condition icons from Weather Icons library

πŸ“‹ Prerequisites

Before you begin, ensure you have met the following requirements:

  • Node.js >= 14.0.0 - Download here
  • npm >= 6.0.0 or yarn >= 1.22.0
  • Git - For version control
  • A modern web browser (Chrome, Firefox, Safari, or Edge)
  • Visual Crossing API Key - Free tier available at Visual Crossing Weather

πŸ”§ Installation

1. Clone the repository

git clone https://github.com/top-submissions/weather-app.git
cd weather-app

2. Install dependencies

npm install

3. Get your Visual Crossing API Key

  1. Visit Visual Crossing Weather API
  2. Sign up for a free account
  3. Copy your API key from the dashboard
  4. Open src/modules/weatherAPI.js and replace 'YOUR_API_KEY' with your actual API key
const API_KEY = 'your_actual_api_key_here';

πŸ’» Usage

Development Mode

Start the development server with hot reload:

npm run dev

The application will be available at http://localhost:8080

Production Build

Build the project for production:

npm run build

The optimized files will be generated in the dist/ directory.

Additional Commands

# Watch mode - rebuild on file changes
npm run watch

# Run linter
npm run lint

# Fix linting issues automatically
npm run lint:fix

# Format code with Prettier
npm run format

# Check code formatting
npm run format:check

βš™οΈ Configuration

The project uses three webpack configurations:

  • webpack.common.js - Shared configuration for all environments
  • webpack.dev.js - Development-specific settings (source maps, dev server)
  • webpack.prod.js - Production optimizations (minification, code splitting)

πŸ“œ Scripts

Script Description
npm run dev Start development server with hot reload
npm run build Create production build
npm run watch Watch for file changes and rebuild
npm run lint Check code for linting errors
npm run lint:fix Automatically fix linting issues
npm run format Format code with Prettier
npm run format:check Check if code is formatted correctly
npm run deploy Deploy to GitHub Pages

πŸš€ Deployment

GitHub Pages

  1. Build the project:

    npm run build
  2. Deploy to GitHub Pages:

    npm run deploy

Your app will be live at: https://top-submissions.github.io/weather-app

πŸ› οΈ Built With

πŸŽ“ Learning Outcomes

What I learned from this project:

  • Promise based functions (i.e. fetch, etc.) return a promise, thus you must use the await keyword when storing their return value to a variable or expression
  • fetch function uses mode: 'cors' in its options parameter as default (for now I can only interpret it as allowing a client, which is from a different origin, to access a server's information)
  • Using async and await keywords to wait for data retrieval from web browser and data transfer to task queue
  • await keyword works similarly to .then() and .catch() functions, where it unboxes the promise turning it into its raw value
  • Parsing JSON into JS objects via .json()
  • Extracting icons from raw fetch query object (i.e. currentConditions.icon)

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


Part of The Odin Project JavaScript Course