-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from ViktorSvertoka/modal-exercise
Refactor(IMG, CSS, JS) Add a stub for the picture and fixed modal window closing
- Loading branch information
Showing
4 changed files
with
17 additions
and
34 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -63,7 +63,6 @@ function createRating(rating) { | |
}, | ||
]; | ||
|
||
// Генерація linearGradient | ||
const linearGradient = ` | ||
<linearGradient id="${gradientId}" x1="0%" y1="0%" x2="100%" y2="0%"> | ||
${gradientStops | ||
|
@@ -105,8 +104,8 @@ function createMarkup({ | |
const getExerciseGif = getGif(gifUrl); | ||
function getGif(gifUrl) { | ||
if (gifUrl === null || !gifUrl) { | ||
return; | ||
// Треба заглушку | ||
return `srcset = './img/modal-exercise-image.jpg 1x,./img/[email protected] 2x' | ||
src = './img/modal-exercise-image.jpg'`; | ||
} | ||
return `src="${gifUrl}"`; | ||
} | ||
|
@@ -115,14 +114,14 @@ function createMarkup({ | |
<div class="modal-exercises__container" data-id="${_id}"> | ||
<button class="modal-exercises__btn-close"> | ||
<svg width="24" height="24"> | ||
<use href="./img/sprite.svg#icon-menu-mobile-close"></use> | ||
<use href="/img/sprite.svg#icon-menu-mobile-close"></use> | ||
</svg> | ||
</button> | ||
<img | ||
class="modal-exercises__img" | ||
${getExerciseGif} | ||
alt="Exercise video" | ||
alt="Exercise image" | ||
loading="lazy" | ||
/> | ||
|
@@ -164,7 +163,7 @@ function createMarkup({ | |
<button class="modal-exercises__btn-favorites modal-exercises__btn" data-id="${_id}"> | ||
Add to favorites | ||
<svg class="btn-favorites__icon"> | ||
<use href="./img/sprite.svg#icon-favorites"></use> | ||
<use href="/img/sprite.svg#icon-favorites"></use> | ||
</svg> | ||
</button> | ||
<button class="modal-exercises__btn-rating modal-exercises__btn">Give a rating</button> | ||
|
@@ -181,7 +180,11 @@ function closeModalExercises() { | |
document.body.style.overflow = 'auto'; | ||
} | ||
|
||
overlay.addEventListener('click', closeModalExercises); | ||
overlay.addEventListener('click', function (event) { | ||
if (event.target === overlay) { | ||
closeModalExercises(); | ||
} | ||
}); | ||
window.addEventListener('keydown', function (event) { | ||
if (event.key === 'Escape' && !modalExercises.classList.contains('hidden')) { | ||
closeModalExercises(); | ||
|