-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SimpleLightbox from "simplelightbox"; | ||
import "simplelightbox/dist/simple-lightbox.min.css"; | ||
|
||
export let lightbox = new SimpleLightbox('.img_wrap a', { | ||
captionsData: 'alt', | ||
captionDelay: 250, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { refs } from './refs'; | ||
|
||
const { gallery } = refs; | ||
|
||
export function createMarkup(searchResults) { | ||
const arrPhotos = searchResults.map(({ webformatURL, largeImageURL, tags, likes, views, comments, downloads }) => { | ||
return `<div class="photo-card"> | ||
<div class="img_wrap"> | ||
<a class="gallery_link" href="${largeImageURL}"> | ||
<img src="${webformatURL}" alt="${tags}" width="300" loading="lazy" /> | ||
</a> | ||
</div> | ||
<div class="info"> | ||
<p class="info-item"> | ||
<b>Likes: ${likes}</b> | ||
</p> | ||
<p class="info-item"> | ||
<b>Views: ${views}</b> | ||
</p> | ||
<p class="info-item"> | ||
<b>Comments: ${comments}</b> | ||
</p> | ||
<p class="info-item"> | ||
<b>Downloads: ${downloads}</b> | ||
</p> | ||
</div> | ||
</div>` | ||
}); | ||
gallery.insertAdjacentHTML("beforeend", arrPhotos.join('')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import axios from 'axios'; | ||
|
||
const URL = "https://pixabay.com/api/"; | ||
const KEY = "37440122-e5d5a2493910548fa520b3add"; | ||
|
||
export async function fetchPhoto(q, page, perPage) { | ||
const url = `${URL}?key=${KEY}&q=${q}&page=${page}&per_page=${perPage}&image_type=photo&orientation=horizontal&safesearch=true`; | ||
const response = await axios.get(url); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const refs = { | ||
searchForm: document.querySelector('.search-form'), | ||
gallery: document.querySelector('.gallery'), | ||
btnLoadMore: document.querySelector('.load-more'), | ||
}; |