Skip to main content

photon_ui/components/
spacer.rs

1use crate::{
2    Component,
3    RenderError,
4    Rendered,
5};
6
7/// A component that renders empty lines for layout spacing.
8pub struct Spacer {
9    lines: usize,
10}
11
12impl Spacer {
13    /// Create a spacer that renders `lines` empty rows.
14    pub fn new(lines: usize) -> Self {
15        Self { lines }
16    }
17}
18
19impl Component for Spacer {
20    fn render(&self, _width: u16) -> Result<Rendered, RenderError> {
21        Ok(Rendered {
22            lines: vec!["".to_string(); self.lines],
23            cursor: None,
24            images: Vec::new(),
25        })
26    }
27}