A clean, responsive web app for quickly checking current weather for any city — built for the user persona Jamie (Outdoor Enthusiast).
- 🔎 Search any city (uses Open‑Meteo Geocoding API)
- 🌡️ Live current conditions from Open‑Meteo (no API key needed)
- 🔁 °C/°F toggle (also updates wind to km/h or mph)
- ✅ Graceful error handling + loading states
- 📱 Fully responsive, accessible UI (Tailwind CSS)
- React 18 + Vite
- Tailwind CSS
- Open‑Meteo (Forecast + Geocoding APIs)
-
Install dependencies
npm install
-
Run dev server
npm run dev
Vite will print a local URL like
http://localhost:5173. -
Build for production
npm run build npm run preview
- On search, the app calls:
GET https://geocoding-api.open-meteo.com/v1/search?name={CITY}&count=1to get latitude/longitude.GET https://api.open-meteo.com/v1/forecast?latitude={LAT}&longitude={LON}¤t_weather=true&temperature_unit={celsius|fahrenheit}&windspeed_unit={kmh|mph}&timezone=autoto fetch current weather.
- Weather codes are mapped to friendly labels + emojis in
src/utils/weatherCodes.js. - Errors (no results, network issues) are displayed in-line.
Option A – CodeSandbox
- Go to https://codesandbox.io/ → "Create Sandbox" → Template: Vite + React.
- Add Tailwind: create files
postcss.config.cjs,tailwind.config.cjs, and add the directives tosrc/index.css(already included here). - Copy/paste the contents of this project into the sandbox (or upload the zip).
Option B – StackBlitz
- Go to https://stackblitz.com/ → "Create new" → Vite React.
- Add the Tailwind config files and
src/index.csscontent from this repo. - Paste
src/App.jsxandsrc/utils/weatherCodes.jsover the defaults.
Tip: You can also git init this folder and push to GitHub, then import the repo in CodeSandbox/StackBlitz for one‑click deploy.
-
Manual test cases:
- Search a valid city (e.g., London). Expect temperature, wind, time, emoji.
- Search a nonsense string (e.g.,
zzzzzzz). Expect an inline error message. - Toggle °C/°F and re‑search. Units should change; values should differ.
- Click Use my location. Grant permission → see local weather (or error if denied).
- Resize to mobile width; layout should remain readable.
-
Optional unit test idea (Vitest/Jest): test
degToCompass()anddescribeWeather()mappings fromsrc/utils/weatherCodes.js.
- No authentication is required for Open‑Meteo endpoints used here.
- All network calls are
fetch()with basic error handling. - Accessibility: proper labels, semantic headings, button states, reduced motion respected by default Tailwind.
MIT
https://shaik0809.github.io/Weather-project-using-Html-CSS-JavaScript/