mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-06 23:44:36 +00:00
24 lines
835 B
TypeScript
24 lines
835 B
TypeScript
import { Stack, type StackChild, type StackOptions, visibleStackEntries } from "./stack.ts";
|
|
|
|
export class VStack extends Stack {
|
|
protected readonly layoutType = "vstack" as const;
|
|
|
|
constructor(children: StackChild[] = [], options: StackOptions = {}) {
|
|
super(children, options);
|
|
}
|
|
|
|
override render(width: number): string[] {
|
|
const viewport = { width: Math.max(1, width), height: Number.MAX_SAFE_INTEGER };
|
|
const entries = visibleStackEntries(this.entries, viewport);
|
|
const lines: string[] = [];
|
|
for (let index = 0; index < entries.length; index++) {
|
|
if (index > 0) {
|
|
for (let gap = 0; gap < this.gap; gap++) lines.push("");
|
|
}
|
|
lines.push(...entries[index]!.component.render(viewport.width));
|
|
}
|
|
return lines;
|
|
}
|
|
}
|
|
|
|
export type { StackChild, StackEntry, StackEntryOptions, StackOptions } from "./stack.ts";
|