Skip to content

Commit

Permalink
Merge pull request #26 from moevm/bogdanov_stepper
Browse files Browse the repository at this point in the history
update stepper
  • Loading branch information
necitboss authored Dec 11, 2024
2 parents 9c52912 + d74f936 commit aacb52d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion main/_front/src/html/elems/stepper.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="container">
<div>Минимальное значение везде 1. Максимальное значение задается в data-max</div>
<div>Минимальное значение: 1; максимальное: 10</div>
<div class="stepper" data-max="10">
<div class="stepper" data-max="10" id="type">
<button class="stepper__minus">
<svg width="39.000000" height="39.000000" viewBox="0 0 39 39" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip25_442)">
Expand Down Expand Up @@ -53,6 +53,7 @@
</button>
</div>
</div>
<button class="btn" style="margin-top: 20px; margin-left: 300px; margin-bottom: 30px;" id="change_parameter">Изменить параметр</button>
</div>
</body>
</html>
30 changes: 29 additions & 1 deletion main/_front/src/js/elems/stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,32 @@ steppers.forEach(stepper => {
}
}
})
})
})

const stepperChange = (item, value) => {
const minus_btn = item.querySelector('.stepper__minus');
const plus_btn = item.querySelector('.stepper__plus');
const stepper_value = item.querySelector('.stepper__value');

const max = item.dataset.max;
stepper_value.textContent = value;

if (checkMinDisabled(stepper_value)){
minus_btn.disabled = true;
stepper_value.textContent = "1";
}else {
minus_btn.disabled = false;
}
if (checkMaxDisabled(stepper_value, max)){
plus_btn.disabled = true;
stepper_value.textContent = max;
}else {
plus_btn.disabled = false;
}
}

const change_parameter = document.querySelector("#change_parameter");
console.log(change_parameter);
change_parameter.addEventListener("click", (e) => {
stepperChange(document.querySelector("#type"), 10);
})

0 comments on commit aacb52d

Please sign in to comment.