Add empty state for project panel (#3863)
This PR adds an empty state for the project panel. It will now display an "Open a project" button. Release Notes: - Added an empty state for the project panel.
This commit is contained in:
parent
94536ba24a
commit
7f6770d272
2 changed files with 34 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
use gpui::{AnyView, DefiniteLength};
|
||||
|
||||
use crate::{prelude::*, IconPosition};
|
||||
use crate::{prelude::*, IconPosition, KeyBinding};
|
||||
use crate::{
|
||||
ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Icon, IconSize, Label, LineHeightStyle,
|
||||
};
|
||||
|
@ -19,6 +19,7 @@ pub struct Button {
|
|||
icon_size: Option<IconSize>,
|
||||
icon_color: Option<Color>,
|
||||
selected_icon: Option<Icon>,
|
||||
key_binding: Option<KeyBinding>,
|
||||
}
|
||||
|
||||
impl Button {
|
||||
|
@ -34,6 +35,7 @@ impl Button {
|
|||
icon_size: None,
|
||||
icon_color: None,
|
||||
selected_icon: None,
|
||||
key_binding: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +78,11 @@ impl Button {
|
|||
self.selected_icon = icon.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn key_binding(mut self, key_binding: impl Into<Option<KeyBinding>>) -> Self {
|
||||
self.key_binding = key_binding.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Selectable for Button {
|
||||
|
@ -157,7 +164,7 @@ impl RenderOnce for Button {
|
|||
self.base.child(
|
||||
h_stack()
|
||||
.gap_1()
|
||||
.when(self.icon_position.is_some(), |this| {
|
||||
.when(self.icon_position == Some(IconPosition::Start), |this| {
|
||||
this.children(self.icon.map(|icon| {
|
||||
ButtonIcon::new(icon)
|
||||
.disabled(is_disabled)
|
||||
|
@ -168,12 +175,18 @@ impl RenderOnce for Button {
|
|||
}))
|
||||
})
|
||||
.child(
|
||||
Label::new(label)
|
||||
.color(label_color)
|
||||
.size(self.label_size.unwrap_or_default())
|
||||
.line_height_style(LineHeightStyle::UiLabel),
|
||||
h_stack()
|
||||
.gap_2()
|
||||
.justify_between()
|
||||
.child(
|
||||
Label::new(label)
|
||||
.color(label_color)
|
||||
.size(self.label_size.unwrap_or_default())
|
||||
.line_height_style(LineHeightStyle::UiLabel),
|
||||
)
|
||||
.children(self.key_binding),
|
||||
)
|
||||
.when(!self.icon_position.is_some(), |this| {
|
||||
.when(self.icon_position != Some(IconPosition::Start), |this| {
|
||||
this.children(self.icon.map(|icon| {
|
||||
ButtonIcon::new(icon)
|
||||
.disabled(is_disabled)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue