Skip to content

Commit

Permalink
Merge branch 'main' into Favorites-Anatolii
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtanFS committed Oct 22, 2023
2 parents dec564c + e976a01 commit 2ee1574
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
32 changes: 15 additions & 17 deletions src/js/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const refs = {
const { catsList, catFilterList, exercisesTitleSpan, catFilterInput } = refs;

let categoryName = '';
let currentExercise;

catFilterList.addEventListener('click', catFilterBtnHandler);
catFilterInput.addEventListener('input', catInputHandler);
Expand Down Expand Up @@ -69,27 +68,26 @@ function paginationBtnHandler(e) {
.catch(err => console.log(err));
}
async function catsListBtnHandler(e) {
if (e.target.nodeName === 'UL') {
return;
}
try {
const currentExercise = e.target.closest('.categories-item').dataset.bodyPart;
const getExercises = await fetchExercises(categoryName, currentExercise);
catsList.innerHTML = createExercisesMarkup(getExercises);
exercisesTitleSpan.innerHTML = currentExercise;

currentExercise = e.target.closest('.categories-item').dataset.bodyPart;
console.log('Exercise', currentExercise);
const getExercises = await fetchExercises(categoryName, currentExercise);
catFilterInput.hidden = false;

catsList.innerHTML = createExercisesMarkup(getExercises);
const exericesBtns = document.querySelectorAll('[data-modal-exercise="open"]');

exercisesTitleSpan.innerHTML = currentExercise;
catFilterInput.hidden = false;
exericesBtns.forEach(btn => {
btn.addEventListener('click', (event) => {
const exerciseId = event.currentTarget.closest('.exercises-item').dataset.exerciseId;

const openModalBtns = document.querySelectorAll('[data-modal-exercise="open"]').forEach(btn => {
btn.addEventListener('click', (event) => {
const exerciseId = event.currentTarget.closest('.exercises-item').dataset.exerciseId;
console.log(exerciseId);
handleOpenModalClick(event, exerciseId);
handleOpenModalClick(event, exerciseId);
})
})
});

} catch {
err => console.log('Err', err);
}
// const resp = await fetchAllExercises(categoryName, currentExercise);
}

Expand Down
6 changes: 3 additions & 3 deletions src/js/templates/exercises-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ function createMarkup({ rating, name, burnedCalories, bodyPart, target, _id }) {
<p class="exercises-rating">
${rating.toFixed(1)}
<svg width="18" height="18" class="exercises-svg">
<use href="../img/sport-sprite.svg#icon-star"></use>
<use href="../../img/sport-sprite.svg#icon-star"></use>
</svg>
</p>
</div>
<button type="button" class="exercises-btn" data-modal-exercise="open">
Start
<svg width="16" height="16" class="exercises-btn-svg">
<use href="../img/sport-sprite.svg#icon-arrow-up"></use>
<use href="./img/sport-sprite.svg#icon-arrow-up"></use>
</svg>
</button>
</div>
<div class="exercises-name-container">
<span class="exercises-name-span">
<svg width="20" height="20" class="exercises-name-svg">
<use href="../img/sport-sprite.svg#icon-running-stick"></use>
<use href="./img/sport-sprite.svg#icon-running-stick"></use>
</svg>
</span>
<p class="exercises-name">
Expand Down
5 changes: 1 addition & 4 deletions src/partials/catalog.html
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<div class="categories-wrapper">


</div>
<div class="categories-wrapper"></div>

0 comments on commit 2ee1574

Please sign in to comment.