feat(channels): "Post in channel" card at the top of the posts list
- own avatar, "Post in channel" and the Post tab, as in Teams web; a click opens the post composer - replaces the "New post" button - Announcement is left out until announcements are built (guardrails: no placeholder UI) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -18,6 +18,7 @@ use crate::runtime;
18
18
use crate::theme;
19
19
use crate::views::channel_tabs::ChannelPane;
20
20
use crate::views::composer::{Composer, ComposerEvent, ReplyPreview};
21
use crate::views::post_card::{PostAction, post_in_channel_card};
21
22
use crate::views::widgets::icon;
22
23
23
24
const REPLY_PLACEHOLDER: &str = "Reply in thread";
@@ -244,38 +245,22 @@ impl ConversationView {
244
245
}
245
246
let proposal_card = self.render_proposal_card(cx);
246
247
if !self.new_post_open {
248
let view = cx.entity().downgrade();
249
let open: PostAction = Box::new(move |window, cx| {
250
view.update(cx, |this, cx| this.open_new_post(window, cx)).ok();
251
});
247
252
return Some(
248
253
v_flex()
249
254
.w_full()
250
255
.flex_none()
251
256
.children(proposal_card)
252
257
.child(
253
h_flex()
258
div()
254
259
.w_full()
255
260
.flex_none()
256
261
.px(px(20.))
257
262
.pt(px(12.))
258
.pb(px(12.))
259
.child(
260
h_flex()
261
.id("new-post")
262
.h(px(32.))
263
.px(px(12.))
264
.gap(px(6.))
265
.items_center()
266
.rounded(px(8.))
267
.bg(theme::accent())
268
.text_color(theme::on_accent())
269
.text_size(px(13.))
270
.font_weight(FontWeight::SEMIBOLD)
271
.cursor_pointer()
272
.hover(|button| button.bg(theme::accent_text()))
273
.on_click(cx.listener(|this, _, window, cx| {
274
this.open_new_post(window, cx)
275
}))
276
.child(icon(IconName::Plus, 14., theme::on_accent()))
277
.child("New post"),
278
),
263
.child(post_in_channel_card(&self.app.read(cx).directory, open)),
279
264
)
280
265
.into_any_element(),
281
266
);
@@ -18,6 +18,7 @@ use crate::runtime;18
use crate::theme;18
use crate::theme;19
use crate::views::channel_tabs::ChannelPane;19
use crate::views::channel_tabs::ChannelPane;20
use crate::views::composer::{Composer, ComposerEvent, ReplyPreview};20
use crate::views::composer::{Composer, ComposerEvent, ReplyPreview};21
use crate::views::post_card::{PostAction, post_in_channel_card};21
use crate::views::widgets::icon;22
use crate::views::widgets::icon;22
23
23
const REPLY_PLACEHOLDER: &str = "Reply in thread";24
const REPLY_PLACEHOLDER: &str = "Reply in thread";@@ -244,38 +245,22 @@ impl ConversationView {244
}245
}245
let proposal_card = self.render_proposal_card(cx);246
let proposal_card = self.render_proposal_card(cx);246
if !self.new_post_open {247
if !self.new_post_open {248
let view = cx.entity().downgrade();249
let open: PostAction = Box::new(move |window, cx| {250
view.update(cx, |this, cx| this.open_new_post(window, cx)).ok();251
});247
return Some(252
return Some(248
v_flex()253
v_flex()249
.w_full()254
.w_full()250
.flex_none()255
.flex_none()251
.children(proposal_card)256
.children(proposal_card)252
.child(257
.child(253
h_flex()258
div()254
.w_full()259
.w_full()255
.flex_none()260
.flex_none()256
.px(px(20.))261
.px(px(20.))257
.pt(px(12.))262
.pt(px(12.))258
.pb(px(12.))263
.child(post_in_channel_card(&self.app.read(cx).directory, open)),259
.child(260
h_flex()261
.id("new-post")262
.h(px(32.))263
.px(px(12.))264
.gap(px(6.))265
.items_center()266
.rounded(px(8.))267
.bg(theme::accent())268
.text_color(theme::on_accent())269
.text_size(px(13.))270
.font_weight(FontWeight::SEMIBOLD)271
.cursor_pointer()272
.hover(|button| button.bg(theme::accent_text()))273
.on_click(cx.listener(|this, _, window, cx| {274
this.open_new_post(window, cx)275
}))276
.child(icon(IconName::Plus, 14., theme::on_accent()))277
.child("New post"),278
),279
)264
)280
.into_any_element(),265
.into_any_element(),281
);266
);@@ -42,10 +42,13 @@ const REPLY_IN_THREAD: &str = "Reply in thread";
42
42
const NEW_STRIPE_WIDTH: f32 = 3.;
43
43
const NEW_BADGE_HEIGHT: f32 = 20.;
44
44
const NEW_LABEL: &str = "New";
45
const POST_IN_CHANNEL: &str = "Post in channel";
46
const POST_LABEL: &str = "Post";
45
47
pub const POST_CARD_TAG: &str = "post-card";
46
48
pub const POST_AVATAR_TAG: &str = "post-card/avatar";
47
49
pub const POST_BODY_TAG: &str = "post-card/body";
48
50
pub const POST_FOOTER_AVATAR_TAG: &str = "post-card/footer-avatar";
51
pub const POST_IN_CHANNEL_TAG: &str = "post-in-channel";
49
52
50
53
pub type PostAction = Box<dyn Fn(&mut Window, &mut App)>;
51
54
@@ -440,6 +443,57 @@ fn reply_footer(
440
443
)
441
444
}
442
445
446
pub fn post_in_channel_card(directory: &Directory, open: PostAction) -> AnyElement {
447
let own_avatar = directory.me.as_ref().map(|me| {
448
div().flex_none().child(person_avatar(
449
directory,
450
Some(&me.user_id),
451
&me.display_name,
452
ROOT_AVATAR,
453
))
454
});
455
v_flex()
456
.id(POST_IN_CHANNEL_TAG)
457
.debug_selector(|| POST_IN_CHANNEL_TAG.into())
458
.w_full()
459
.p(px(CARD_PADDING))
460
.gap(px(CARD_GAP))
461
.rounded(px(CARD_RADIUS))
462
.bg(theme::row_hover())
463
.cursor_pointer()
464
.on_click(move |_, window, cx| open(window, cx))
465
.child(
466
h_flex()
467
.gap(px(AVATAR_GAP))
468
.items_center()
469
.children(own_avatar)
470
.child(
471
div()
472
.text_size(px(13.))
473
.font_weight(FontWeight::SEMIBOLD)
474
.text_color(theme::text_strong())
475
.child(POST_IN_CHANNEL),
476
),
477
)
478
.child(
479
h_flex().child(
480
h_flex()
481
.h(px(32.))
482
.px(px(12.))
483
.gap(px(6.))
484
.items_center()
485
.rounded(px(6.))
486
.bg(theme::reply_surface())
487
.text_size(px(13.))
488
.font_weight(FontWeight::SEMIBOLD)
489
.text_color(theme::accent_text())
490
.child(icon(IconName::MessageSquare, 14., theme::accent_text()))
491
.child(POST_LABEL),
492
),
493
)
494
.into_any_element()
495
}
496
443
497
fn new_post_badge() -> Div {
444
498
div()
445
499
.absolute()
@@ -42,10 +42,13 @@ const REPLY_IN_THREAD: &str = "Reply in thread";42
const NEW_STRIPE_WIDTH: f32 = 3.;42
const NEW_STRIPE_WIDTH: f32 = 3.;43
const NEW_BADGE_HEIGHT: f32 = 20.;43
const NEW_BADGE_HEIGHT: f32 = 20.;44
const NEW_LABEL: &str = "New";44
const NEW_LABEL: &str = "New";45
const POST_IN_CHANNEL: &str = "Post in channel";46
const POST_LABEL: &str = "Post";45
pub const POST_CARD_TAG: &str = "post-card";47
pub const POST_CARD_TAG: &str = "post-card";46
pub const POST_AVATAR_TAG: &str = "post-card/avatar";48
pub const POST_AVATAR_TAG: &str = "post-card/avatar";47
pub const POST_BODY_TAG: &str = "post-card/body";49
pub const POST_BODY_TAG: &str = "post-card/body";48
pub const POST_FOOTER_AVATAR_TAG: &str = "post-card/footer-avatar";50
pub const POST_FOOTER_AVATAR_TAG: &str = "post-card/footer-avatar";51
pub const POST_IN_CHANNEL_TAG: &str = "post-in-channel";49
52
50
pub type PostAction = Box<dyn Fn(&mut Window, &mut App)>;53
pub type PostAction = Box<dyn Fn(&mut Window, &mut App)>;51
54
@@ -440,6 +443,57 @@ fn reply_footer(440
)443
)441
}444
}442
445
446
pub fn post_in_channel_card(directory: &Directory, open: PostAction) -> AnyElement {447
let own_avatar = directory.me.as_ref().map(|me| {448
div().flex_none().child(person_avatar(449
directory,450
Some(&me.user_id),451
&me.display_name,452
ROOT_AVATAR,453
))454
});455
v_flex()456
.id(POST_IN_CHANNEL_TAG)457
.debug_selector(|| POST_IN_CHANNEL_TAG.into())458
.w_full()459
.p(px(CARD_PADDING))460
.gap(px(CARD_GAP))461
.rounded(px(CARD_RADIUS))462
.bg(theme::row_hover())463
.cursor_pointer()464
.on_click(move |_, window, cx| open(window, cx))465
.child(466
h_flex()467
.gap(px(AVATAR_GAP))468
.items_center()469
.children(own_avatar)470
.child(471
div()472
.text_size(px(13.))473
.font_weight(FontWeight::SEMIBOLD)474
.text_color(theme::text_strong())475
.child(POST_IN_CHANNEL),476
),477
)478
.child(479
h_flex().child(480
h_flex()481
.h(px(32.))482
.px(px(12.))483
.gap(px(6.))484
.items_center()485
.rounded(px(6.))486
.bg(theme::reply_surface())487
.text_size(px(13.))488
.font_weight(FontWeight::SEMIBOLD)489
.text_color(theme::accent_text())490
.child(icon(IconName::MessageSquare, 14., theme::accent_text()))491
.child(POST_LABEL),492
),493
)494
.into_any_element()495
}496
443
fn new_post_badge() -> Div {497
fn new_post_badge() -> Div {444
div()498
div()445
.absolute()499
.absolute()