wip: connect to github
This commit is contained in:
@@ -3,7 +3,7 @@ use gpui::{
|
||||
StatefulInteractiveElement, Styled, div, prelude::FluentBuilder,
|
||||
};
|
||||
|
||||
use crate::{app, component::text::TextContent, theme};
|
||||
use crate::{app, component::text::TextContent};
|
||||
|
||||
#[derive(gpui::IntoElement)]
|
||||
pub struct Button {
|
||||
@@ -12,6 +12,7 @@ pub struct Button {
|
||||
leading: Option<gpui::Svg>,
|
||||
trailing: Option<gpui::Svg>,
|
||||
on_click: Option<Box<dyn Fn(&gpui::ClickEvent, &mut gpui::Window, &mut gpui::App)>>,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
pub fn button(id: impl Into<gpui::ElementId>) -> Button {
|
||||
@@ -21,6 +22,7 @@ pub fn button(id: impl Into<gpui::ElementId>) -> Button {
|
||||
leading: None,
|
||||
trailing: None,
|
||||
on_click: None,
|
||||
enabled: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +49,11 @@ impl Button {
|
||||
self.on_click = Some(Box::new(f));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn disabled(mut self) -> Self {
|
||||
self.enabled = false;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl gpui::RenderOnce for Button {
|
||||
@@ -86,8 +93,9 @@ impl gpui::RenderOnce for Button {
|
||||
.px_2p5()
|
||||
.py_0p5()
|
||||
.children(children)
|
||||
.when(self.on_click.is_some(), |div| {
|
||||
.when(self.on_click.is_some() && self.enabled, |div| {
|
||||
div.on_click(self.on_click.unwrap())
|
||||
})
|
||||
.when(!self.enabled, |div| div.opacity(0.5))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user