Move all files to stimulus-esbuild/
This commit is contained in:
parent
4c850b3b40
commit
7588eb0c98
14 changed files with 0 additions and 0 deletions
45
stimulus-esbuild/assets/js/controllers/count_controller.js
Normal file
45
stimulus-esbuild/assets/js/controllers/count_controller.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["result"];
|
||||
|
||||
static values = {
|
||||
canBeNegative: Boolean,
|
||||
count: Number,
|
||||
maximumCountNumber: Number,
|
||||
};
|
||||
|
||||
connect() {
|
||||
console.log("count#connect");
|
||||
|
||||
this.resultTarget.textContent = this.countValue;
|
||||
}
|
||||
|
||||
countValueChanged() {
|
||||
console.log("count#countValueChanged");
|
||||
|
||||
this.resultTarget.textContent = this.countValue;
|
||||
}
|
||||
|
||||
decrement() {
|
||||
console.log("count#decrement");
|
||||
|
||||
if (this.canBeNegativeValue === false && this.countValue === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.countValue = this.countValue - 1;
|
||||
}
|
||||
|
||||
increment() {
|
||||
console.log("count#increment");
|
||||
|
||||
const maximumCountNumber = this.maximumCountNumberValue || 10;
|
||||
|
||||
if (this.countValue === maximumCountNumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.countValue = this.countValue + 1;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue