Files
proxy-suite-flake/windows/crates/ps-gui/src/ui/widgets.rs
T
faumarayandClaude Opus 5.5 7dfb3129f4 windows: the app's Telegram proxy page
tg-ws-proxy on or off and its state; its tg:// links, to copy or open in
Telegram (none without the secrets scope, and the page says so); whether
other devices may connect; its port and fake-TLS domain (which adds the
ee link). Long links are cut short rather than widening the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:33:10 +03:00

51 lines
1.9 KiB
Rust

//! 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<SharedString>, action: Option<AnyElement>, 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<SharedString>, 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<SharedString>, 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())
}