Added stimulus and turbo. Added first controller to close sidebar.
This commit is contained in:
15
assets/controllers/closable_controller.js
Normal file
15
assets/controllers/closable_controller.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
async close(){
|
||||
this.element.style.width = '0';
|
||||
await this.#waitForAnimation();
|
||||
this.element.remove();
|
||||
}
|
||||
|
||||
#waitForAnimation() {
|
||||
return Promise.all(
|
||||
this.element.getAnimations().map((animation) => animation.finished),
|
||||
);
|
||||
}
|
||||
}
|
||||
16
assets/controllers/hello_controller.js
Normal file
16
assets/controllers/hello_controller.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
/*
|
||||
* This is an example Stimulus controller!
|
||||
*
|
||||
* Any element with a data-controller="hello" attribute will cause
|
||||
* this controller to be executed. The name "hello" comes from the filename:
|
||||
* hello_controller.js -> "hello"
|
||||
*
|
||||
* Delete this file or adapt it for your use!
|
||||
*/
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user