Almost kinda functional description box
This commit is contained in:
+35
-9
@@ -50,37 +50,63 @@ pub fn vertical_chunks_with_margin(
|
||||
}
|
||||
|
||||
pub fn layout_block(title_span: Span<'_>) -> Block<'_> {
|
||||
Block::default().borders(Borders::ALL).title(title_span)
|
||||
Block::default().borders(Borders::ALL).title(title_span)
|
||||
}
|
||||
|
||||
pub fn style_bold() -> Style {
|
||||
Style::default().add_modifier(Modifier::BOLD)
|
||||
Style::default().add_modifier(Modifier::BOLD)
|
||||
}
|
||||
|
||||
pub fn style_highlight() -> Style {
|
||||
Style::default().add_modifier(Modifier::REVERSED)
|
||||
Style::default().add_modifier(Modifier::REVERSED)
|
||||
}
|
||||
|
||||
pub fn style_default() -> Style {
|
||||
Style::default().fg(Color::White)
|
||||
Style::default().fg(Color::White)
|
||||
}
|
||||
|
||||
pub fn style_primary() -> Style {
|
||||
Style::default().fg(Color::Green)
|
||||
Style::default().fg(Color::Green)
|
||||
}
|
||||
|
||||
pub fn style_secondary() -> Style {
|
||||
Style::default().fg(Color::Magenta)
|
||||
Style::default().fg(Color::Magenta)
|
||||
}
|
||||
|
||||
pub fn style_tertiary() -> Style {
|
||||
Style::default().fg(Color::Red)
|
||||
Style::default().fg(Color::Red)
|
||||
}
|
||||
|
||||
pub fn title_style(title: &str) -> Span<'_> {
|
||||
Span::styled(title, style_bold())
|
||||
Span::styled(title, style_bold())
|
||||
}
|
||||
|
||||
pub fn title_block(title: &str) -> Block<'_> {
|
||||
layout_block(title_style(title))
|
||||
layout_block(title_style(title))
|
||||
}
|
||||
|
||||
pub fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
|
||||
let popup_layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
Constraint::Percentage(percent_y),
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(r);
|
||||
|
||||
Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Percentage((100 - percent_x) / 2),
|
||||
Constraint::Percentage(percent_x),
|
||||
Constraint::Percentage((100 - percent_x) / 2),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(popup_layout[1])[1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user