This commit is contained in:
2024-10-20 22:00:09 +02:00
parent 73bac7450a
commit 9247cddf98
2 changed files with 17 additions and 3 deletions
+4 -2
View File
@@ -106,6 +106,8 @@ pub fn text() -> Component {
pub fn button() -> Component { pub fn button() -> Component {
let mut component = Component::new(); let mut component = Component::new();
component.style.hover_fg = crate::style::Color::Blue;
fn update(this: &mut Component, k: key::Key) -> UpdateResponse { fn update(this: &mut Component, k: key::Key) -> UpdateResponse {
if k.kind == KeyKind::Enter { if k.kind == KeyKind::Enter {
if this.toggle { if this.toggle {
@@ -128,8 +130,8 @@ pub fn button() -> Component {
} }
} }
fn render(s: &mut Component) -> String { fn render(this: &mut Component) -> String {
s.expr.clone() this.style.clone().write(&this.expr)
} }
component.update = update; component.update = update;
+13 -1
View File
@@ -43,7 +43,19 @@ impl Style {
} }
pub fn get_outline(self) -> String { pub fn get_outline(self) -> String {
String::from(self.fg.ansi() + &self.bg.ansi_bg() + &self.font.ansi()) if self.is_active {
self.outline.prioritize(self.hover_outline).ansi()
} else {
self.outline.ansi()
}
}
pub fn write(self, s: &str) -> String {
format!("{}{}", self.get(), s)
}
pub fn write_outline(self, s: &str) -> String {
format!("{}{}", self.get_outline(), s)
} }
} }