kibodo
Version:
Keyboard-only frontend framework
36 lines (28 loc) • 728 B
text/typescript
import View from "./view";
class TextView extends View {
lines: string[];
constructor(content: string[] = []) {
super();
this.lines = content;
}
renderContent() {
const text = document.createElement('div');
text.className = 'text';
this.lines.forEach(line => {
const lineElement = document.createElement('div');
lineElement.textContent = line;
text.appendChild(lineElement);
});
return text;
}
addLine(line: string): void {
this.lines.push(line);
}
onDown(): void {
window.scrollBy(0, 10);
}
onUp(): void {
window.scrollBy(0, -10);
}
}
export default TextView;