wip: connect to github

This commit is contained in:
2026-04-24 19:22:25 +01:00
parent b327648d31
commit a9f4d1d923
11 changed files with 587 additions and 146 deletions

View File

@@ -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))
}
}