28 lines
846 B
TypeScript
28 lines
846 B
TypeScript
// widgets/BackButtonWidget.ts
|
|
import { Widget } from '../components/Widget';
|
|
import { createElement, navigateTo } from '../utils/utils';
|
|
|
|
export class BackButtonWidget extends Widget {
|
|
private buttonText: string;
|
|
private navigatePath: string;
|
|
|
|
constructor(buttonText: string, navigatePath: string) {
|
|
super();
|
|
this.buttonText = buttonText;
|
|
this.navigatePath = navigatePath;
|
|
}
|
|
|
|
render(): HTMLElement {
|
|
this.container.innerHTML = ''; // Clear previous content
|
|
|
|
const button = createElement('button');
|
|
button.classList.add('btn', 'btn-secondary');
|
|
button.textContent = this.buttonText;
|
|
button.addEventListener('click', () => {
|
|
navigateTo(this.navigatePath);
|
|
});
|
|
|
|
this.container.appendChild(button);
|
|
return this.container;
|
|
}
|
|
} |