styles
This commit is contained in:
+4
-2
@@ -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
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user