use crate::{
density,
icons::{CarbonIcon, Icon},
t3::craft::{rem, sans},
theme::color,
tokens::{self, ColorRole},
};
use gpui_kit::{AnyElement, Div, IntoElement, ParentElement, SharedString, Styled, div, px};
pub(crate) fn frame() -> Div {
sans(div(), 14., 400)
.relative()
.flex()
.items_center()
.w_full()
.gap(tokens::SPACING_04)
.min_h(density::current().row_lg())
.pt(tokens::SPACING_02)
.pb(tokens::SPACING_02)
.pr(tokens::SPACING_03)
.pl(tokens::SPACING_05)
.bg(color(ColorRole::Layer01))
.border_b_1()
.border_color(color(ColorRole::BorderSubtle01))
.text_color(color(ColorRole::TextPrimary))
}
pub(super) fn lead_icon(name: CarbonIcon) -> Div {
div().flex().flex_none().child(
Icon::carbon(name)
.size_length(rem(16.))
.color(color(ColorRole::IconSecondary)),
)
}
pub(super) fn main(
name: SharedString,
name_ink: gpui_kit::Hsla,
meta: impl IntoIterator<Item = AnyElement>,
) -> Div {
div()
.flex()
.flex_col()
.flex_1()
.min_w_0()
.gap(px(2.))
.child(
div()
.min_w_0()
.overflow_hidden()
.whitespace_nowrap()
.text_ellipsis()
.text_color(name_ink)
.child(name),
)
.child(
sans(div(), 12., 400)
.flex()
.flex_wrap()
.items_center()
.gap_x(tokens::SPACING_03)
.gap_y(tokens::SPACING_02)
.text_color(color(ColorRole::TextSecondary))
.children(meta),
)
}
pub(super) fn metadot() -> AnyElement {
div()
.px(px(2.))
.text_color(color(ColorRole::TextHelper))
.child("·")
.into_any_element()
}
pub(super) fn meta_text(text: impl Into<SharedString>) -> AnyElement {
div()
.whitespace_nowrap()
.child(text.into())
.into_any_element()
}
pub(super) fn with_dots(runs: impl IntoIterator<Item = AnyElement>) -> Vec<AnyElement> {
let mut out = Vec::new();
for (i, run) in runs.into_iter().enumerate() {
if i > 0 {
out.push(metadot());
}
out.push(run);
}
out
}