34 lines
718 B
TypeScript
34 lines
718 B
TypeScript
import { Component, ComponentNames } from ".";
|
|
|
|
export class Highlight extends Component {
|
|
public isHighlighted: boolean;
|
|
private onHighlight: Function;
|
|
private onUnhighlight: Function;
|
|
|
|
constructor(
|
|
onHighlight: Function,
|
|
onUnhighlight: Function,
|
|
isHighlighted: boolean = false,
|
|
) {
|
|
super(ComponentNames.Highlight);
|
|
|
|
this.isHighlighted = isHighlighted;
|
|
this.onHighlight = onHighlight;
|
|
this.onUnhighlight = onUnhighlight;
|
|
}
|
|
|
|
public highlight() {
|
|
if (!this.isHighlighted) {
|
|
this.isHighlighted = true;
|
|
this.onHighlight();
|
|
}
|
|
}
|
|
|
|
public unhighlight() {
|
|
if (this.isHighlighted) {
|
|
this.isHighlighted = false;
|
|
this.onUnhighlight();
|
|
}
|
|
}
|
|
}
|