diff --git a/crates/client/design/tokens.toml b/crates/client/design/tokens.toml index 57196b1..bb6570f 100644 --- a/crates/client/design/tokens.toml +++ b/crates/client/design/tokens.toml @@ -69,6 +69,7 @@ rail = 56 avatar_lg = 64 thumb = 120 sidebar = 230 +index = 200 talk = 300 popover = 300 sheet = 380 diff --git a/crates/client/src/gui/builder.rs b/crates/client/src/gui/builder.rs index aad649f..474aa66 100644 --- a/crates/client/src/gui/builder.rs +++ b/crates/client/src/gui/builder.rs @@ -21,20 +21,18 @@ use common::{ permission, }; use gpui_kit::{ - AnyElement, App, Context, Entity, FontWeight, IntoElement, ParentElement, Styled, Window, + AnyElement, App, Context, Entity, IntoElement, ParentElement, Styled, Window, assets::IconName, - component::{Icon, input::InputState}, + component::input::InputState, div, - prelude::FluentBuilder as _, px, }; -use self::ui::{accent_button, icon_button, page_heading, plain_button}; +use self::ui::{accent_button, icon_button, plain_button}; use super::{ Palette, Yumush, - chat::View, - clickable, entity_action, notify_error, - settings_page::frame, + chat::View, entity_action, notify_error, + settings_page::{frame, heading}, style::{size, space, text}, text, widget::search_text, @@ -137,7 +135,7 @@ impl Yumush { BuilderTab::Log => self.log_body(entity, palette), }; let mut sections = vec![ - page_heading(title, self.tab_actions(tab, entity, palette, cx), palette) + heading(title, self.tab_actions(tab, entity, palette, cx), palette) .into_any_element(), ]; sections.extend(body); @@ -146,16 +144,7 @@ impl Yumush { "builder_scroll", entity, palette, - div() - .flex() - .items_center() - .gap(px(space::SM)) - .child( - Icon::new(IconName::Shield) - .size(px(size::ICON)) - .text_color(palette.accent), - ) - .child(Role::Builder.label()), + Role::Builder.label(), BuilderTab::ALL .map(|tab| { self.builder_nav_item(tab, entity, palette) @@ -221,29 +210,22 @@ impl Yumush { entity: &Entity, palette: Palette, ) -> impl IntoElement { - let label = tab.label(); - let active = self.chat.builder_tab == tab; - let color = if active { palette.text } else { palette.muted }; let open = (tab == BuilderTab::Reports) .then_some(self.chat.open_reports) .filter(|count| *count > 0); - clickable( + super::parts::index_item( format!("builder_tab_{}", tab.id()), - palette, + tab.label(), + self.chat.builder_tab == tab, + palette.tokens, entity_action(entity, move |yumush, window, cx| { yumush.select_builder_tab(tab, window, cx) }), ) - .h(px(size::CONTROL_SM + space::XS)) - .flex() - .items_center() - .gap(px(space::SM)) - .text_color(color) - .when(active, |this| this.font_weight(FontWeight::MEDIUM)) - .child(div().flex_1().min_w_0().truncate().child(label)) .children(open.map(|count| { div() + .ml(px(space::SM)) .text_size(text(text::CAPTION)) .text_color(palette.danger) .child(count.to_string()) diff --git a/crates/client/src/gui/builder/access.rs b/crates/client/src/gui/builder/access.rs index 642a8c4..712f1ed 100644 --- a/crates/client/src/gui/builder/access.rs +++ b/crates/client/src/gui/builder/access.rs @@ -16,15 +16,9 @@ use crate::gui::style::{size, space, text}; use crate::gui::{Palette, Yumush, entity_action, millis_time, notify_error, text, widget::field}; use crate::lang::w; -fn list_card(header: Div, rows: Vec
, empty: &str, palette: Palette) -> Div { +fn list_card(header: Div, rows: Vec
, none: &str, palette: Palette) -> Div { let body = if rows.is_empty() { - div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(empty.to_string()) + super::ui::empty(none, palette) } else { div().flex().flex_col().children(rows) }; diff --git a/crates/client/src/gui/builder/backups.rs b/crates/client/src/gui/builder/backups.rs index 2ac2dd3..ddc9316 100644 --- a/crates/client/src/gui/builder/backups.rs +++ b/crates/client/src/gui/builder/backups.rs @@ -13,7 +13,7 @@ use super::{ }; use crate::gui::{ Palette, Yumush, entity_action, millis_time, notify_error, storage, - style::{size, space, text}, + style::{size, text}, text, }; use crate::lang::w; @@ -100,13 +100,7 @@ impl Yumush { }) .collect(); let body = if rows.is_empty() { - div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(w().builder_backups.no_backups) + super::ui::empty(w().builder_backups.no_backups, palette) } else { div().flex().flex_col().children(rows) }; diff --git a/crates/client/src/gui/builder/log.rs b/crates/client/src/gui/builder/log.rs index 7573372..1ee68c6 100644 --- a/crates/client/src/gui/builder/log.rs +++ b/crates/client/src/gui/builder/log.rs @@ -297,13 +297,7 @@ impl Yumush { .map(|entry| builder_log_row(entry, palette)) .collect(); let body = if rows.is_empty() { - div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(w().builder_log.no_entries) + super::ui::empty(w().builder_log.no_entries, palette) } else { div().flex().flex_col().children(rows) }; diff --git a/crates/client/src/gui/builder/messages.rs b/crates/client/src/gui/builder/messages.rs index a68c5a6..ac0de62 100644 --- a/crates/client/src/gui/builder/messages.rs +++ b/crates/client/src/gui/builder/messages.rs @@ -233,13 +233,7 @@ impl Yumush { }) .collect(); let list = if rows.is_empty() { - div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(w().builder_messages.no_messages) + super::ui::empty(w().builder_messages.no_messages, palette) } else { div() .relative() diff --git a/crates/client/src/gui/builder/overview.rs b/crates/client/src/gui/builder/overview.rs index 2dec2d4..19fc14e 100644 --- a/crates/client/src/gui/builder/overview.rs +++ b/crates/client/src/gui/builder/overview.rs @@ -81,7 +81,6 @@ fn bar_chart( .child( div() .h(px(PANEL_HEIGHT)) - .px(px(space::LG)) .py(px(space::MD)) .flex() .flex_col() @@ -232,7 +231,7 @@ impl Yumush { Vec::new(), palette, )) - .child(div().p(px(space::LG)).child(voice_stats::stats_panel( + .child(div().pt(px(space::SM)).child(voice_stats::stats_panel( stats, &|id| self.chat.name_of(id), voice_stats::Detail::Full, diff --git a/crates/client/src/gui/builder/storage.rs b/crates/client/src/gui/builder/storage.rs index a99b28b..0f67cc9 100644 --- a/crates/client/src/gui/builder/storage.rs +++ b/crates/client/src/gui/builder/storage.rs @@ -250,13 +250,7 @@ impl Yumush { }) .collect(); let body = if rows.is_empty() { - div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(w().builder_storage.no_attachments) + super::ui::empty(w().builder_storage.no_attachments, palette) } else { div().flex().flex_col().children(rows) }; diff --git a/crates/client/src/gui/builder/ui.rs b/crates/client/src/gui/builder/ui.rs index 5ae58a2..9c20c02 100644 --- a/crates/client/src/gui/builder/ui.rs +++ b/crates/client/src/gui/builder/ui.rs @@ -206,15 +206,9 @@ pub(super) fn end_of_day_ms(text: &str) -> Option { epoch_ms(date.tomorrow().ok()?)?.checked_sub(1) } -pub(super) fn rows_body(rows: Vec
, empty: &str, palette: Palette) -> Div { +pub(super) fn rows_body(rows: Vec
, none: &str, palette: Palette) -> Div { if rows.is_empty() { - return div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(empty.to_string()); + return empty(none, palette); } div().flex().flex_col().children(rows) } @@ -266,24 +260,23 @@ pub(super) fn card_header(title: &str, actions: Vec, palette: Palett .items_center() .justify_between() .gap(px(space::SM)) - .child( - div() - .text_size(text(text::CAPTION)) - .text_color(palette.tokens.faint()) - .child(title.to_string()), - ) + .child(crate::gui::parts::section(title.to_string(), palette.tokens)) .children(actions) } -pub(super) fn list_card(title: Option<&str>, rows: Vec
, empty: &str, palette: Palette) -> Div { +pub(super) fn empty(label: &str, palette: Palette) -> Div { + div() + .min_h(px(size::ROW)) + .flex() + .items_center() + .text_size(text(text::UI)) + .text_color(palette.tokens.faint()) + .child(label.to_string()) +} + +pub(super) fn list_card(title: Option<&str>, rows: Vec
, none: &str, palette: Palette) -> Div { let body = if rows.is_empty() { - div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(empty.to_string()) + empty(none, palette) } else { div().flex().flex_col().children(rows) }; @@ -366,18 +359,3 @@ pub(super) fn pill(label: &str, color: Hsla, palette: Palette) -> Div { .child(label.to_string()) } -pub(super) fn page_heading(title: &str, actions: Vec, palette: Palette) -> Div { - div() - .flex() - .items_center() - .justify_between() - .gap(px(space::SM)) - .child( - div() - .text_size(text(text::TITLE)) - .font_weight(FontWeight::SEMIBOLD) - .text_color(palette.text) - .child(title.to_string()), - ) - .children(actions) -} diff --git a/crates/client/src/gui/builder/users.rs b/crates/client/src/gui/builder/users.rs index 4b6b770..0c8cc2d 100644 --- a/crates/client/src/gui/builder/users.rs +++ b/crates/client/src/gui/builder/users.rs @@ -496,13 +496,7 @@ impl Yumush { )); let body = if rows.is_empty() { - div() - .py(px(space::XL)) - .flex() - .justify_center() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(w().builder_users.no_users) + super::ui::empty(w().builder_users.no_users, palette) } else { div().flex().flex_col().children(rows) }; diff --git a/crates/client/src/gui/parts.rs b/crates/client/src/gui/parts.rs index b33489a..f61dd75 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -114,7 +114,10 @@ pub fn row(label: impl Into, trailing: impl IntoElement, t: Tokens } pub fn section(title: impl Into, t: Tokens) -> Div { - words(title, Text::Caption, Ink::Faint, t).pb(px(space::XS)) + words(title, Text::Label, Ink::Dim, t) + .font_weight(FontWeight::MEDIUM) + .pt(px(space::LG)) + .pb(px(space::XS)) } #[derive(Clone, Copy)] diff --git a/crates/client/src/gui/settings_page.rs b/crates/client/src/gui/settings_page.rs index 38b3d39..86ec56d 100644 --- a/crates/client/src/gui/settings_page.rs +++ b/crates/client/src/gui/settings_page.rs @@ -581,10 +581,9 @@ pub(super) fn page( .into_any_element() }) .collect(); - let body = sections - .into_iter() - .nth(selected) - .map(|Section(_, body)| body); + let Some(Section(name, body)) = sections.into_iter().nth(selected) else { + return frame(id, entity, palette, title, index, Vec::new(), Vec::new()); + }; frame( id, @@ -593,10 +592,29 @@ pub(super) fn page( title, index, Vec::new(), - body.into_iter().collect(), + vec![heading(name, Vec::new(), palette).into_any_element(), body], ) } +pub(super) fn heading(title: &str, actions: Vec, palette: Palette) -> Div { + div() + .h(px(size::CONTROL)) + .flex() + .items_center() + .justify_between() + .gap(px(space::SM)) + .child( + div() + .min_w_0() + .truncate() + .text_size(text(text::TITLE)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(palette.tokens.paper()) + .child(title.to_string()), + ) + .children(actions) +} + pub(super) fn frame( id: &'static str, entity: &Entity, @@ -607,78 +625,67 @@ pub(super) fn frame( body: Vec, ) -> Div { let back = entity.clone(); + let top = space::XXL + space::LG; div() .flex_1() .min_w_0() .min_h_0() .flex() + .child(div().flex_1().flex_basis(px(0.)).min_w_0()) .child( div() - .w(px(size::SIDEBAR)) + .w(px(size::INDEX)) .flex_shrink_0() - .px(px(space::XL)) - .py(px(space::XL)) + .pt(px(top)) + .pb(px(space::XL)) + .pl(px(space::XL)) .flex() .flex_col() - .border_r(px(stroke::LINE)) - .border_color(palette.tokens.thread()) .child( - div() - .pb(px(space::XL)) - .flex() - .items_center() - .gap(px(space::XS)) - .ml(px(-space::SM)) - .child( - clickable("page_back", palette, move |window, cx| { - back.update(cx, |yumush, cx| { - yumush.show_view(View::Chat, window, cx) - }); - }) - .tip(w().settings_page.back_esc) - .size(px(size::CONTROL_SM)) - .flex_shrink_0() - .flex() - .items_center() - .justify_center() - .rounded_full() - .text_color(palette.muted) - .child( - gpui_kit::component::Icon::new( - gpui_kit::assets::IconName::ArrowLeft, - ) - .size(px(size::ICON)), - ), - ) - .child( - div() - .min_w_0() - .text_size(text(text::TITLE)) - .text_color(palette.tokens.paper()) - .child(title), - ), + clickable("page_back", palette, move |window, cx| { + back.update(cx, |yumush, cx| yumush.show_view(View::Chat, window, cx)); + }) + .tip(w().settings_page.back_esc) + .h(px(size::CONTROL)) + .mb(px(space::LG)) + .ml(px(-space::SM)) + .px(px(space::SM)) + .rounded(px(radius::MD)) + .flex() + .items_center() + .gap(px(space::SM)) + .min_w_0() + .text_size(text(text::UI)) + .text_color(palette.muted) + .child( + gpui_kit::component::Icon::new(gpui_kit::assets::IconName::ArrowLeft) + .size(px(size::ICON_SM)) + .flex_shrink_0(), + ) + .child(div().min_w_0().truncate().child(title)), ) - .children(index) - .child(div().flex_1()) - .children(footer), + .child(div().flex().flex_col().children(index)) + .child(div().pt(px(space::XL)).flex().flex_col().children(footer)), ) .child( div() .id(id) .flex_1() + .flex_basis(px(size::PAGE + space::XXL)) .min_w_0() .min_h_0() .overflow_y_scroll() .child( div() .w_full() - .max_w(px(size::PAGE)) + .max_w(px(size::PAGE + space::XXL * 2.)) .px(px(space::XXL)) - .py(px(space::XL)) + .pt(px(top)) + .pb(px(space::XXL * 2.)) .flex() .flex_col() - .gap(px(space::XL)) + .gap(px(space::LG)) .children(body), ), ) @@ -700,6 +707,7 @@ pub(super) fn with_danger(section: Section, actions: Vec) -> Section .when(!actions.is_empty(), |this| { this.child( div() + .ml(px(-space::SM)) .flex() .items_center() .gap(px(space::LG)) @@ -796,7 +804,6 @@ pub(super) fn picture_card(picture: Picture, entity: &Entity, palette: P let remove_entity = entity.clone(); div() - .p(px(space::LG)) .flex() .items_center() .gap(px(space::LG))