Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka committed Dec 16, 2023
1 parent d119173 commit 666f980
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/favorites.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<load ="partials/09-loader.html" />
</footer>

<script type="module" src="./main.js"></script>
<script type="module" src="./js/01-mobile-menu.js"></script>
<script type="module" src="./js/10-favorites.js"></script>
<script type="module" src="./js/14-added-local.js"></script>
<script type="module" src="./js/15-remove-local.js"></script>
Expand Down
2 changes: 2 additions & 0 deletions src/js/05-modal-exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const overlay = document.querySelector('.overlay');
const listItem = document.querySelector('.js-list');

listItem.addEventListener('click', onExercisesCardClick);
console.log(listItem);

async function onExercisesCardClick(event) {
if (!event.target.closest('.card__btn')) {
Expand Down Expand Up @@ -188,6 +189,7 @@ overlay.addEventListener('click', function (event) {
closeModalExercises();
}
});

window.addEventListener('keydown', function (event) {
if (event.key === 'Escape' && !modalExercises.classList.contains('hidden')) {
closeModalExercises();
Expand Down
11 changes: 11 additions & 0 deletions src/js/12-exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ function renderExercises(data) {

listItem.insertAdjacentHTML('beforeend', markup);
}

document.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.exercises__btn');

buttons.forEach(button => {
button.addEventListener('click', () => {
buttons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
});
});
});
50 changes: 27 additions & 23 deletions src/js/15-remove-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,36 @@ function createMarkup(newLocal) {
const markup = newLocal
.map(({ _id, name, burnedCalories, bodyPart, target }) => {
return `
<li class="filters__item-card">
<div class="card__wrap">
<div class="card__block-btn">
<p class="card__badge">Workout</p>
<button class="card__btn" id="remove" data-id="${_id}" type="button">Remove
<svg class="card__btn-arrow" width="16" height="16">
<use href="${icons}#icon-arrow-menu-mobile"></use>
</svg>
</button>
<button class="card__btn" data-id="${_id}" type="button">Start
<svg class="card__btn-arrow" width="16" height="16">
<use href="${icons}#icon-arrow-menu-mobile"></use>
<li class="fav-filters__item-card">
<div class="fav-card__wrap">
<div class="fav-card__block-btn">
<div class="fav-card__trash-btn-wrap">
<p class="fav-card__badge">Workout</p>
<button class="fav-card__btn js-remove-btn" data-id="${_id}" type="button">
<svg class="fav-card__btn-trash-svg" width="16" height="16">
<use href="${icons}#icon-trash"></use>
</svg>
</button>
</div>
<div class="card__wrap-title">
<svg class="card__title-svg" width="24" height="24">
<use href="${icons}#icon-running-stick-figure"></use>
</svg>
<h2 class="card__title">${name}</h2>
</div>
<div class="card__block-info">
<p class="card__text-info"><span>Burned calories:</span>${burnedCalories}</p>
<p class="card__text-info"><span>Body part:</span>${bodyPart}</p>
<p class="card__text-info"><span>Target:</span>${target}</p>
</div>
<button class="fav-card__btn-start" data-id="${_id}" type="button">Start
<svg class="fav-card__btn-start-svg" width="16" height="16">
<use href="${icons}#icon-arrow"></use>
</svg>
</button>
</div>
<div class="fav-card__title-wrap">
<svg class="fav-card__title-svg" width="24" height="24">
<use href="${icons}#icon-running-stick-figure"></use>
</svg>
<h2 class="fav-card__title">${name}</h2>
</div>
<div class="fav-card__block-info">
<p class="fav-card__text-info"><span>Burned calories:</span>${burnedCalories}</p>
<p class="fav-card__text-info"><span>Body part:</span>${bodyPart}</p>
<p class="fav-card__text-info"><span>Target:</span>${target}</p>
</div>
</div>
</li>`;
})
Expand Down
13 changes: 0 additions & 13 deletions src/partials/03-exercises.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,4 @@ <h4 class="aside__white-card-subtitle">Daily norm of sports</h4>
<ul class="filters__list js-list"></ul>
</div>
</div>

<script>
document.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.exercises__btn');

buttons.forEach(button => {
button.addEventListener('click', () => {
buttons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
});
});
});
</script>
</section>

0 comments on commit 666f980

Please sign in to comment.