A dynamic weather forecast application that displays real-time weather data with temperature conversion and beautiful sky-inspired theming.
- Weather App βοΈπ§οΈ
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.
- π 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
Before you begin, ensure you have met the following requirements:
- Node.js
>= 14.0.0- Download here - npm
>= 6.0.0or 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
git clone https://github.com/top-submissions/weather-app.git
cd weather-appnpm install- Visit Visual Crossing Weather API
- Sign up for a free account
- Copy your API key from the dashboard
- Open
src/modules/weatherAPI.jsand replace'YOUR_API_KEY'with your actual API key
const API_KEY = 'your_actual_api_key_here';Start the development server with hot reload:
npm run devThe application will be available at http://localhost:8080
Build the project for production:
npm run buildThe optimized files will be generated in the dist/ directory.
# 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:checkThe project uses three webpack configurations:
webpack.common.js- Shared configuration for all environmentswebpack.dev.js- Development-specific settings (source maps, dev server)webpack.prod.js- Production optimizations (minification, code splitting)
| 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 |
-
Build the project:
npm run build
-
Deploy to GitHub Pages:
npm run deploy
Your app will be live at: https://top-submissions.github.io/weather-app
- JavaScript ES6+ - Modern JavaScript
- Webpack 5 - Module bundler
- Visual Crossing Weather API - Weather data provider
- Weather Icons - Weather condition icons
- date-fns - Date formatting utility
- ESLint - JavaScript linter
- Prettier - Code formatter
What I learned from this project:
- Promise based functions (i.e.
fetch, etc.) return a promise, thus you must use theawaitkeyword when storing their return value to a variable or expression fetchfunction usesmode: '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
asyncandawaitkeywords to wait for data retrieval from web browser and data transfer to task queue awaitkeyword 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)
This project is licensed under the MIT License - see the LICENSE file for details.
- The Odin Project - For the excellent curriculum and project idea
- Visual Crossing - For providing the weather API
- Weather Icons by Erik Flowers - For the beautiful weather icons
- Webpack Documentation - For comprehensive bundler guides
Part of The Odin Project JavaScript Course