Style the chat panel further

This commit is contained in:
Max Brunsfeld 2023-09-14 17:19:08 -07:00
parent 59269d422b
commit dd7c687041
4 changed files with 46 additions and 21 deletions

View file

@ -97,7 +97,7 @@ impl ChatPanel {
.with_style(move |cx| { .with_style(move |cx| {
let style = &theme::current(cx).chat_panel.channel_select; let style = &theme::current(cx).chat_panel.channel_select;
SelectStyle { SelectStyle {
header: style.header.container, header: Default::default(),
menu: style.menu, menu: style.menu,
} }
}) })
@ -269,14 +269,17 @@ impl ChatPanel {
.contained() .contained()
.with_style(theme.chat_panel.channel_select.container), .with_style(theme.chat_panel.channel_select.container),
) )
.with_child(self.render_active_channel_messages()) .with_child(self.render_active_channel_messages(&theme))
.with_child(self.render_input_box(&theme, cx)) .with_child(self.render_input_box(&theme, cx))
.into_any() .into_any()
} }
fn render_active_channel_messages(&self) -> AnyElement<Self> { fn render_active_channel_messages(&self, theme: &Arc<Theme>) -> AnyElement<Self> {
let messages = if self.active_chat.is_some() { let messages = if self.active_chat.is_some() {
List::new(self.message_list.clone()).into_any() List::new(self.message_list.clone())
.contained()
.with_style(theme.chat_panel.list)
.into_any()
} else { } else {
Empty::new().into_any() Empty::new().into_any()
}; };
@ -381,6 +384,8 @@ impl ChatPanel {
.with_style(theme.hash.container), .with_style(theme.hash.container),
) )
.with_child(Label::new(channel.name.clone(), theme.name.clone())) .with_child(Label::new(channel.name.clone(), theme.name.clone()))
.aligned()
.left()
.contained() .contained()
.with_style(theme.container) .with_style(theme.container)
.into_any() .into_any()

View file

@ -1,5 +1,7 @@
use crate::{ use crate::{
elements::*, platform::MouseButton, AppContext, Entity, View, ViewContext, WeakViewHandle, elements::*,
platform::{CursorStyle, MouseButton},
AppContext, Entity, View, ViewContext, WeakViewHandle,
}; };
pub struct Select { pub struct Select {
@ -102,6 +104,7 @@ impl View for Select {
.contained() .contained()
.with_style(style.header) .with_style(style.header)
}) })
.with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, this, cx| { .on_click(MouseButton::Left, move |_, this, cx| {
this.toggle(cx); this.toggle(cx);
}), }),
@ -128,6 +131,7 @@ impl View for Select {
cx, cx,
) )
}) })
.with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, this, cx| { .on_click(MouseButton::Left, move |_, this, cx| {
this.set_selected_index(ix, cx); this.set_selected_index(ix, cx);
}) })

View file

@ -629,6 +629,7 @@ pub struct IconButton {
pub struct ChatPanel { pub struct ChatPanel {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
pub list: ContainerStyle,
pub channel_select: ChannelSelect, pub channel_select: ChannelSelect,
pub input_editor: FieldEditor, pub input_editor: FieldEditor,
pub message: ChatMessage, pub message: ChatMessage,

View file

@ -13,10 +13,10 @@ export default function chat_panel(): any {
const channel_name = { const channel_name = {
padding: { padding: {
// top: 4, left: SPACING,
right: SPACING,
top: 4,
bottom: 4, bottom: 4,
// left: 4,
right: 4,
}, },
hash: { hash: {
...text(layer, "sans", "base"), ...text(layer, "sans", "base"),
@ -26,23 +26,33 @@ export default function chat_panel(): any {
return { return {
background: background(layer), background: background(layer),
padding: { list: {
top: SPACING, margin: {
bottom: SPACING, left: SPACING,
left: SPACING, right: SPACING,
right: SPACING, }
}, },
channel_select: { channel_select: {
header: { ...channel_name }, header: {
...channel_name,
border: border(layer, { bottom: true })
},
item: channel_name, item: channel_name,
active_item: channel_name, active_item: {
hovered_item: channel_name, ...channel_name,
hovered_active_item: channel_name, background: background(layer, "on", "active"),
},
hovered_item: {
...channel_name,
background: background(layer, "on", "hovered"),
},
hovered_active_item: {
...channel_name,
background: background(layer, "on", "active"),
},
menu: { menu: {
padding: { background: background(layer, "on"),
top: 10, border: border(layer, { bottom: true })
bottom: 10,
}
} }
}, },
input_editor: { input_editor: {
@ -54,6 +64,11 @@ export default function chat_panel(): any {
}), }),
selection: theme.players[0], selection: theme.players[0],
border: border(layer, "on"), border: border(layer, "on"),
margin: {
left: SPACING,
right: SPACING,
bottom: SPACING,
},
padding: { padding: {
bottom: 4, bottom: 4,
left: 8, left: 8,