BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / connection_banner.rs

connection_banner.rs

connection_banner.rs 1.9 KiB Download Raw
1use gpui_kit::assets::IconName;
2use gpui_kit::component::h_flex;
3use gpui_kit::prelude::FluentBuilder as _;
4use gpui_kit::*;
5
6use super::widgets::icon;
7use crate::connection_banner::BannerText;
8use crate::theme;
9use app_ui_kit::layout::{ISLAND_GAP, RAIL_WIDTH};
10
11const BANNER_HEIGHT: f32 = 32.;
12const BANNER_TEXT_SIZE: f32 = 12.;
13const BANNER_ICON_SIZE: f32 = 14.;
14
15pub fn render_connection_banner(
16 banner: BannerText,
17 on_retry: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
18) -> impl IntoElement {
19 h_flex()
20 .debug_selector(|| "shell/connection-banner".into())
21 .flex_none()
22 .h(px(BANNER_HEIGHT))
23 .ml(px(RAIL_WIDTH))
24 .mr(px(ISLAND_GAP))
25 .mb(px(ISLAND_GAP))
26 .px(px(12.))
27 .gap(px(8.))
28 .items_center()
29 .rounded(px(8.))
30 .bg(theme::amber().opacity(0.14))
31 .text_size(px(BANNER_TEXT_SIZE))
32 .text_color(theme::text())
33 .child(icon(
34 IconName::TriangleAlert,
35 BANNER_ICON_SIZE,
36 theme::amber(),
37 ))
38 .child(div().min_w_0().truncate().child(banner.text))
39 .children(banner.detail.map(|detail| {
40 div()
41 .flex_none()
42 .text_color(theme::text_muted())
43 .child(detail)
44 }))
45 .when_some(banner.action, |row, label| {
46 row.child(
47 div()
48 .id("connection-banner-action")
49 .flex_none()
50 .ml_auto()
51 .px(px(8.))
52 .py(px(2.))
53 .rounded(px(6.))
54 .cursor_pointer()
55 .font_weight(FontWeight::SEMIBOLD)
56 .text_color(theme::accent_text())
57 .hover(|button| button.bg(theme::row_hover()))
58 .child(label)
59 .on_click(on_retry),
60 )
61 })
62}