Donovan Daniels
b1c702e3cd
poorly tested but it worked well enough, I'm sure I'll be patching bugs over the next few weeks Also remove turbo because it sucks Also changed the way we handle hosts in dev
24 lines
548 B
TypeScript
24 lines
548 B
TypeScript
import { Controller } from "@hotwired/stimulus";
|
|
|
|
export default class extends Controller {
|
|
static override targets = ["notice"];
|
|
declare noticeTarget: HTMLElement;
|
|
timeout: number | undefined;
|
|
|
|
// automatically close
|
|
override connect() {
|
|
this.timeout = setTimeout(() => this._close(), 3500);
|
|
}
|
|
|
|
_close() {
|
|
$(this.noticeTarget).fadeOut("fast");
|
|
}
|
|
|
|
close(event: KeyboardEvent) {
|
|
if (this.timeout) {
|
|
clearTimeout(this.timeout);
|
|
}
|
|
event.preventDefault();
|
|
}
|
|
}
|