//! Pieces the pages share: the page frame, cards, a unit's state as a tag. use gpui_kit::component::tag::Tag; use gpui_kit::assets::IconName; use gpui_kit::component::*; use gpui_kit::*; pub fn brand(cx: &App) -> impl IntoElement { div().h_flex().gap_2().items_center().child(Icon::new(IconName::Shield).text_color(cx.theme().primary)).child(div().font_semibold().child("Proxy Suite")) } /// A page: its title, then what is under it. pub fn page(title: &'static str, cx: &App) -> Div { div().v_flex().gap_4().p_6().w_full().min_w_0().max_w(px(920.)).child(div().text_xl().font_semibold().text_color(cx.theme().foreground).child(title)) } /// A bordered section of a page, titled, with what it controls on the right of the title. pub fn card(title: impl Into, action: Option, cx: &App) -> Div { div() .v_flex() .gap_3() .p_4() .min_w_0() .rounded_lg() .border_1() .border_color(cx.theme().border) .bg(cx.theme().background) .child(div().h_flex().justify_between().items_center().child(div().font_semibold().child(title.into())).children(action)) } /// A unit's state, as the service says it, coloured by what it means. pub fn state_tag(state: &str) -> Tag { let tag = match state { "active" => Tag::success(), "activating" | "reloading" | "deactivating" => Tag::warning(), "failed" => Tag::danger(), _ => Tag::secondary(), }; tag.child(state.to_owned()) } /// A quieter line of explanation. pub fn hint(text: impl Into, cx: &App) -> Div { div().text_sm().text_color(cx.theme().muted_foreground).child(text.into()) } /// A label and its value, in a row. pub fn fact(label: &'static str, value: impl Into, cx: &App) -> Div { div().h_flex().gap_2().text_sm().child(div().w(px(110.)).text_color(cx.theme().muted_foreground).child(label)).child(value.into()) }