A responsive weather dashboard built with plain HTML, CSS, and JavaScript using the Open-Meteo APIs.
Live demo: https://sunnyyeahboiii.github.io/Weather-App-FrontEnd-Mentors/
- Overview
- Features
- Tech Stack
- Project Structure
- Getting Started
- How It Works
- API Usage
- Responsive Behavior
- Known Limitations
- Roadmap Ideas
- Credits
This project is a solution to the Frontend Mentor weather app challenge. It provides:
- Location search with geocoding suggestions
- Current weather conditions
- "Feels like", humidity, wind speed, and precipitation metrics
- 7-day daily forecast cards
- Hourly forecast for a selected weekday
- Unit switching for temperature, wind speed, and precipitation
The app is implemented as a static frontend (no framework, no bundler, no backend).
- Location Search
- Uses Open-Meteo geocoding API to fetch matching cities
- Displays dropdown-style result cards
- Loads selected city's forecast data
- Current Weather Board
- Shows location text, date, weather icon, and current temperature
- Starts with a skeleton/loading state
- Additional Metrics
- Feels like temperature
- Relative humidity
- Wind speed
- Precipitation
- Daily Forecast
- Seven cards with weekday, icon, max/min temperature
- Hourly Forecast
- Scrollable hourly list
- Day selector to switch between weekdays
- Unit Selector
- Temperature: Celsius/Fahrenheit
- Wind speed: km/h or mph
- Precipitation: mm or inch
- HTML5
- CSS3 (
styles.css,responsive.css,skeleton.css) - Vanilla JavaScript (
script.js) - Open-Meteo APIs
- Deployed via GitHub Pages
.
├── index.html
├── script.js
├── styles.css
├── responsive.css
├── skeleton.css
├── assets/
│ ├── images/
│ └── fonts/
├── style-guide.md
├── README-FrontendMentors.md
└── README-template.md
Because this is a static site, you can run it directly or with a local static server.
git clone https://github.com/sunnyyeahboiii/Weather-App-FrontEnd-Mentors.git
cd Weather-App-FrontEnd-MentorsChoose one option:
- Open
index.htmldirectly in your browser - Or start a local server (recommended), for example:
python3 -m http.server 5500Then visit http://localhost:5500.
At a high level:
- User searches for a city
- Geocoding API returns location candidates
- User selects a city card
- Forecast API fetches weather data using selected coordinates + chosen units
- UI sections are populated:
- current weather board
- detail metric cards
- daily forecast
- hourly forecast for selected day
Key client-side state in script.js:
latitude,longitudecityName,cityAdmintemperatureUnit,windSpeedUnit,precipitationUnitdataObj(fetched weather payload)forecastDayOfTheWeek(selected hourly day)
Endpoint:
https://geocoding-api.open-meteo.com/v1/search?name=<location_name>
Endpoint pattern used:
https://api.open-meteo.com/v1/forecast?latitude=<lat>&longitude=<lon>&temperature_unit=<unit>&precipitation_unit=<unit>&wind_speed_unit=<unit>¤t=temperature_2m,weather_code,wind_speed_10m&hourly=temperature_2m,weather_code&daily=weather_code,temperature_2m_max,temperature_2m_min&&minutely_15=temperature_2m,relative_humidity_2m,wind_speed_10m,precipitation
No API key is required for these Open-Meteo endpoints.
Responsive rules are primarily in responsive.css:
max-width: 768px:- Main weather layout switches from grid to stacked column flow
- Forecast cards adjust widths
max-width: 475px:- Header/logo and text sizes adapt further
- Current weather board content stacks vertically
From current codebase behavior:
- Weather icon assets
- JS expects files like
assets/images/icon-<condition>.webp. - If those files are missing, weather condition images will not render.
- JS expects files like
- Search edge cases
- If geocoding returns no
results, UI error handling can be improved.
- If geocoding returns no
- Error handling
- Fetch errors are currently logged to console, but user-facing error states are limited.
- Initial state mismatch
- Default coordinates are set to Berlin values while displayed default city text is "Vietnam".
- Accessibility opportunities
- Unit and forecast controls can be improved with richer ARIA semantics and keyboard UX polish.
- Add robust empty-state and API-error UI
- Add loading states per section (search, daily, hourly) for clearer feedback
- Add better time formatting (
12:00 AM/PM, zero-padding) - Add automated tests for core rendering/formatting logic
- Refactor JS into smaller modules for maintainability
- Challenge: Frontend Mentor - Weather app
- Weather data and geocoding: Open-Meteo
- Author: Sunny