@teaui/core
Version:
A high-level terminal UI library for Node
40 lines • 1.09 kB
JavaScript
import { Style } from '../Style.js';
import { View } from '../View.js';
import { Size } from '../geometry.js';
export class Space extends View {
static horizontal(value, extraProps = {}) {
return new Space({ width: value, ...extraProps });
}
static vertical(value, extraProps = {}) {
return new Space({ height: value, ...extraProps });
}
constructor(props = {}) {
super(props);
this.#update(props);
}
update(props) {
this.#update(props);
super.update(props);
}
#update({ background }) {
this.background = background;
}
naturalSize(_available) {
return Size.zero;
}
#prev = this.background;
render(viewport) {
if (viewport.isEmpty) {
return;
}
if (!this.background) {
return;
}
if (this.#prev !== this.background) {
this.#prev = this.background;
}
const style = new Style({ background: this.background });
viewport.paint(style);
}
}
//# sourceMappingURL=Space.js.map