refactor(block): group builder pattern methods (#1134)

This commit is contained in:
EdJoPaTo 2024-05-25 03:04:35 +02:00 committed by GitHub
parent 1de9a82b7a
commit 73fd367a74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -469,6 +469,38 @@ impl<'a> Block<'a> {
self
}
/// Defines the padding inside a `Block`.
///
/// See [`Padding`] for more information.
///
/// # Examples
///
/// This renders a `Block` with no padding (the default).
/// ```
/// # use ratatui::{prelude::*, widgets::*};
/// Block::bordered().padding(Padding::zero());
/// // Renders
/// // ┌───────┐
/// // │content│
/// // └───────┘
/// ```
///
/// This example shows a `Block` with padding left and right ([`Padding::horizontal`]).
/// Notice the two spaces before and after the content.
/// ```
/// # use ratatui::{prelude::*, widgets::*};
/// Block::bordered().padding(Padding::horizontal(2));
/// // Renders
/// // ┌───────────┐
/// // │ content │
/// // └───────────┘
/// ```
#[must_use = "method moves the value of self and returns the modified value"]
pub const fn padding(mut self, padding: Padding) -> Self {
self.padding = padding;
self
}
/// Compute the inner area of a block based on its border visibility rules.
///
/// # Examples
@ -529,38 +561,6 @@ impl<'a> Block<'a> {
.iter()
.any(|title| title.position.unwrap_or(self.titles_position) == position)
}
/// Defines the padding inside a `Block`.
///
/// See [`Padding`] for more information.
///
/// # Examples
///
/// This renders a `Block` with no padding (the default).
/// ```
/// # use ratatui::{prelude::*, widgets::*};
/// Block::bordered().padding(Padding::zero());
/// // Renders
/// // ┌───────┐
/// // │content│
/// // └───────┘
/// ```
///
/// This example shows a `Block` with padding left and right ([`Padding::horizontal`]).
/// Notice the two spaces before and after the content.
/// ```
/// # use ratatui::{prelude::*, widgets::*};
/// Block::bordered().padding(Padding::horizontal(2));
/// // Renders
/// // ┌───────────┐
/// // │ content │
/// // └───────────┘
/// ```
#[must_use = "method moves the value of self and returns the modified value"]
pub const fn padding(mut self, padding: Padding) -> Self {
self.padding = padding;
self
}
}
impl BorderType {