Version 1.0 upload
This commit is contained in:
28
src/widgets/BackButtonWidget.ts
Normal file
28
src/widgets/BackButtonWidget.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user