A modern, responsive weather application built with vanilla JavaScript that provides current weather conditions and 5-day forecasts for any city worldwide.
- 🌤️ Current Weather Display: Shows temperature, feels-like temperature, humidity, wind speed, pressure, and visibility
- 📅 5-Day Forecast: Daily weather predictions with temperature ranges and conditions
- 🔍 Smart Search: Autocomplete functionality with city suggestions
- 📍 Geolocation Support: Get weather for your current location (with permission)
- 🌓 Dark/Light Theme: Toggle between light and dark themes
- 📱 Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- ⚡ Real-time Updates: Fast loading and smooth transitions
- 🔔 Notifications: User-friendly success and error messages
- ⌨️ Keyboard Shortcuts: Ctrl/Cmd+K to focus search, Escape to clear
- HTML5: Semantic markup with accessibility features
- CSS3: Modern styling with gradients, animations, and responsive grid
- Vanilla JavaScript: ES6+ features, no external dependencies
- OpenWeatherMap API: Real weather data (mock data for demo)
weather-app/
├── index.html # Main HTML entry point
├── styles.css # Complete styling with themes
├── app.js # Main application logic and state management
├── weatherService.js # Weather data fetching service
├── components.js # Reusable UI components
├── package.json # Project configuration
└── README.md # This file
- Clone or download the project files
- Install dependencies (if needed):
npm install
Start the development server:
npm run devOr start on a specific port:
npm startYou can also open index.html directly in a web browser, but some features may be limited due to CORS restrictions.
Handles all weather data fetching with mock data for demonstration. In production, replace with real API calls to OpenWeatherMap.
Displays current weather conditions with:
- Temperature and "feels like" temperature
- Weather description and icon
- Detailed metrics (humidity, wind, pressure, visibility)
Shows 5-day forecast with:
- Daily temperature ranges
- Weather conditions and icons
- Additional details (humidity, wind speed)
Provides city search functionality with:
- Autocomplete suggestions
- Keyboard shortcuts support
- Geolocation integration
To use real weather data:
- Sign up at OpenWeatherMap
- Get your API key
- Replace the mock data in
weatherService.jswith actual API calls:const response = await fetch(`${this.baseUrl}/weather?q=${city}&appid=${YOUR_API_KEY}&units=metric`);
The app includes a built-in dark/light theme toggle. Customize colors in styles.css under the /* Dark Theme */ section.
Add more default cities to the mock data in weatherService.js by extending the mockData object.
- Chrome/Chromium 60+
- Firefox 55+
- Safari 12+
- Edge 79+
- Lazy loading of weather data
- Efficient DOM updates
- Optimized CSS animations
- Minimal bundle size (~30KB total)
- Service worker ready (commented in HTML)
- Semantic HTML5 markup
- ARIA-friendly structure
- Keyboard navigation support
- High contrast themes
- Screen reader compatible
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - feel free to use this project for personal or commercial purposes.
Open the application in your browser and try searching for cities like:
- New York
- London
- Tokyo
- Paris
- Berlin
The app will display current weather conditions and a 5-day forecast for any location.
Made with ❤️ using vanilla JavaScript