mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Border to props
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
// ext
|
// ext
|
||||||
use tui::style::{Color, Modifier};
|
use tui::style::{Color, Modifier};
|
||||||
|
use tui::widgets::Borders;
|
||||||
|
|
||||||
// -- Props
|
// -- Props
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ pub struct Props {
|
|||||||
pub visible: bool, // Is the element visible ON CREATE?
|
pub visible: bool, // Is the element visible ON CREATE?
|
||||||
pub foreground: Color, // Foreground color
|
pub foreground: Color, // Foreground color
|
||||||
pub background: Color, // Background color
|
pub background: Color, // Background color
|
||||||
|
pub borders: Borders, // Borders
|
||||||
pub bold: bool, // Text bold
|
pub bold: bool, // Text bold
|
||||||
pub italic: bool, // Italic
|
pub italic: bool, // Italic
|
||||||
pub underlined: bool, // Underlined
|
pub underlined: bool, // Underlined
|
||||||
@@ -53,6 +55,7 @@ impl Default for Props {
|
|||||||
visible: true,
|
visible: true,
|
||||||
foreground: Color::Reset,
|
foreground: Color::Reset,
|
||||||
background: Color::Reset,
|
background: Color::Reset,
|
||||||
|
borders: Borders::ALL,
|
||||||
bold: false,
|
bold: false,
|
||||||
italic: false,
|
italic: false,
|
||||||
underlined: false,
|
underlined: false,
|
||||||
@@ -144,6 +147,16 @@ impl PropsBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### with_borders
|
||||||
|
///
|
||||||
|
/// Set component borders style
|
||||||
|
pub fn with_borders(&mut self, borders: Borders) -> &mut Self {
|
||||||
|
if let Some(props) = self.props.as_mut() {
|
||||||
|
props.borders = borders;
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// ### bold
|
/// ### bold
|
||||||
///
|
///
|
||||||
/// Set bold property for component
|
/// Set bold property for component
|
||||||
@@ -491,6 +504,7 @@ mod tests {
|
|||||||
assert_eq!(props.visible, true);
|
assert_eq!(props.visible, true);
|
||||||
assert_eq!(props.background, Color::Reset);
|
assert_eq!(props.background, Color::Reset);
|
||||||
assert_eq!(props.foreground, Color::Reset);
|
assert_eq!(props.foreground, Color::Reset);
|
||||||
|
assert_eq!(props.borders, Borders::ALL);
|
||||||
assert_eq!(props.bold, false);
|
assert_eq!(props.bold, false);
|
||||||
assert_eq!(props.italic, false);
|
assert_eq!(props.italic, false);
|
||||||
assert_eq!(props.underlined, false);
|
assert_eq!(props.underlined, false);
|
||||||
@@ -518,6 +532,7 @@ mod tests {
|
|||||||
.hidden()
|
.hidden()
|
||||||
.with_background(Color::Blue)
|
.with_background(Color::Blue)
|
||||||
.with_foreground(Color::Green)
|
.with_foreground(Color::Green)
|
||||||
|
.with_borders(Borders::BOTTOM)
|
||||||
.bold()
|
.bold()
|
||||||
.italic()
|
.italic()
|
||||||
.underlined()
|
.underlined()
|
||||||
@@ -530,6 +545,7 @@ mod tests {
|
|||||||
.with_value(PropValue::Str(String::from("Hello")))
|
.with_value(PropValue::Str(String::from("Hello")))
|
||||||
.build();
|
.build();
|
||||||
assert_eq!(props.background, Color::Blue);
|
assert_eq!(props.background, Color::Blue);
|
||||||
|
assert_eq!(props.borders, Borders::BOTTOM);
|
||||||
assert_eq!(props.bold, true);
|
assert_eq!(props.bold, true);
|
||||||
assert_eq!(props.foreground, Color::Green);
|
assert_eq!(props.foreground, Color::Green);
|
||||||
assert_eq!(props.italic, true);
|
assert_eq!(props.italic, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user