Add Stimulus controller for collapse functionality
This commit is contained in:
parent
3258ea4f0b
commit
46830f50cd
|
@ -0,0 +1,16 @@
|
|||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['action', 'content'];
|
||||
|
||||
declare readonly contentTarget: HTMLElement;
|
||||
declare readonly actionTarget: HTMLElement;
|
||||
|
||||
connect(): void {
|
||||
this.actionTarget.addEventListener('click', this.update.bind(this));
|
||||
}
|
||||
|
||||
update(): void {
|
||||
this.contentTarget.classList.toggle('collapsed');
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import AutofocusController from "retrospring/controllers/autofocus_controller";
|
|||
import CharacterCountController from "retrospring/controllers/character_count_controller";
|
||||
import CharacterCountWarningController from "retrospring/controllers/character_count_warning_controller";
|
||||
import FormatPopupController from "retrospring/controllers/format_popup_controller";
|
||||
import CollapseController from "retrospring/controllers/collapse_controller";
|
||||
|
||||
/**
|
||||
* This module sets up Stimulus and our controllers
|
||||
|
@ -18,5 +19,6 @@ export default function (): void {
|
|||
window['Stimulus'].register('autofocus', AutofocusController);
|
||||
window['Stimulus'].register('character-count', CharacterCountController);
|
||||
window['Stimulus'].register('character-count-warning', CharacterCountWarningController);
|
||||
window['Stimulus'].register('collapse', CollapseController);
|
||||
window['Stimulus'].register('format-popup', FormatPopupController);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue