A responsive, animated weather application that lets users search for current weather conditions by city name. It leverages the public WeatherAPI service to display real‑time atmospheric data with a polished UI built using Bootstrap 5, custom CSS, and Font Awesome icons.
- City search with Enter key or button trigger
- Loading spinner and error handling states
- Current conditions: temperature, feels like, condition text & icon
- Key metrics: visibility, humidity, wind speed/direction, pressure
- Extra metrics: UV index, cloud cover, precipitation, dew point
- Animated UI elements (cards, stats, icons, transitions)
- Responsive design (desktop → mobile)
- Utility temperature/wind formatting helpers
- HTML5 semantic structure
- CSS3 (custom design system, gradients, animations, responsive breakpoints)
- JavaScript (ES6 classes & modular methods)
- Bootstrap 5 (layout & base components via CDN)
- Font Awesome 6 icons (CDN)
- WeatherAPI (https://www.weatherapi.com/) for live data
index.html # Markup & layout
styles.css # Custom theming, animations, responsive rules
script.js # WeatherApp class, API fetch, DOM updates, utilities
README.md # Project documentation
- User enters a city and clicks Search (or presses Enter).
searchWeather()validates input, shows loading UI.fetchWeatherData()calls WeatherAPI Current endpoint.- On success,
displayWeatherData()maps JSON to UI elements. - On failure, an error alert is shown.
Current implementation calls:
GET https://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&q=CITY&aqi=noReplace YOUR_API_KEY with a valid WeatherAPI key (free tier available). The repository version currently hard‑codes a key in script.js; for security you should:
- Remove the committed key.
- Store it in an environment variable at build time OR
- Prompt the user to input it OR
- Load from a separate
config.jsthat is.gitignored.
- Clone or download the project folder.
- Open
index.htmldirectly in a modern browser (no build step required). - Enter a city name (e.g., London, New York, Colombo) and press Search.
- Styling: Adjust theme tokens in
:rootinsidestyles.css. - Animation: Modify keyframes (
float,bounce,fadeInUp, etc.). - Metrics: Extend
displayWeatherData()to include forecast endpoints. - Units: Add a toggle (°C/°F) using the provided
TemperatureConverterutility.
Breakpoints tuned for ≤768px and ≤576px with scaled typography, spacing, and icon sizing to preserve readability and interaction comfort.
Designed for evergreen browsers (Chrome, Edge, Firefox, Safari). Legacy IE is not supported.
- CDN delivery for Bootstrap & Font Awesome reduces initial setup.
- Minimal JavaScript bundle (single
script.js) for quick load. - Consider adding
deferto the script tag for non‑blocking parsing if you inline the JS file locally.
- Descriptive text for icons via alt attributes
- Clear focus states can be further improved (todo)
- Color contrast largely meets WCAG AA (verify with tooling)
Weather data accuracy depends on the upstream provider (WeatherAPI). Always verify critical decisions with multiple sources.
This project is open source and available for educational purposes. Feel free to use, modify, and distribute as needed.
⭐️ From Nugi29