mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 15:14:27 +00:00
feat(block): add Block::bordered
(#736)
This avoid creating a block with no borders and then settings Borders::ALL. i.e. ```diff - Block::default().borders(Borders::ALL); + Block::bordered(); ```
This commit is contained in:
parent
98bcf1c0a5
commit
23f6938498
1 changed files with 13 additions and 0 deletions
|
@ -267,6 +267,13 @@ impl<'a> Block<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new block with [all borders](Borders::ALL) shown
|
||||||
|
pub const fn bordered() -> Self {
|
||||||
|
let mut block = Block::new();
|
||||||
|
block.borders = Borders::ALL;
|
||||||
|
block
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds a title to the block.
|
/// Adds a title to the block.
|
||||||
///
|
///
|
||||||
/// The `title` function allows you to add a title to the block. You can call this function
|
/// The `title` function allows you to add a title to the block. You can call this function
|
||||||
|
@ -820,6 +827,12 @@ mod tests {
|
||||||
style::{Color, Modifier, Stylize},
|
style::{Color, Modifier, Stylize},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn create_with_all_borders() {
|
||||||
|
let block = Block::bordered();
|
||||||
|
assert_eq!(block.borders, Borders::all());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inner_takes_into_account_the_borders() {
|
fn inner_takes_into_account_the_borders() {
|
||||||
// No borders
|
// No borders
|
||||||
|
|
Loading…
Reference in a new issue