Make empty state interactive

This commit is contained in:
Mikayla 2023-08-14 10:34:00 -07:00
parent fde9653ad8
commit b07555b6df
No known key found for this signature in database
3 changed files with 50 additions and 17 deletions

View file

@ -370,7 +370,7 @@ impl CollabPanel {
this.render_channel_editor(&theme, *depth, cx) this.render_channel_editor(&theme, *depth, cx)
} }
ListEntry::ContactPlaceholder => { ListEntry::ContactPlaceholder => {
this.render_contact_placeholder(&theme.collab_panel) this.render_contact_placeholder(&theme.collab_panel, is_selected, cx)
} }
} }
}); });
@ -1402,13 +1402,23 @@ impl CollabPanel {
event_handler.into_any() event_handler.into_any()
} }
fn render_contact_placeholder(&self, theme: &theme::CollabPanel) -> AnyElement<Self> { fn render_contact_placeholder(
Label::new( &self,
"Add contacts to begin collaborating", theme: &theme::CollabPanel,
theme.placeholder.text.clone(), is_selected: bool,
) cx: &mut ViewContext<Self>,
.contained() ) -> AnyElement<Self> {
.with_style(theme.placeholder.container) enum AddContacts {}
MouseEventHandler::<AddContacts, Self>::new(0, cx, |state, _| {
let style = theme.list_empty_state.style_for(is_selected, state);
Label::new("Add contacts to begin collaborating", style.text.clone())
.contained()
.with_style(style.container)
.into_any()
})
.on_click(MouseButton::Left, |_, this, cx| {
this.toggle_contact_finder(cx);
})
.into_any() .into_any()
} }
@ -1861,6 +1871,7 @@ impl CollabPanel {
ListEntry::Channel(channel) => { ListEntry::Channel(channel) => {
self.join_channel(channel.id, cx); self.join_channel(channel.id, cx);
} }
ListEntry::ContactPlaceholder => self.toggle_contact_finder(cx),
_ => {} _ => {}
} }
} }

View file

@ -220,7 +220,7 @@ pub struct CopilotAuthAuthorized {
pub struct CollabPanel { pub struct CollabPanel {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
pub placeholder: ContainedText, pub list_empty_state: Toggleable<Interactive<ContainedText>>,
pub log_in_button: Interactive<ContainedText>, pub log_in_button: Interactive<ContainedText>,
pub channel_editor: ContainerStyle, pub channel_editor: ContainerStyle,
pub channel_hash: Icon, pub channel_hash: Icon,

View file

@ -110,10 +110,6 @@ export default function contacts_panel(): any {
return { return {
channel_modal: channel_modal(), channel_modal: channel_modal(),
placeholder: {
...text(theme.middle, "sans", "default", { size: "sm" }),
padding: 5,
},
log_in_button: interactive({ log_in_button: interactive({
base: { base: {
background: background(theme.middle), background: background(theme.middle),
@ -273,10 +269,36 @@ export default function contacts_panel(): any {
}, },
}, },
}), }),
list_empty_state: { list_empty_state: toggleable({
...text(layer, "ui_sans", "variant", { size: "sm" }), base: interactive({
padding: side_padding base: {
}, ...text(layer, "ui_sans", "variant", { size: "sm" }),
padding: side_padding
},
state: {
clicked: {
background: background(layer, "pressed"),
},
},
}),
state: {
inactive: {
hovered: {
background: background(layer, "hovered"),
},
},
active: {
default: {
...text(layer, "ui_sans", "active", { size: "sm" }),
background: background(layer, "active"),
},
clicked: {
background: background(layer, "pressed"),
},
},
},
}),
contact_avatar: { contact_avatar: {
corner_radius: 10, corner_radius: 10,
width: 18, width: 18,