2024-12-22 16:52:01 -08:00
|
|
|
import { addStyle } from "./document";
|
2024-12-22 14:59:03 -08:00
|
|
|
import { ElemWrapper } from "./elemwrapper";
|
|
|
|
|
import { SingleTimer } from "./singletimer";
|
|
|
|
|
|
|
|
|
|
export class Highlighter {
|
|
|
|
|
private elem: ElemWrapper;
|
|
|
|
|
private timer: SingleTimer;
|
|
|
|
|
|
|
|
|
|
constructor(elem: ElemWrapper) {
|
|
|
|
|
this.elem = elem;
|
|
|
|
|
this.elem.classList.add("preHighlight");
|
|
|
|
|
|
|
|
|
|
this.timer = new SingleTimer(() => {
|
|
|
|
|
this.elem.classList.remove("highlight");
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public highlight() {
|
|
|
|
|
this.elem.classList.add("highlight");
|
|
|
|
|
this.timer.start();
|
|
|
|
|
}
|
2024-12-22 15:05:12 -08:00
|
|
|
}
|
|
|
|
|
|
2024-12-22 16:52:01 -08:00
|
|
|
addStyle(`
|
2024-12-22 15:05:12 -08:00
|
|
|
.preHighlight {
|
|
|
|
|
transition: color 0.3s ease-out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.highlight {
|
|
|
|
|
color: var(--sl-color-primary-600);
|
|
|
|
|
transition: color 0.1s ease-in;
|
|
|
|
|
}
|
2024-12-22 16:52:01 -08:00
|
|
|
`);
|