Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Image Gallery

A beginner-friendly, fully responsive image gallery built with pure HTML, CSS, and Vanilla JavaScript — no frameworks, no libraries.


Features

  • Dynamic thumbnails — generated by a JavaScript forEach loop, not hand-coded HTML
  • Featured image — large display area with smooth fade transitions on change
  • Previous / Next navigation — wraps around from last → first and first → last
  • Dark Mode / Light Mode toggle — CSS Variables handle all colour switching
  • Keyboard navigation Left Arrow = Previous · Right Arrow = Next
  • Image counter — shows "Image X of Y" at all times
  • Active thumbnail highlight — glowing ring on the currently selected thumb
  • Hover effects — scale, border, and shadow on thumbnail hover
  • Fully responsive — CSS Grid auto-fill adapts to any screen size
  • Accessiblearia-label, tabindex, keyboard-focusable thumbnails, :focus-visible ring, prefers-reduced-motion support

Technologies Used

Technology Version
HTML5 Semantic elements, ARIA attributes
CSS3 Variables, Grid, Flexbox, Transitions
JavaScript ES6 (const/let, arrow functions, template literals)

No React · No Bootstrap · No jQuery · No Tailwind · No Angular · No Vue


Concepts Practised

Concept Where
Arrays imageData[] stores all 10 image objects
Loops forEach builds all thumbnails dynamically
Functions showImage(), showPrev(), showNext(), buildThumbnails(), toggleTheme(), updateCounter(), updateActiveThumbnail(), init()
Conditionals Boundary/wrap checks in showPrev/showNext; theme check in toggleTheme; if/else throughout
Events click on buttons & thumbnails; keydown for arrow keys; keydown for Enter/Space on focused thumbnails
DOM Manipulation getElementById, createElement, appendChild, classList.add/remove, textContent, src, alt, setAttribute, scrollIntoView

Project Structure

js-image-gallery/
├── index.html   — Page structure and semantic HTML
├── style.css    — All styling: tokens, layout, responsive, animations
├── script.js    — All interactivity: gallery logic, events, dark mode
└── README.md    — This file

How to Run

  1. Download or clone the folder.
  2. Open index.html in any modern browser — no server required.
# Optional: serve locally with Python
python -m http.server 8080
# Then open http://localhost:8080

Screenshots

(Add screenshots here)


Future Improvements

  • Image captions displayed below the featured image
  • Search / filter images by tag
  • Full-screen / lightbox mode
  • Lazy loading with loading="lazy" and IntersectionObserver
  • Touch/swipe support for mobile
  • Slideshow / autoplay mode with pause on hover
  • Local Storage: remember last viewed image and theme preference
  • Image upload: let users add their own images to the gallery

Image Credits

Images are royalty-free placeholders from picsum.photos, which serves random photos from Unsplash.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages