Skip to content

Commit

Permalink
Merge pull request #2 from Valik3201/simple-lightbox-library
Browse files Browse the repository at this point in the history
Added `SimpleLightbox` npm dependency
  • Loading branch information
Valik3201 authored Nov 8, 2023
2 parents 8d9c584 + 5b480f8 commit 50d5721
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
17 changes: 14 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"url": "https://github.com/Valik3201/goit-js-hw-08/issues"
},
"dependencies": {
"modern-normalize": "^1.1.0"
"modern-normalize": "^1.1.0",
"simplelightbox": "^2.14.2"
},
"devDependencies": {
"@parcel/packager-raw-url": "^2.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/01-gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<h1 class="title">SimpleLightbox Library</h1>

<!-- Add gallery items to this list -->
<ul class="gallery"></ul>
<div class="gallery"></div>

<script src="js/01-gallery.js" type="module"></script>
</body>
Expand Down
39 changes: 38 additions & 1 deletion src/js/01-gallery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
// Described in documentation;
import SimpleLightbox from 'simplelightbox';

// Additional styles import
import 'simplelightbox/dist/simple-lightbox.min.css';

// Add imports above this line
import { galleryItems } from './gallery-items';
// Change code below this line

console.log(galleryItems);
// Create Gallery
const galleryContainer = document.querySelector('.gallery');

const galleryImage = galleryItems.map(element => {
const galleryItem = document.createElement('div');
galleryItem.classList.add('gallery__item');

const galleryLink = document.createElement('a');
galleryLink.classList.add('galery__link');
galleryLink.href = element.original;

const image = document.createElement('img');
image.classList.add('gallery__image');
image.src = element.preview;
image.alt = element.description;

galleryLink.appendChild(image);
galleryItem.appendChild(galleryLink);

return galleryItem;
});

galleryContainer.append(...galleryImage);

// Initialization of SimpleLightbox
const gallery = new SimpleLightbox('.gallery a', {
captions: true,
captionsData: 'alt',
captionDelay: 250,
animationSpeed: 100,
fadeSpeed: 150,
});

0 comments on commit 50d5721

Please sign in to comment.