Table of Contents
A beautiful Image Gallery with Sorting and Drag and Drop Support. For full feature list, head over to the Features section below.
🌐 The project is already live at: https://webdevsk.github.io/Image-Gallery-DND/
OR
🖥️ You can test it on your local machine by following the steps below.
⭐ Want to build a Drag and Drop
only component from scratch? You can follow my own instructions here:
( )=> Quick Setup DND Kit
-
Open your projects base folder and launch any terminal of your choice.
-
Run this command:
npm install npm@latest -g
-
Clone the repo
git clone https://github.com/webdevsk/Image-Gallery-DND.git
-
Install NPM packages
npm install
-
Fill in a
.env.local
file following the patterns ofenvSample.txt
-
Run Dev server
npm run dev
- Built using CSS Grid layout. Fully responsive on all devices.
- First image spans by 2 cells in both direction indicating a Featured Image.
- Hover over an image to reveal an Overlay with action buttons.
- useState hook allows each button to show up indivisually based on different scenarios.
- Uses
dnd kit
library to allow drag and drop feature. - Supports
Pointer
,Mouse
,Touch
andKeyboard
interactions for better accessibility. - Shows a
Duplicate element
that floats while dragging. - Shows a
Drop zone
with proper styling. - Animates on drop end.
Sorts
the state variable based on drop source and target.- Animates on every
Sort
operations.
- Overlay features a Set as Featured button.
- Sorts the state variable array to move current item to the beginning.
- Animates while being sorted.
- Overlay features a Selection button.
- Select/Mark, Unselect/Unmark items for deletion.
- Gallery Header shows
Selected items count
, aBatch Selection button
andDelete button
. - Items are removed from State variable array upon deletion.
- Overlay features a Expand button.
- Shows a
Dialogue
with the current image for a bigger view. - Button for closing the Dialogue. Clicking outside closes the dialogue as well.
- Carefully setup Dialogue height and width for the Mobile support.
- Uses
react-zoom-pan-pinch
library to allow expanded image to be interactive. - Supports
Mouse
,Mouse Wheel
andTouch
to effectively zoom, pan and pinch image.
- Press
Add Images
button to add your own. - File size validation:
- Upto 2MB (2048KB)
- File format validation:
- Only allow types of file: image
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Project Link: https://github.com/webdevsk/Image-Gallery-DND