Simple, fast, and modern weather app that shows current conditions and a 5‑day forecast with helpful visuals and a favorites list. It uses OpenWeather as the data source and Pixabay for dynamic backgrounds.
Live demo: https://florinfire80.github.io/WeatherApp
Prerequisites:
Install and run locally:
git clone https://github.com/florinfire80/WeatherApp.git
cd WeatherApp
npm install
# Create a .env file (see Environment variables below) then start the dev server
npm run start
Build for production:
npm run build
Run tests:
npm test
Lint and format:
npm run lint
npm run lint:fix
npm run format
This project expects API keys via environment variables. For consistency,
variables are prefixed with PARCEL_
and inlined by Parcel during builds.
Create a file named .env
in the project root with:
PARCEL_OPENWEATHER_API_KEY=your_openweather_api_key
PARCEL_PIXABAY_API_KEY=your_pixabay_api_key # optional (background images)
Notes:
PARCEL_PIXABAY_API_KEY
, but background images may
fail to load.PARCEL_OPENWEATHER_API_KEY
, API calls will fail. The app logs a
clear warning and some features won’t work.Windows (Git Bash) one-liner to create .env
:
printf "PARCEL_OPENWEATHER_API_KEY=YOUR_KEY\nPARCEL_PIXABAY_API_KEY=YOUR_KEY\n" > .env
This repo uses GitHub Actions to build and deploy to Pages on every push to
main
.
PARCEL_OPENWEATHER_API_KEY
(required)PARCEL_PIXABAY_API_KEY
(optional)https://florinfire80.github.io/WeatherApp/
homepage
in package.json
matches this URL (already set).localStorage
with TTL reduce API calls and speed up
navigationsrc/
index.html
index.js # entry + theme + initial wiring
components/
WeatherData/
current/ # current weather: service, clock, background, search
fiveDays/ # five‑day view: bootstrap + renderers + state
icons/ # SVG icons + registry + icon code mapping
weatherService.js # fetch, normalize, cache
utilsForCurrentDay.js
utilsForFiveDays.js
scheduler/ # performance-friendly task helpers
...
sass/ # SCSS partials and variables
css/ # built CSS (by Parcel/Sass)
npm run start
– start the Parcel dev servernpm run build
– clean and build production assets (outputs to dist/
)npm test
– run the Jest test suitenpm run lint
/ npm run lint:fix
– run ESLint (and auto‑fix)npm run format
– format files with PrettierThe app builds as a static site suitable for GitHub Pages.
npm run build
dist/
to the branch you serve with GitHub Pages (e.g.,
gh-pages
)This repository also sets homepage
in package.json
to the public URL; ensure
it matches your Pages settings if you fork.
Example (push dist
to gh-pages
once):
git checkout --orphan gh-pages
git reset --hard
cp -r dist/* .
git add .
git commit -m "Deploy"
git push -u origin gh-pages -f
Subsequent deploys can be done by rebuilding and repeating the copy/commit to
gh-pages
.
.env
contains a valid PARCEL_OPENWEATHER_API_KEY
, then
restart npm run start
.PARCEL_PIXABAY_API_KEY
to .env
or ignore (it’s optional).--public-url ./
(already configured in
npm run build
).ISC