diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index eebc624..37a89ed 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -71,14 +71,14 @@ mod wave; mod widget; use auth::Auth; -use style::{Tokens, radius, size, space, text}; +use style::{Tokens, radius, size, space}; use chat::{Chat, View}; use voice_settings::VoiceControls; actions!(yumush, [FocusFind, CloseSettings]); pub fn text(size: f32) -> Rems { - rems(size / text::UI) + rems(size / style::text::UI) } #[derive(Clone, Copy)] @@ -349,7 +349,7 @@ impl Render for Tip { .bg(palette.field) .text_color(palette.text) .font_family(FONT) - .text_size(text(text::LABEL)) + .text_size(text(style::text::LABEL)) .child(self.0) } } @@ -414,7 +414,7 @@ pub fn rank_tag(rank: Option, palette: Palette) -> Option
{ Some( div() - .text_size(text(text::CAPTION)) + .text_size(text(style::text::CAPTION)) .text_color(color) .child(rank.label()), ) @@ -507,7 +507,7 @@ fn connection_notice(connection: &Connection, palette: Palette) -> Option
{ .items_center() .justify_center() .gap(px(space::SM)) - .text_size(text(text::CAPTION)) + .text_size(text(style::text::CAPTION)) .text_color(color) .child(Spinner::new().xsmall().color(color)) .child(label), @@ -1300,7 +1300,7 @@ impl Render for Yumush { .size_full() .bg(palette.window) .text_color(palette.text) - .text_size(text(text::UI)) + .text_size(text(style::text::UI)) .track_focus(&self.focus) .on_action( cx.listener(|this, _: &FocusFind, window, cx| this.chat.focus_find(window, cx)), diff --git a/crates/client/src/gui/auth.rs b/crates/client/src/gui/auth.rs index 5bc89ac..5285a0e 100644 --- a/crates/client/src/gui/auth.rs +++ b/crates/client/src/gui/auth.rs @@ -13,6 +13,7 @@ use super::{ Palette, Route, Tooltip as _, Yumush, badge, clickable, connection_notice, hoverable, new_input, notify_error, palette, primary_button, settings_page::{segment, segment_track}, + style::{radius, size, space, text}, text, widget::{field, frame}, }; @@ -105,11 +106,11 @@ impl Yumush { let action_button = primary_button("auth_button", palette, move |window, cx| { submit_entity.update(cx, |this, cx| submit(this, window, cx)); }) - .h(px(32.)) + .h(px(size::CONTROL)) .flex() .items_center() .justify_center() - .rounded(px(8.)) + .rounded(px(radius::MD)) .font_weight(FontWeight::MEDIUM) .child(action_label); @@ -132,24 +133,20 @@ impl Yumush { .size_full() .child( div() - .w(px(320.)) - .p(px(24.)) + .w(px(size::POPOVER)) + .p(px(space::XL)) .flex() .flex_col() - .gap(px(12.)) - .rounded(px(10.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) + .gap(px(space::MD)) .child( div() - .text_size(text(18.)) + .text_size(text(text::BODY)) .font_weight(FontWeight::SEMIBOLD) .child(title), ) .children(maintenance.then(|| { div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child("Maintenance") })) @@ -180,19 +177,19 @@ impl Yumush { hoverable( format!("saved_{}", account.user_id), div() - .h(px(36.)) - .px(px(8.)) + .h(px(size::CONTROL)) + .px(px(space::SM)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .child( badge( palette, account.user_id, &account.username, - px(22.), - text(11.), + px(size::CHIP), + text(text::CAPTION), ) .rounded_full(), ) @@ -209,13 +206,13 @@ impl Yumush { }, ) .tip("Forget") - .size(px(22.)) + .size(px(size::CHIP)) .flex() .items_center() .justify_center() - .rounded(px(5.)) + .rounded(px(radius::SM)) .text_color(palette.muted) - .child(Icon::new(IconName::X).w(px(12.)).h(px(12.))), + .child(Icon::new(IconName::X).size(px(size::ICON_SM))), ), palette, ) @@ -228,7 +225,7 @@ impl Yumush { }) .collect(); - Some(div().flex().flex_col().gap(px(2.)).children(rows)) + Some(div().flex().flex_col().gap(px(space::XXS)).children(rows)) } } @@ -248,6 +245,6 @@ fn tab( palette, ) .flex_1() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .child(label) } diff --git a/crates/client/src/gui/builder.rs b/crates/client/src/gui/builder.rs index 183caf0..594a15f 100644 --- a/crates/client/src/gui/builder.rs +++ b/crates/client/src/gui/builder.rs @@ -32,6 +32,7 @@ use gpui_kit::{ use self::ui::{accent_button, icon_button, page_heading, plain_button}; use super::{ Palette, Yumush, chat::View, clickable, entity_action, notify_error, settings_page::header, + style::{radius, size, space, text}, text, widget::search_text, }; use crate::net::NetworkHandle; @@ -158,13 +159,13 @@ impl Yumush { .child( div() .w_full() - .max_w(px(960.)) + .max_w(px(size::PAGE)) .mx_auto() - .px(px(32.)) - .py(px(28.)) + .px(px(space::XXL)) + .py(px(space::XXL)) .flex() .flex_col() - .gap(px(20.)) + .gap(px(space::XL)) .children(sections), ), ), @@ -219,12 +220,12 @@ impl Yumush { fn builder_rail(&self, entity: &Entity, palette: Palette) -> Div { div() - .w(px(200.)) + .w(px(size::SIDEBAR)) .flex_shrink_0() .flex() .flex_col() - .gap(px(2.)) - .p(px(8.)) + .gap(px(space::XXS)) + .p(px(space::SM)) .bg(palette.panel) .border_r_1() .border_color(palette.border) @@ -254,24 +255,24 @@ impl Yumush { yumush.select_builder_tab(tab, window, cx) }), ) - .h(px(32.)) - .px(px(10.)) + .h(px(size::CONTROL)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(6.)) - .text_size(text(13.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) + .text_size(text(text::LABEL)) .text_color(color) .when(active, |this| this.bg(palette.hover)) - .child(Icon::new(icon).w(px(14.)).h(px(14.)).text_color(color)) + .child(Icon::new(icon).size(px(size::ICON_SM)).text_color(color)) .child(div().flex_1().min_w_0().truncate().child(label)) .children(open.map(|count| { div() - .px(px(6.)) + .px(px(space::XS)) .rounded_full() .bg(palette.accent) .text_color(palette.on_accent) - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .child(count.to_string()) })) } @@ -283,12 +284,12 @@ impl Yumush { }); div() - .h(px(32.)) - .px(px(10.)) + .h(px(size::CONTROL)) + .px(px(space::MD)) .flex() .items_center() .justify_between() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.muted) .child("Ghost") .child( diff --git a/crates/client/src/gui/builder/access.rs b/crates/client/src/gui/builder/access.rs index 54d2773..b1efeea 100644 --- a/crates/client/src/gui/builder/access.rs +++ b/crates/client/src/gui/builder/access.rs @@ -13,15 +13,16 @@ use super::ui::{ toolbar, }; use crate::gui::STAMP; +use crate::gui::style::{size, space, text}; use crate::gui::{Palette, Yumush, entity_action, millis_time, notify_error, text, widget::field}; fn list_card(header: Div, rows: Vec
, empty: &str, palette: Palette) -> Div { let body = if rows.is_empty() { div() - .py(px(24.)) + .py(px(space::XL)) .flex() .justify_center() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(empty.to_string()) } else { @@ -52,12 +53,12 @@ fn invite_row( ); div() - .min_h(px(44.)) - .px(px(14.)) - .py(px(10.)) + .min_h(px(size::ROW)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .child( div() .flex_1() @@ -72,7 +73,7 @@ fn invite_row( ) .child( div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .truncate() .child(format!( @@ -110,12 +111,12 @@ fn ban_row(ban: &ServerBan, entity: &Entity, palette: Palette) -> Div { }; div() - .min_h(px(44.)) - .px(px(14.)) - .py(px(10.)) + .min_h(px(size::ROW)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .child(pill(kind, palette.text, palette)) .child( div() @@ -131,7 +132,7 @@ fn ban_row(ban: &ServerBan, entity: &Entity, palette: Palette) -> Div { ) .children(ban.reason.as_ref().map(|reason| { div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .truncate() .child(reason.clone()) @@ -253,7 +254,7 @@ impl Yumush { pub(super) fn access_body(&self, entity: &Entity, palette: Palette) -> Vec { let controls = toolbar(vec![ fixed(80., field(palette, &self.chat.invite_uses)), - fixed(90., field(palette, &self.chat.invite_hours)), + fixed(size::THUMB, field(palette, &self.chat.invite_hours)), accent_button( "create_invite", "Create", diff --git a/crates/client/src/gui/builder/backups.rs b/crates/client/src/gui/builder/backups.rs index 69cbed9..66ab034 100644 --- a/crates/client/src/gui/builder/backups.rs +++ b/crates/client/src/gui/builder/backups.rs @@ -11,7 +11,13 @@ use super::{ save_directory, ui::{accent_button, card, card_header, confirmed, delete_icon_button, icon_button, list_row}, }; -use crate::gui::{DATE, Palette, Yumush, entity_action, millis_time, notify_error, storage, text}; +use crate::gui::{ + DATE, Palette, Yumush, entity_action, millis_time, notify_error, storage, + style::{size, space, text}, + text, +}; + +const STORAGE_WIDTH: f32 = 72.; fn backup_row(info: &BackupInfo, pending: bool, entity: &Entity, palette: Palette) -> Div { let export_name = info.name.clone(); @@ -39,8 +45,7 @@ fn backup_row(info: &BackupInfo, pending: bool, entity: &Entity, palette list_row() .child( Icon::new(IconName::HardDrive) - .w(px(16.)) - .h(px(16.)) + .size(px(size::ICON)) .flex_shrink_0() .text_color(palette.muted), ) @@ -49,24 +54,24 @@ fn backup_row(info: &BackupInfo, pending: bool, entity: &Entity, palette .flex_1() .min_w_0() .truncate() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.text) .child(info.name.clone()), ) .child( div() .flex_shrink_0() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(millis_time(info.created_ms, DATE)), ) .child( div() - .w(px(72.)) + .w(px(STORAGE_WIDTH)) .flex_shrink_0() .flex() .justify_end() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(storage(info.size_bytes)), ) @@ -95,10 +100,10 @@ impl Yumush { .collect(); let body = if rows.is_empty() { div() - .py(px(24.)) + .py(px(space::XL)) .flex() .justify_center() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child("No backups") } else { diff --git a/crates/client/src/gui/builder/communities.rs b/crates/client/src/gui/builder/communities.rs index 4681602..56f25f7 100644 --- a/crates/client/src/gui/builder/communities.rs +++ b/crates/client/src/gui/builder/communities.rs @@ -17,7 +17,10 @@ use super::{ }; use crate::gui::{ Palette, Yumush, avatar, chat::View, community_icon, entity_action, notify_error, - profile::user_link, text, widget::search_text, + profile::user_link, + style::{radius, size, space, text}, + text, + widget::search_text, }; impl Yumush { @@ -291,15 +294,15 @@ impl Yumush { card(palette) .child( div() - .px(px(14.)) - .py(px(10.)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .items_center() .border_b_1() .border_color(palette.border) .child( div() - .w(px(240.)) + .w(px(size::SIDEBAR)) .child(Input::new(&self.chat.builder_search)), ), ) @@ -318,11 +321,11 @@ impl Yumush { let user_id = member.user.id; div() - .h(px(40.)) - .px(px(12.)) + .h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div().flex_1().min_w_0().flex().child(user_link( format!("transfer_user_{}", member.user.id), @@ -331,12 +334,12 @@ impl Yumush { div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child(avatar( palette, &member.user, - px(20.), - text(10.), + px(size::AVATAR), + text(text::CAPTION), &self.chat.avatars, )) .child( @@ -383,17 +386,17 @@ impl Yumush { let meta = format!("{} members{owner}", summary.members); let row = div() - .min_h(px(48.)) - .px(px(14.)) - .py(px(8.)) + .min_h(px(size::ROW)) + .px(px(space::LG)) + .py(px(space::SM)) .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .child(community_icon( palette, community, - px(28.), - text(11.), + px(size::AVATAR), + text(text::CAPTION), &self.chat.avatars, )) .child( @@ -404,7 +407,7 @@ impl Yumush { .flex_col() .child( div() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .font_weight(FontWeight::MEDIUM) .text_color(palette.text) .truncate() @@ -412,7 +415,7 @@ impl Yumush { ) .child( div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .truncate() .child(meta), @@ -498,13 +501,11 @@ impl Yumush { .flex_col() .child(row) .children(expanded.then(|| { - div().px(px(14.)).pb(px(10.)).child( + div().px(px(space::LG)).pb(px(space::MD)).child( div() .flex() .flex_col() - .rounded(px(6.)) - .border_1() - .border_color(palette.border) + .rounded(px(radius::MD)) .children(self.transfer_rows(entity, palette)), ) })) diff --git a/crates/client/src/gui/builder/log.rs b/crates/client/src/gui/builder/log.rs index 2030dad..81564a4 100644 --- a/crates/client/src/gui/builder/log.rs +++ b/crates/client/src/gui/builder/log.rs @@ -21,7 +21,9 @@ use crate::gui::STAMP; use crate::gui::{ Palette, Yumush, community_settings::user_name, - entity_action, millis_time, notify_error, text, + entity_action, millis_time, notify_error, + style::{size, space, text}, + text, widget::{field, search_text}, }; @@ -181,8 +183,7 @@ fn builder_log_row(entry: &AdminLogEntry, palette: Palette) -> Div { list_row() .child( Icon::new(action_icon(&entry.action)) - .w(px(14.)) - .h(px(14.)) + .size(px(size::ICON_SM)) .text_color(palette.muted), ) .child( @@ -191,17 +192,17 @@ fn builder_log_row(entry: &AdminLogEntry, palette: Palette) -> Div { .min_w_0() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child( div() .truncate() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.text) .child(builder_log_text(entry)), ) .child( div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(millis_time(entry.created_at, STAMP)), ), @@ -283,11 +284,11 @@ impl Yumush { pub(super) fn log_body(&self, entity: &Entity, palette: Palette) -> Vec { let filters = toolbar(vec![ - fixed(130., field(palette, &self.chat.builder_log_actor)), - fixed(130., field(palette, &self.chat.builder_log_target)), - fixed(160., Select::new(&self.chat.builder_log_action)), - fixed(150., field(palette, &self.chat.builder_log_from)), - fixed(150., field(palette, &self.chat.builder_log_to)), + fixed(size::THUMB,field(palette, &self.chat.builder_log_actor)), + fixed(size::THUMB,field(palette, &self.chat.builder_log_target)), + fixed(size::THUMB,Select::new(&self.chat.builder_log_action)), + fixed(size::THUMB,field(palette, &self.chat.builder_log_from)), + fixed(size::THUMB,field(palette, &self.chat.builder_log_to)), accent_button( "apply_builder_log", "Apply", @@ -311,10 +312,10 @@ impl Yumush { .collect(); let body = if rows.is_empty() { div() - .py(px(24.)) + .py(px(space::XL)) .flex() .justify_center() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child("No entries") } else { @@ -325,8 +326,8 @@ impl Yumush { card(palette) .child( div() - .px(px(14.)) - .py(px(10.)) + .px(px(space::LG)) + .py(px(space::MD)) .border_b_1() .border_color(palette.border) .child(filters), diff --git a/crates/client/src/gui/builder/messages.rs b/crates/client/src/gui/builder/messages.rs index 9d876a6..f8dffdc 100644 --- a/crates/client/src/gui/builder/messages.rs +++ b/crates/client/src/gui/builder/messages.rs @@ -17,6 +17,7 @@ use super::ui::{ list_row, start_of_day_ms, }; use crate::gui::YEAR_STAMP; +use crate::gui::style::{size, space, text}; use crate::gui::{ Palette, Yumush, avatar, community_settings::user_name, @@ -88,12 +89,12 @@ fn message_hit_row( .min_w_0() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child( div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .min_w_0() .child(user_link( format!("hit_author_{}", hit.message.id), @@ -101,7 +102,7 @@ fn message_hit_row( entity, div() .truncate() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .font_weight(FontWeight::MEDIUM) .text_color(palette.text) .child(user_name(&hit.author).to_string()), @@ -110,21 +111,21 @@ fn message_hit_row( div() .min_w_0() .truncate() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(hit.community.clone()), ) .child( div() .flex_shrink_0() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(millis_time(hit.message.created_at, YEAR_STAMP)), ), ) .child( div() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.body) .line_clamp(2) .child(hit.message.body.clone()), @@ -134,7 +135,7 @@ fn message_hit_row( div() .flex() .items_center() - .gap(px(4.)) + .gap(px(space::XS)) .flex_shrink_0() .child(open) .child(delete) @@ -145,11 +146,11 @@ fn message_hit_row( impl Yumush { pub(super) fn messages_body(&self, entity: &Entity, palette: Palette) -> Vec { let filters = div() - .px(px(14.)) - .py(px(12.)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .flex_col() - .gap(px(8.)) + .gap(px(space::SM)) .child( div().flex().child( div() @@ -163,7 +164,7 @@ impl Yumush { .flex() .flex_wrap() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .children( [ &self.chat.builder_message_user, @@ -171,7 +172,7 @@ impl Yumush { &self.chat.builder_message_from, &self.chat.builder_message_to, ] - .map(|input| div().flex_1().min_w(px(140.)).child(field(palette, input))), + .map(|input| div().flex_1().min_w(px(size::THUMB)).child(field(palette, input))), ) .child(accent_button( "search_messages", @@ -193,9 +194,9 @@ impl Yumush { .as_ref() .is_some_and(|author| self.chat.pending_builder_purge == Some(author.id)); let picture = match &hit.author { - Some(author) => avatar(palette, author, px(28.), text(11.), &self.chat.avatars), + Some(author) => avatar(palette, author, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), None => div() - .size(px(28.)) + .size(px(size::AVATAR)) .flex_shrink_0() .rounded_full() .bg(palette.hover), diff --git a/crates/client/src/gui/builder/overview.rs b/crates/client/src/gui/builder/overview.rs index 8c4b103..f136c61 100644 --- a/crates/client/src/gui/builder/overview.rs +++ b/crates/client/src/gui/builder/overview.rs @@ -8,9 +8,14 @@ use gpui_kit::{Context, Div, IntoElement, ParentElement, Styled, Window, div, px use jiff::Timestamp; use super::ui::{card, card_header, stat_tile}; -use crate::gui::{DAY, Palette, Yumush, storage, text}; +use crate::gui::{ + DAY, Palette, Yumush, storage, + style::{radius, size, space, text}, + text, +}; const CHART_HEIGHT: f32 = 80.; +const PANEL_HEIGHT: f32 = 140.; fn day_label(day: u64) -> String { Timestamp::from_millisecond((day * DAY_MILLIS) as i64) @@ -19,10 +24,10 @@ fn day_label(day: u64) -> String { } fn tile_row(tiles: &[(&str, String)], palette: Palette) -> Div { - div().flex().gap(px(12.)).children( + div().flex().gap(px(space::MD)).children( tiles .iter() - .map(|(label, value)| stat_tile(label, value, palette).flex_1().min_w(px(200.))), + .map(|(label, value)| stat_tile(label, value, palette).flex_1().min_w(px(size::SIDEBAR))), ) } @@ -51,7 +56,7 @@ fn bar_chart( title, vec![ div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(summary.to_string()) .into_any_element(), @@ -60,15 +65,15 @@ fn bar_chart( )) .child( div() - .h(px(140.)) - .px(px(14.)) - .py(px(12.)) + .h(px(PANEL_HEIGHT)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .flex_col() - .gap(px(4.)) + .gap(px(space::XS)) .child( div() - .text_size(text(10.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(maximum.to_string()), ) @@ -77,28 +82,28 @@ fn bar_chart( .h(px(CHART_HEIGHT)) .flex() .items_end() - .gap(px(2.)) + .gap(px(space::XXS)) .children(values.iter().map(|&value| { let (height, color) = if value == 0 { - (2., palette.hover) + (space::XXS, palette.hover) } else { ( - (CHART_HEIGHT * value as f32 / maximum as f32).max(2.), - palette.accent.opacity(0.85), + (CHART_HEIGHT * value as f32 / maximum as f32).max(space::XXS), + palette.accent, ) }; - div().flex_1().h(px(height)).rounded_t(px(2.)).bg(color) + div().flex_1().h(px(height)).rounded_t(px(radius::SM)).bg(color) })), ) .child( div() - .pt(px(4.)) + .pt(px(space::XS)) .border_t_1() .border_color(palette.border) .flex() .justify_between() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(first) .child(last), @@ -149,7 +154,7 @@ impl Yumush { rows.push( div() .flex() - .gap(px(12.)) + .gap(px(space::MD)) .child(bar_chart( "Active users", stats, diff --git a/crates/client/src/gui/builder/reports.rs b/crates/client/src/gui/builder/reports.rs index 4fb8dea..e9b81a8 100644 --- a/crates/client/src/gui/builder/reports.rs +++ b/crates/client/src/gui/builder/reports.rs @@ -19,7 +19,8 @@ use crate::{ entity_action, millis_time, notify_error, profile::user_link, settings_page::{segment, segment_track}, - text, + style::{radius, size, space, text}, + text as text_fn, }, net::{Fail, NetworkHandle}, }; @@ -180,7 +181,7 @@ impl Yumush { self.chat.report_filter == status, palette, ) - .px(px(10.)) + .px(px(space::MD)) .child(label) })), ) @@ -207,17 +208,29 @@ impl Yumush { palette: Palette, ) -> Div { let target_avatar = match &report.target { - Some(user) => { - avatar(palette, user, px(20.), text(9.), &self.chat.avatars).into_any_element() - } - None => badge(palette, report.id, "someone", px(20.), text(9.)).into_any_element(), + Some(user) => avatar( + palette, + user, + px(size::AVATAR), + text_fn(text::CAPTION), + &self.chat.avatars, + ) + .into_any_element(), + None => badge( + palette, + report.id, + "someone", + px(size::AVATAR), + text_fn(text::CAPTION), + ) + .into_any_element(), }; let head = div() .flex_1() .min_w_0() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child(user_link( format!("report_target_{}", report.id), report.target.as_ref(), @@ -225,7 +238,7 @@ impl Yumush { div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child(target_avatar) .child( div() @@ -244,14 +257,14 @@ impl Yumush { report.reporter.as_ref(), entity, div() - .text_size(text(11.)) + .text_size(text_fn(text::CAPTION)) .text_color(palette.muted) .truncate() .child(format!("reported by {}", user_name(&report.reporter))), )); let meta = div() .flex_shrink_0() - .text_size(text(11.)) + .text_size(text_fn(text::CAPTION)) .text_color(palette.muted) .child(format!( "{} · {}", @@ -261,38 +274,38 @@ impl Yumush { let actions = self.report_actions(report, entity, palette); let handled = (report.status != ReportStatus::Open).then(|| { div() - .text_size(text(11.)) + .text_size(text_fn(text::CAPTION)) .text_color(palette.muted) .child(format!("by {}", user_name(&report.handled_by))) }); div() - .px(px(14.)) - .py(px(10.)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::SM)) .child( div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child(head) .child(meta), ) .child( div() - .text_size(text(13.)) + .text_size(text_fn(text::LABEL)) .text_color(palette.body) .child(report.reason.clone()), ) .children(report.body.as_ref().map(|body| { div() - .px(px(8.)) - .py(px(6.)) - .rounded(px(6.)) + .px(px(space::SM)) + .py(px(space::SM)) + .rounded(px(radius::MD)) .bg(palette.window) - .text_size(text(12.)) + .text_size(text_fn(text::CAPTION)) .text_color(palette.muted) .line_clamp(2) .child(body.clone()) @@ -303,7 +316,7 @@ impl Yumush { .flex() .flex_wrap() .items_center() - .gap(px(4.)) + .gap(px(space::XS)) .children(actions) })) } diff --git a/crates/client/src/gui/builder/storage.rs b/crates/client/src/gui/builder/storage.rs index 34970a7..a0a1858 100644 --- a/crates/client/src/gui/builder/storage.rs +++ b/crates/client/src/gui/builder/storage.rs @@ -18,7 +18,9 @@ use super::ui::{ }; use crate::gui::{ DATE, Palette, Yumush, community_settings::user_name, entity_action, millis_time, notify_error, - storage, text, widget::field, + storage, + style::{radius, size, space, text}, + text, widget::field, }; fn share(bytes: u64, max: u64) -> f32 { @@ -31,50 +33,50 @@ fn share(bytes: u64, max: u64) -> f32 { fn usage_row(name: &str, bytes: u64, count: u64, fraction: f32, palette: Palette) -> Div { div() - .px(px(14.)) - .py(px(8.)) + .px(px(space::LG)) + .py(px(space::SM)) .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::SM)) .child( div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() .flex_1() .min_w_0() .truncate() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.text) .child(name.to_string()), ) .child( div() .flex_shrink_0() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .font_weight(FontWeight::MEDIUM) .text_color(palette.text) .child(storage(bytes)), ) .child( div() - .w(px(48.)) + .w(px(size::ROW)) .flex_shrink_0() .flex() .justify_end() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(count.to_string()), ), ) .child( - div().h(px(3.)).rounded(px(3.)).bg(palette.hover).child( + div().h(px(space::XXS)).rounded(px(radius::SM)).bg(palette.hover).child( div() .h_full() .w(relative(fraction)) - .rounded(px(3.)) + .rounded(px(radius::SM)) .bg(palette.accent), ), ) @@ -99,8 +101,7 @@ fn attachment_row( list_row() .child( Icon::new(IconName::File) - .w(px(16.)) - .h(px(16.)) + .size(px(size::ICON)) .flex_shrink_0() .text_color(palette.muted), ) @@ -110,18 +111,18 @@ fn attachment_row( .min_w_0() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child( div() .truncate() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.text) .child(info.attachment.name.clone()), ) .child( div() .truncate() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(format!( "{} · {} · {}", @@ -134,7 +135,7 @@ fn attachment_row( .child( div() .flex_shrink_0() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(storage(info.attachment.size)), ) @@ -188,7 +189,7 @@ impl Yumush { let usage = div() .flex() - .gap(px(20.)) + .gap(px(space::XL)) .child( div() .flex_1() @@ -200,9 +201,9 @@ impl Yumush { )); let controls = toolbar(vec![ - fixed(160., field(palette, &self.chat.builder_attachment_user)), + fixed(size::THUMB, field(palette, &self.chat.builder_attachment_user)), fixed( - 160., + size::THUMB, field(palette, &self.chat.builder_attachment_community), ), accent_button( @@ -227,10 +228,10 @@ impl Yumush { .collect(); let body = if rows.is_empty() { div() - .py(px(24.)) + .py(px(space::XL)) .flex() .justify_center() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child("No attachments") } else { diff --git a/crates/client/src/gui/builder/ui.rs b/crates/client/src/gui/builder/ui.rs index bba0097..54753bc 100644 --- a/crates/client/src/gui/builder/ui.rs +++ b/crates/client/src/gui/builder/ui.rs @@ -1,3 +1,4 @@ +use crate::gui::style::{radius, size, space, text}; use crate::gui::{Palette, Tooltip as _, clickable, primary_button, text, widget}; use gpui_kit::{ AnyElement, App, Div, FontWeight, Hsla, IntoElement, ParentElement, Stateful, Styled, Window, @@ -5,6 +6,8 @@ use gpui_kit::{ }; use jiff::{civil::Date, tz::TimeZone}; +const LABEL_WIDTH: f32 = 88.; + pub(super) fn to_bytes(text: &str, unit: u64) -> Option { text.trim().parse::().ok()?.checked_mul(unit) } @@ -76,16 +79,16 @@ pub(super) fn action_button( ) -> Stateful
{ clickable(id, palette, action) .tip(tip) - .h(px(28.)) - .px(px(10.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(6.)) - .rounded(px(6.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) + .text_size(text(text::CAPTION)) .font_weight(FontWeight::MEDIUM) .text_color(color) - .child(Icon::new(icon).w(px(14.)).h(px(14.))) + .child(Icon::new(icon).size(px(size::ICON_SM))) .child(label) } @@ -129,15 +132,15 @@ pub(super) fn action_group( div() .flex() .items_start() - .gap(px(12.)) + .gap(px(space::MD)) .child( div() - .w(px(88.)) - .h(px(28.)) + .w(px(LABEL_WIDTH)) + .h(px(size::CONTROL_SM)) .flex_shrink_0() .flex() .items_center() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .font_weight(FontWeight::MEDIUM) .text_color(palette.muted) .child(title), @@ -148,8 +151,8 @@ pub(super) fn action_group( .min_w_0() .flex() .flex_col() - .gap(px(4.)) - .child(div().flex().flex_wrap().gap(px(4.)).children(children)), + .gap(px(space::XS)) + .child(div().flex().flex_wrap().gap(px(space::XS)).children(children)), ), ) } @@ -161,15 +164,15 @@ pub(super) fn danger_button( action: impl Fn(&mut Window, &mut App) + 'static, ) -> impl IntoElement { clickable(id, palette, action) - .h(px(28.)) - .px(px(12.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .rounded(px(6.)) - .text_size(text(12.)) + .rounded(px(radius::MD)) + .text_size(text(text::CAPTION)) .font_weight(FontWeight::MEDIUM) .border_1() - .border_color(palette.danger.opacity(0.5)) + .border_color(palette.border) .text_color(palette.danger) .child(label) } @@ -196,10 +199,10 @@ pub(super) fn end_of_day_ms(text: &str) -> Option { pub(super) fn rows_body(rows: Vec
, empty: &str, palette: Palette) -> Div { if rows.is_empty() { return div() - .py(px(24.)) + .py(px(space::XL)) .flex() .justify_center() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(empty.to_string()); } @@ -220,12 +223,12 @@ pub(super) fn accent_button( action: impl Fn(&mut Window, &mut App) + 'static, ) -> impl IntoElement { primary_button(id, palette, action) - .h(px(28.)) - .px(px(12.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .rounded(px(6.)) - .text_size(text(12.)) + .rounded(px(radius::MD)) + .text_size(text(text::CAPTION)) .font_weight(FontWeight::MEDIUM) .child(label) } @@ -237,12 +240,12 @@ pub(super) fn plain_button( action: impl Fn(&mut Window, &mut App) + 'static, ) -> impl IntoElement { clickable(id, palette, action) - .h(px(28.)) - .px(px(12.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .rounded(px(6.)) - .text_size(text(12.)) + .rounded(px(radius::MD)) + .text_size(text(text::CAPTION)) .font_weight(FontWeight::MEDIUM) .text_color(palette.muted) .child(label) @@ -252,26 +255,24 @@ pub(super) fn card(palette: Palette) -> Div { div() .flex() .flex_col() - .rounded(px(10.)) - .border_1() - .border_color(palette.border) + .rounded(px(radius::MD)) .bg(palette.panel) .overflow_hidden() } pub(super) fn card_header(title: &str, actions: Vec, palette: Palette) -> Div { div() - .px(px(14.)) - .py(px(10.)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .items_center() .justify_between() - .gap(px(8.)) + .gap(px(space::SM)) .border_b_1() .border_color(palette.border) .child( div() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .font_weight(FontWeight::MEDIUM) .text_color(palette.text) .child(title.to_string()), @@ -282,10 +283,10 @@ pub(super) fn card_header(title: &str, actions: Vec, palette: Palett pub(super) fn list_card(title: Option<&str>, rows: Vec
, empty: &str, palette: Palette) -> Div { let body = if rows.is_empty() { div() - .py(px(24.)) + .py(px(space::XL)) .flex() .justify_center() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(empty.to_string()) } else { @@ -306,12 +307,12 @@ pub(super) fn list_card(title: Option<&str>, rows: Vec
, empty: &str, palett pub(super) fn list_row() -> Div { div() - .min_h(px(44.)) - .px(px(14.)) - .py(px(10.)) + .min_h(px(size::ROW)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) } pub(super) fn toolbar(items: Vec) -> Div { @@ -319,24 +320,24 @@ pub(super) fn toolbar(items: Vec) -> Div { .flex() .flex_wrap() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .children(items) } pub(super) fn stat_tile(label: &str, value: &str, palette: Palette) -> Div { card(palette) - .p(px(14.)) - .gap(px(4.)) + .p(px(space::LG)) + .gap(px(space::XS)) .child( div() - .text_size(text(22.)) + .text_size(text(text::TITLE)) .font_weight(FontWeight::SEMIBOLD) .text_color(palette.text) .child(value.to_string()), ) .child( div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(label.to_string()), ) @@ -358,27 +359,27 @@ pub(super) fn field_row( .flex_col() .child( div() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.text) .child(label.to_string()), ) .children(hint.map(|hint| { div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(hint.to_string()) })), ) - .child(div().w(px(220.)).flex_shrink_0().child(control)) + .child(div().w(px(size::SIDEBAR)).flex_shrink_0().child(control)) } pub(super) fn pill(label: &str, color: Hsla, palette: Palette) -> Div { div() - .px(px(6.)) - .py(px(1.)) - .rounded(px(4.)) + .px(px(space::SM)) + .py(px(space::XXS)) + .rounded(px(radius::SM)) .bg(palette.hover) - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(color) .child(label.to_string()) } @@ -388,10 +389,10 @@ pub(super) fn page_heading(title: &str, actions: Vec, palette: Palet .flex() .items_center() .justify_between() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() - .text_size(text(20.)) + .text_size(text(text::TITLE)) .font_weight(FontWeight::SEMIBOLD) .text_color(palette.text) .child(title.to_string()), diff --git a/crates/client/src/gui/builder/users.rs b/crates/client/src/gui/builder/users.rs index a5989b6..12f0da8 100644 --- a/crates/client/src/gui/builder/users.rs +++ b/crates/client/src/gui/builder/users.rs @@ -28,6 +28,7 @@ use crate::{ notify_error, profile::user_link, text, + style::{radius, size, space, text}, widget::{field, search_text}, }, net::{Fail, NetworkHandle}, @@ -422,30 +423,30 @@ impl Yumush { }; let toolbar = div() - .px(px(14.)) - .py(px(10.)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .flex_wrap() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .border_b_1() .border_color(palette.border) .child( div() .flex_1() - .min_w(px(160.)) + .min_w(px(size::THUMB)) .child(Input::new(&self.chat.builder_search)), ) .child( div() .flex_1() - .min_w(px(120.)) + .min_w(px(size::THUMB)) .child(field(palette, &self.chat.new_username)), ) .child( div() .flex_1() - .min_w(px(120.)) + .min_w(px(size::THUMB)) .child(field(palette, &self.chat.new_password)), ) .child(accent_button( @@ -459,10 +460,10 @@ impl Yumush { let body = if rows.is_empty() { div() - .py(px(24.)) + .py(px(space::XL)) .flex() .justify_center() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child("No users".to_string()) } else { @@ -486,11 +487,11 @@ impl Yumush { palette: Palette, ) -> Div { div() - .h(px(40.)) - .px(px(12.)) + .h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() .flex_1() @@ -520,11 +521,11 @@ impl Yumush { }; div() - .h(px(40.)) - .px(px(12.)) + .h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() .flex_1() @@ -575,20 +576,19 @@ impl Yumush { div() .w_full() - .h(px(28.)) + .h(px(size::CONTROL_SM)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( Icon::new(IconName::Monitor) - .w(px(14.)) - .h(px(14.)) + .size(px(size::ICON_SM)) .text_color(palette.muted), ) .child( div() .flex_1() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .min_w_0() .truncate() .child(device.to_string()), @@ -596,7 +596,7 @@ impl Yumush { .child( div() .flex_shrink_0() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(seen_text(session.last_seen)), ) @@ -610,11 +610,11 @@ impl Yumush { palette: Palette, ) -> Div { div() - .h(px(40.)) - .px(px(12.)) + .h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() .flex_1() @@ -638,11 +638,11 @@ impl Yumush { palette: Palette, ) -> Div { div() - .h(px(40.)) - .px(px(12.)) + .h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() .flex_1() @@ -774,15 +774,15 @@ impl Yumush { }), ) .tip("Manage") - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex_shrink_0() .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.muted) .when(expanded, |this| this.bg(palette.hover)) - .child(Icon::new(IconName::Ellipsis).w(px(16.)).h(px(16.))); + .child(Icon::new(IconName::Ellipsis).size(px(size::ICON))); let rename_button = action_button( format!("rename_user_{}", user.id), @@ -857,16 +857,16 @@ impl Yumush { ); let row = div() - .px(px(14.)) - .py(px(10.)) + .px(px(space::LG)) + .py(px(space::MD)) .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .child(user_link( format!("builder_user_avatar_{}", user.id), Some(user), entity, - avatar(palette, user, px(28.), text(11.), &self.chat.avatars), + avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), )) .child( div() @@ -874,20 +874,20 @@ impl Yumush { .min_w_0() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child( div() .min_w_0() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child(user_link( format!("builder_user_name_{}", user.id), Some(user), entity, div() .truncate() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .font_weight(FontWeight::MEDIUM) .text_color(palette.text) .child(user.username.clone()), @@ -909,7 +909,7 @@ impl Yumush { div() .min_w_0() .truncate() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(format!("joined {joined} · seen {seen}")), ), @@ -950,9 +950,9 @@ impl Yumush { div() .flex() .flex_col() - .gap(px(8.)) - .px(px(14.)) - .py(px(10.)) + .gap(px(space::SM)) + .px(px(space::LG)) + .py(px(space::MD)) .bg(palette.window) .border_t_1() .border_color(palette.border) diff --git a/crates/client/src/gui/builder/voice.rs b/crates/client/src/gui/builder/voice.rs index 867760c..6ca701b 100644 --- a/crates/client/src/gui/builder/voice.rs +++ b/crates/client/src/gui/builder/voice.rs @@ -12,7 +12,11 @@ use gpui_kit::{ use super::ui::{card, card_header, icon_button, list_card, pill, rows_body}; use crate::{ - gui::{Palette, Yumush, avatar, entity_action, notify_error, profile::user_link, text}, + gui::{ + Palette, Yumush, avatar, entity_action, notify_error, profile::user_link, + style::{self, size, space}, + text, + }, net::{Fail, NetworkHandle}, }; @@ -173,12 +177,12 @@ impl Yumush { let kick_id = id; div() - .min_h(px(44.)) - .px(px(14.)) - .py(px(8.)) + .min_h(px(size::ROW)) + .px(px(space::LG)) + .py(px(space::SM)) .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .child( div().flex_1().min_w_0().flex().child(user_link( format!("voice_user_{id}"), @@ -187,19 +191,19 @@ impl Yumush { div() .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .child(avatar( palette, user, - px(24.), - text(10.), + px(size::AVATAR), + text(style::text::CAPTION), &self.chat.avatars, )) .child( div() .min_w_0() .truncate() - .text_size(text(13.)) + .text_size(text(style::text::LABEL)) .text_color(palette.text) .child(user.username.clone()), ), diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 88c7d7b..93cf56c 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -6,18 +6,24 @@ use common::share::{Fps, Kind, Quality, Resolution}; use gpui_kit::{ AnyElement, AppContext as _, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement, StatefulInteractiveElement, Styled, Task, Window, assets::IconName, - component::Icon, div, px, + component::Icon, div, px, transparent_black, }; use super::{ Palette, Tooltip as _, Yumush, avatar, clickable, media_view::into_render_image, notify_error, - share_view, surface::Surface, text, wave::mini_wave, widget::spawn_warn, + share_view, + style::{radius, size, space, text}, + parts::{Voice, caption, voice_line}, + surface::Surface, text, wave::mini_wave, widget::spawn_warn, }; use crate::share::session::WatchQuality; const IDLE_TICK: Duration = Duration::from_millis(250); const FRAME_TICK: Duration = Duration::from_millis(16); const PUMP_STALL: Duration = Duration::from_millis(50); +const STRIP_H: f32 = 206.; +const TILE_W: f32 = 338.; +const TILE_H: f32 = 190.; pub(super) const TILE_QUALITY: WatchQuality = WatchQuality::Fixed(Quality { resolution: Resolution::P360, @@ -215,23 +221,56 @@ impl Yumush { .into_iter() .map(|source| stage_tile(entity, self, palette, source)) .collect(); + if tiles.is_empty() { + return Some(self.voices(palette).into_any_element()); + } Some( div() .id("stage_strip") .flex() .flex_shrink_0() - .h(px(206.)) - .gap(px(8.)) - .p(px(8.)) + .h(px(STRIP_H)) + .gap(px(space::SM)) + .p(px(space::SM)) .bg(palette.window) .overflow_x_scroll() .border_b_1() .border_color(palette.border) - .children(tiles), + .children(tiles) + .into_any_element(), ) } + fn voices(&self, palette: Palette) -> Div { + let t = palette.tokens; + let people = self + .chat + .voice_community() + .map(|community_id| self.chat.voice_ids(community_id)) + .unwrap_or_default() + .into_iter() + .filter_map(|id| self.chat.author(*id)) + .map(|user| { + let speaking = self.chat.waves.speaking.contains(&user.id); + let voice = if speaking { + Voice::Live(t.person(user.id)) + } else { + Voice::Quiet + }; + caption(user.username.clone(), voice_line(self.chat.waves.voice(user.id), voice, t), t) + .w(px(size::TALK)) + }); + div() + .flex() + .flex_col() + .flex_shrink_0() + .gap(px(space::MD)) + .px(px(space::XL)) + .py(px(space::XL)) + .children(people) + } + pub(super) fn stage_grid( &self, entity: &Entity, @@ -273,17 +312,17 @@ impl Yumush { .relative() .flex_1() .min_h_0() - .p(px(8.)) + .p(px(space::SM)) .bg(palette.window) .flex() .flex_col() - .gap(px(8.)) + .gap(px(space::SM)) .children((0..rows).map(|_| { div() .flex_1() .min_h_0() .flex() - .gap(px(8.)) + .gap(px(space::SM)) .children((0..columns).map(|_| { cells .next() @@ -368,8 +407,8 @@ fn stage_tile( .child(avatar( palette, user, - px(56.), - text(20.), + px(size::AVATAR_LG), + text(text::TITLE), &yumush.chat.avatars, )) .into_any_element(), @@ -388,9 +427,9 @@ fn stage_tile( .tip("Watch") .relative() .flex_shrink_0() - .w(px(338.)) - .h(px(190.)) - .rounded(px(10.)) + .w(px(TILE_W)) + .h(px(TILE_H)) + .rounded(px(radius::MD)) .overflow_hidden() .bg(gpui_kit::black()) .border_2() @@ -399,14 +438,14 @@ fn stage_tile( } else if speaking { palette.ok } else { - palette.ok.opacity(0.) + transparent_black() }) .child(content) .child( tile_label(yumush, palette, (user_id, kind)) .absolute() - .left(px(8.)) - .bottom(px(8.)), + .left(px(space::SM)) + .bottom(px(space::SM)), ) } @@ -435,8 +474,8 @@ fn grid_cell( .child(avatar( palette, user, - px(64.), - text(24.), + px(size::AVATAR_LG), + text(text::TITLE), &yumush.chat.avatars, )) .into_any_element(), @@ -449,21 +488,21 @@ fn grid_cell( .flex_1() .min_w_0() .min_h_0() - .rounded(px(10.)) + .rounded(px(radius::MD)) .overflow_hidden() .bg(gpui_kit::black()) .border_2() .border_color(if speaking { palette.ok } else { - palette.ok.opacity(0.) + transparent_black() }) .child(content) .child( tile_label(yumush, palette, (user_id, kind)) .absolute() - .left(px(8.)) - .bottom(px(8.)), + .left(px(space::SM)) + .bottom(px(space::SM)), ); if shared { @@ -506,33 +545,29 @@ pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, kind): (Id || (yumush.is_me(user_id) && yumush.chat.voice_flags().is_some_and(|(muted, _)| muted)); div() - .h(px(24.)) - .px(px(8.)) - .rounded(px(12.)) - .bg(gpui_kit::black().opacity(0.72)) - .border_1() - .border_color(palette.tinted(user_id).opacity(0.7)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) + .rounded(px(radius::LG)) + .bg(gpui_kit::black()) .flex() .items_center() - .gap(px(6.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .children(shared.then(|| { Icon::new(share_view::kind_icon(kind)) - .w(px(13.)) - .h(px(13.)) + .size(px(size::ICON_SM)) .text_color(tone) })) .child( div() .font_weight(FontWeight::MEDIUM) - .text_color(gpui_kit::white().opacity(0.95)) + .text_color(gpui_kit::white()) .child(name.to_string()), ) .children(wave.map(|history| mini_wave(history, 10., palette.ok))) .children((muted && wave.is_none()).then(|| { Icon::new(IconName::MicOff) - .w(px(12.)) - .h(px(12.)) + .size(px(size::ICON_SM)) .text_color(palette.danger) })) } diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 3331387..7fcbee7 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -1,3 +1,4 @@ +use super::style::{radius, size, space, stroke, text}; use super::text; use crate::gui::CLOCK; use std::{ @@ -11,7 +12,7 @@ use crate::gui::social::InviteLookup; use crate::gui::voice_stats::{self, SAMPLE_HISTORY}; use crate::gui::wave::Waves; use crate::gui::{ - FIND_HINT, Palette, Tooltip as _, Yumush, avatar, badge, + FIND_HINT, Palette, Tooltip as _, Yumush, avatar, builder::{BuilderTab, Transfer}, clickable, community_name, community_settings::{BanSort, LogSort}, @@ -1226,15 +1227,15 @@ fn empty_state(palette: Palette) -> impl IntoElement { .flex() .items_center() .justify_center() - .gap(px(8.)) + .gap(px(space::SM)) .text_color(palette.muted) .child( div() - .px(px(5.)) - .rounded(px(4.)) + .px(px(space::XS)) + .rounded(px(radius::SM)) .border_1() .border_color(palette.border) - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .child(FIND_HINT), ) .child("Find a user") @@ -1266,7 +1267,6 @@ pub(super) fn create_community( struct MembersTrigger { palette: Palette, members: Vec, - avatars: HashMap>, } impl Selectable for MembersTrigger { @@ -1282,31 +1282,19 @@ impl Selectable for MembersTrigger { impl RenderOnce for MembersTrigger { fn render(self, _: &mut Window, _: &mut App) -> impl IntoElement { let palette = self.palette; - let avatars = self - .members - .iter() - .take(3) - .enumerate() - .map(|(index, user)| { - avatar(palette, user, px(18.), text(9.), &self.avatars) - .border_2() - .border_color(palette.panel) - .when(index > 0, |this| this.ml(px(-6.))) - }); hoverable( "members_trigger", div() - .h(px(28.)) - .px(px(8.)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) .flex() .items_center() - .gap(px(6.)) - .rounded(px(6.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) + .text_size(text(text::LABEL)) .text_color(palette.muted) - .child(div().flex().children(avatars)) - .child(self.members.len().to_string()), + .child(format!("{} people", self.members.len())), palette, ) } @@ -1332,15 +1320,9 @@ impl Yumush { div() .flex_1() .min_w_0() - .mt(px(8.)) - .mr(px(8.)) - .mb(px(8.)) .flex() .flex_col() - .rounded(px(10.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) + .bg(palette.window) .overflow_hidden() .children(self.announcement_banner(entity, palette)) .children(self.call_banner(entity, palette)) @@ -1368,7 +1350,7 @@ impl Yumush { Some(grid) => panel.child(grid), None => panel .child(self.message_area(entity, themed)) - .child(self.composer(entity, themed)), + .child(self.composer(entity, themed, cx)), }, } })) @@ -1384,9 +1366,9 @@ impl Yumush { (self.chat.stats_open && self.in_stage_chat()).then(|| { div() .id("stats_side") - .w(px(380.)) + .w(px(size::SHEET)) .flex_shrink_0() - .p(px(10.)) + .p(px(space::MD)) .border_l_1() .border_color(palette.border) .overflow_y_scroll() @@ -1416,23 +1398,12 @@ impl Yumush { community.is_some_and(|community| matches!(community.kind, CommunityKind::Group)); div() - .h(px(44.)) - .pl(px(20.)) - .pr(px(12.)) + .h(px(size::ROW + space::MD)) + .px(px(space::XL)) .flex() .items_center() - .gap(px(8.)) - .border_b_2() - .border_color(palette.accent) - .children( - community - .map(|community| self.community_badge(community, px(20.), text(10.), palette)), - ) - .child( - div() - .font_weight(FontWeight::SEMIBOLD) - .child(name.to_string()), - ) + .gap(px(space::SM)) + .child(super::parts::words(name.to_string(), super::parts::Text::Title, super::parts::Ink::Paper, palette.tokens)) .child(div().flex_1()) .children( community @@ -1461,6 +1432,15 @@ impl Yumush { .flex_1() .min_h_0() .relative() + .child( + div() + .absolute() + .left(px(space::XL)) + .top_0() + .bottom_0() + .w(px(stroke::LINE)) + .bg(palette.border), + ) .child(self.message_list(entity, palette)) .children(self.jump_bottom(entity, palette)) } @@ -1476,7 +1456,7 @@ impl Yumush { .child( div() .flex() - .gap(px(8.)) + .gap(px(space::SM)) .child( clickable( "jump_unread", @@ -1517,22 +1497,22 @@ impl Yumush { }), ) .absolute() - .right(px(16.)) - .bottom(px(12.)) - .size(px(36.)) + .right(px(space::LG)) + .bottom(px(space::MD)) + .size(px(size::CONTROL)) .flex() .items_center() .justify_center() .rounded_full() .border_1() .border_color(palette.border) - .bg(palette.panel) - .child(Icon::new(IconName::ArrowDown).w(px(16.)).h(px(16.))) + .bg(palette.window) + .child(Icon::new(IconName::ArrowDown).size(px(size::ICON))) .children((unseen > 0).then(|| { div() .absolute() - .top(px(-6.)) - .right(px(-6.)) + .top(px(-space::SM)) + .right(px(-space::SM)) .children(unread_badge( palette, false, @@ -1558,9 +1538,10 @@ impl Yumush { .flex_1() .min_w_0() .overflow_y_scroll() - .px(px(24.)) - .py(px(20.)) - .gap(px(2.)) + .pl(px(space::XL + space::LG)) + .pr(px(space::XL)) + .py(px(space::LG)) + .gap(px(space::XXS)) .on_scroll(move |_, window, _| { let entity = entity_scroll.clone(); window.on_next_frame(move |_, cx| { @@ -1578,8 +1559,10 @@ impl Yumush { .iter() .enumerate() .map(|(index, message)| { - let first = - index == 0 || self.chat.messages[index - 1].user_id != message.user_id; + let first = index == 0 || { + let previous = &self.chat.messages[index - 1]; + previous.user_id != message.user_id || previous.call.is_some() + }; let row = render_message( message, first, @@ -1603,10 +1586,10 @@ impl Yumush { ) } - fn composer(&self, entity: &Entity, palette: Palette) -> AnyElement { + fn composer(&self, entity: &Entity, palette: Palette, cx: &App) -> AnyElement { if let Composer::Select { ids } = &self.chat.composer { return div() - .p(px(16.)) + .p(px(space::LG)) .child(composer::selection_bar(ids, entity, palette)) .into_any_element(); } @@ -1621,7 +1604,7 @@ impl Yumush { } = &self.chat.media.voice_note { return div() - .p(px(16.)) + .p(px(space::LG)) .children(pending) .child(voice_note::recording_row( *started, levels, &entity, palette, @@ -1629,52 +1612,57 @@ impl Yumush { .into_any_element(); } - composer::format_actions(&self.chat.message_input, div().p(px(16.))) + let has_text = self.chat.message_input.read(cx).text().len() > 0; + + composer::format_actions( + &self.chat.message_input, + div() + .p(px(space::LG)) + .border_t_1() + .border_color(palette.border), + ) .children(pending) .children(bar) .children(self.chat.typing_label().map(|label| { div() - .pl(px(4.)) - .pb(px(4.)) - .text_size(text(12.)) + .pl(px(space::XS)) + .pb(px(space::XS)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(label) })) .child( div() - .min_h(px(40.)) - .pl(px(4.)) - .pr(px(4.)) - .py(px(4.)) + .min_h(px(size::ROW)) + .pl(px(space::XS)) + .pr(px(space::XS)) + .py(px(space::XS)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(8.)) - .border_1() - .border_color(palette.border) - .bg(palette.field) + .gap(px(space::SM)) .child(composer::plus_popover(&self.chat, &entity, palette)) .child(composer::format_popover(palette)) .child( Textarea::new(&self.chat.message_input) .appearance(false) + .text_size(text(text::BODY)) .text_color(palette.text) .flex_1() .min_w_0(), ) .child(voice_note::mic_button(&entity, palette)) .child( - primary_button("send_button", palette, move |window, cx| { + clickable("send_button", palette, move |window, cx| { entity .update(cx, |yumush, cx| yumush.submit_composer(&input, window, cx)) }) .tip("Send") - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) - .child(Icon::new(IconName::ArrowUp).w(px(14.)).h(px(14.))), + .text_color(if has_text { palette.text } else { palette.muted }) + .child(Icon::new(IconName::ArrowUp).size(px(size::ICON_SM))), ), ) .into_any_element() @@ -2207,10 +2195,10 @@ impl Yumush { div() .flex() .flex_col() - .gap(px(14.)) + .gap(px(space::LG)) .child( div() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.muted) .child("Everyone in the call will hear you."), ) @@ -2218,16 +2206,16 @@ impl Yumush { div() .flex() .justify_end() - .gap(px(8.)) + .gap(px(space::SM)) .child( clickable("ghost_speak_cancel", palette, |window, cx| { window.close_dialog(cx) }) - .h(px(30.)) - .px(px(14.)) + .h(px(size::CONTROL)) + .px(px(space::LG)) .flex() .items_center() - .rounded(px(8.)) + .rounded(px(radius::MD)) .text_color(palette.muted) .child("Cancel"), ) @@ -2240,11 +2228,11 @@ impl Yumush { speak.update(cx, |yumush, cx| yumush.set_muted(false, cx)); }, ) - .h(px(30.)) - .px(px(14.)) + .h(px(size::CONTROL)) + .px(px(space::LG)) .flex() .items_center() - .rounded(px(8.)) + .rounded(px(radius::MD)) .child("Speak"), ), ), @@ -2412,22 +2400,18 @@ impl Yumush { (false, true) => (IconName::Headphones, "Leave voice"), }; let id = format!("voice_button_{direct}_{in_voice}"); - let button = if in_voice { - primary_button(id.clone(), palette, on_click) - .when(direct, |button| button.bg(palette.danger)) - } else { - clickable(id, palette, on_click).text_color(palette.accent) - }; + let color = if in_voice { palette.danger } else { palette.muted }; Some( - button + clickable(id, palette, on_click) + .text_color(color) .tip(tip) - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) - .child(Icon::new(icon).w(px(14.)).h(px(14.))), + .rounded_full() + .child(Icon::new(icon).size(px(size::ICON_SM))), ) } @@ -2444,7 +2428,7 @@ impl Yumush { (direct && alone).then(|| { div() .text_color(palette.muted) - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .child("Calling…") }) } @@ -2459,25 +2443,26 @@ impl Yumush { div() .flex() .items_center() - .gap(px(6.)) - .child(Icon::new(IconName::PhoneIncoming).w(px(14.)).h(px(14.))) + .gap(px(space::SM)) + .child(Icon::new(IconName::PhoneIncoming).size(px(size::ICON_SM))) .child(format!("{} is calling", caller.username)), ) .child( div() .flex() - .gap(px(6.)) + .gap(px(space::SM)) .child( - primary_button( + clickable( "accept_call", palette, entity_action(entity, move |yumush, window, cx| { yumush.accept_call(accept_id, window, cx) }), ) - .bg(palette.ok) - .px(px(8.)) - .rounded(px(4.)) + .text_color(palette.ok) + .font_weight(FontWeight::MEDIUM) + .px(px(space::SM)) + .rounded(px(radius::SM)) .child("Accept"), ) .child( @@ -2488,10 +2473,10 @@ impl Yumush { yumush.decline_call(community_id, window, cx) }), ) - .bg(palette.danger) - .text_color(palette.on_accent) - .px(px(8.)) - .rounded(px(4.)) + .text_color(palette.danger) + .font_weight(FontWeight::MEDIUM) + .px(px(space::SM)) + .rounded(px(radius::SM)) .child("Decline"), ), ), @@ -2587,36 +2572,19 @@ impl Yumush { div() .flex() .items_center() - .children(users.into_iter().take(3).enumerate().map(|(index, user)| { - let ring = if self.chat.waves.speaking.contains(&user.id) { - palette.ok - } else { - palette.panel - }; - - profile_popover( - format!("voice_{}", user.id), - Anchor::TopRight, - user, - entity, - avatar(palette, user, px(20.), text(10.), &self.chat.avatars) - .border_2() - .border_color(ring) - .cursor_pointer() - .hover(move |style| style.border_color(palette.accent)) - .when(index > 0, |this| this.ml(px(-6.))), - ) - })) + .gap(px(space::SM)) + .child( + div() + .text_size(text(text::LABEL)) + .text_color(palette.muted) + .child(format!("{} in call", users.len())), + ) .children(self.in_stage_chat().then(|| { div() - .ml(px(8.)) + .ml(px(space::SM)) .flex() .items_center() - .p(px(2.)) - .gap(px(2.)) - .rounded(px(6.)) - .border_1() - .border_color(palette.border) + .gap(px(space::XXS)) .child(stage_button( entity, palette, @@ -2673,7 +2641,6 @@ fn members_popover(entity: &Entity, yumush: &Yumush, palette: Palette) - .trigger(MembersTrigger { palette, members: members.iter().map(|row| row.user.clone()).collect(), - avatars: avatars.clone(), }) .content(move |_, _, _| { let entity = entity.clone(); @@ -2681,14 +2648,12 @@ fn members_popover(entity: &Entity, yumush: &Yumush, palette: Palette) - pop_in( "members_list", div() - .w(px(200.)) - .p(px(4.)) + .w(px(size::SIDEBAR)) + .p(px(space::XS)) .flex() .flex_col() - .rounded(px(8.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) + .rounded(px(radius::LG)) + .bg(palette.field) .children(members.iter().map( |MemberRow { user, @@ -2705,16 +2670,16 @@ fn members_popover(entity: &Entity, yumush: &Yumush, palette: Palette) - hoverable( format!("member_trigger_{}", user.id), div() - .h(px(30.)) - .px(px(8.)) + .h(px(size::CONTROL)) + .px(px(space::SM)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .child(presence_avatar( - avatar(palette, user, px(18.), text(9.), &avatars), + avatar(palette, user, px(size::ICON), text(text::CAPTION), &avatars), *presence, - px(18.), + px(size::ICON), palette, )) .child( @@ -2727,25 +2692,23 @@ fn members_popover(entity: &Entity, yumush: &Yumush, palette: Palette) - div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child(user.username.clone()) .children(rank_tag(*rank, palette)) .children(in_voice.then(|| { Icon::new(IconName::Headphones) - .w(px(12.)) - .h(px(12.)) + .size(px(size::ICON_SM)) .text_color(palette.muted) })) .children(muted.then(|| { Icon::new(IconName::MicOff) - .w(px(12.)) - .h(px(12.)) + .size(px(size::ICON_SM)) .text_color(palette.danger) })), ) .children((!user.status.is_empty()).then(|| { div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .truncate() .child(user.status.clone()) @@ -2766,23 +2729,41 @@ fn accent_bar(palette: Palette) -> Div { .flex() .items_center() .justify_between() - .gap(px(8.)) - .px(px(12.)) - .py(px(6.)) - .bg(palette.accent) - .text_color(palette.on_accent) + .gap(px(space::SM)) + .px(px(space::MD)) + .py(px(space::XS)) + .text_size(text(text::LABEL)) + .text_color(palette.text) + .border_b_1() + .border_color(palette.border) +} + +fn thread_dot(mine: bool, palette: Palette) -> Div { + let dot = div() + .absolute() + .left(px(-(space::LG + space::XS))) + .top(px(space::SM)) + .size(px(space::SM)) + .rounded_full(); + if mine { + dot.bg(palette.text) + } else { + dot.border_1() + .border_color(palette.tokens.faint()) + .bg(palette.window) + } } fn new_divider(palette: Palette) -> impl IntoElement { div() .flex() .items_center() - .gap(px(8.)) - .my(px(6.)) - .child(div().flex_1().h(px(1.)).bg(palette.accent)) + .gap(px(space::SM)) + .my(px(space::SM)) + .child(div().flex_1().h(px(stroke::LINE)).bg(palette.accent)) .child( div() - .text_size(text(10.)) + .text_size(text(text::CAPTION)) .text_color(palette.accent) .child("New"), ) @@ -2795,11 +2776,11 @@ fn older_button(entity: &Entity, palette: Palette) -> impl IntoElement { entity.update(cx, |yumush, cx| yumush.load_older_messages(window, cx)); }) .self_center() - .h(px(24.)) - .px(px(8.)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) .flex() .items_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.muted) .child("↑") } @@ -2844,11 +2825,10 @@ fn render_call( .id(format!("message_row_{}", message.id)) .flex() .items_center() - .gap(px(6.)) - .pl(px(28.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(Icon::new(icon).w(px(14.)).h(px(14.)).text_color(color)) + .child(Icon::new(icon).size(px(size::ICON_SM)).text_color(color)) .child(label) .into_any_element() } @@ -2870,22 +2850,19 @@ fn render_message( let name = div() .flex() .items_center() - .gap(px(8.)) - .child(match author { - Some(user) => avatar(palette, user, px(20.), text(10.), &chat.avatars), - None => badge(palette, message.user_id, username, px(20.), text(10.)).rounded_full(), - }) + .gap(px(space::SM)) .child( div() .id(format!("author_name_{}", message.id)) .font_weight(FontWeight::SEMIBOLD) - .text_color(palette.tinted(message.user_id)) + .text_color(palette.text) .when(author.is_some(), |this| { this.hover(|style| style.underline()) }) .child(username.to_string()), ); let mentioned = me.is_some_and(|me| mentions(&message.body, &me.username)); + let mine = me.is_some_and(|me| me.id == message.user_id); let group = format!("message_{}", message.id); let selecting = matches!(chat.composer, Composer::Select { .. }); let selected = matches!(&chat.composer, Composer::Select { ids } if ids.contains(&message.id)); @@ -2897,14 +2874,15 @@ fn render_message( let row = div() .id(format!("message_row_{}", message.id)) .group(group.clone()) + .relative() .flex() .flex_col() .min_w_0() - .when(first && spaced && !selecting, |this| this.mt(px(14.))) - .when(highlighted, |this| this.bg(palette.accent.opacity(0.2))) + .hover(|style| style.bg(palette.hover)) + .when(first && spaced && !selecting, |this| this.mt(px(space::LG))) + .when(highlighted, |this| this.bg(palette.tokens.press())) .when(mentioned, |this| { - this.bg(palette.accent.opacity(0.08)) - .border_l_2() + this.border_l_2() .border_color(palette.accent) }) .when(first, |this| { @@ -2922,14 +2900,16 @@ fn render_message( this.child( div() + .relative() .flex() .items_center() - .gap(px(8.)) - .mb(px(2.)) + .gap(px(space::SM)) + .mb(px(space::XXS)) + .child(thread_dot(mine, palette)) .child(author) .child( div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(millis_time(message.created_at, CLOCK)), ), @@ -2938,19 +2918,18 @@ fn render_message( .child( div() .relative() - .pl(px(28.)) .min_w_0() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() .min_w_0() - .max_w(px(720.)) + .max_w(px(size::PAGE)) .when(message.body.contains("```"), |this| this.w_full()) .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::SM)) .children(message_actions::quote_line(message, chat, palette)) .when(!message.body.is_empty(), |this| { this.child( @@ -2960,7 +2939,8 @@ fn render_message( .flex() .flex_wrap() .items_baseline() - .gap(px(4.)) + .gap(px(space::XS)) + .text_size(text(text::BODY)) .line_height(relative(1.55)) .text_color(palette.body) .child( @@ -2980,7 +2960,7 @@ fn render_message( .when(message.edited, |this| { this.child( div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child("(edited)"), ) @@ -3015,7 +2995,7 @@ fn render_message( div() .absolute() .right_0() - .top(px(-18.)) + .top(px(-space::LG)) .child(message_actions::actions( message, chat, me, entity, palette, group, )) @@ -3033,22 +3013,22 @@ fn render_message( let message_id = message.id; let select_entity = entity.clone(); let mark_line = if first { - div().h(px(20.)) + div().h(px(size::CHIP)) } else { div().line_height(relative(1.55)).child("\u{200b}") }; div() .id(format!("select_row_{}", message.id)) - .when(first && spaced, |this| this.mt(px(14.))) + .when(first && spaced, |this| this.mt(px(space::LG))) .flex() .items_start() - .gap(px(8.)) - .px(px(6.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .px(px(space::SM)) + .rounded(px(radius::MD)) .cursor_pointer() - .hover(|style| style.bg(palette.hover.opacity(0.5))) - .when(selected, |this| this.bg(palette.hover)) + .hover(|style| style.bg(palette.hover)) + .when(selected, |this| this.bg(palette.tokens.press())) .on_click(move |_, _, cx| { select_entity.update(cx, |yumush, cx| yumush.toggle_select(message_id, cx)); }) @@ -3116,14 +3096,14 @@ fn stats_button(entity: &Entity, palette: Palette, open: bool) -> impl I } else { "Connection stats" }) - .size(px(26.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) - .when(open, |this| this.bg(palette.ok.opacity(0.13))) + .rounded(px(radius::MD)) + .when(open, |this| this.bg(palette.tokens.press())) .text_color(if open { palette.ok } else { palette.muted }) - .child(Icon::new(IconName::Activity).w(px(14.)).h(px(14.))) + .child(Icon::new(IconName::Activity).size(px(size::ICON_SM))) } fn stage_button( @@ -3143,16 +3123,16 @@ fn stage_button( }), ) .tip(if active { "Hide" } else { name }) - .size(px(26.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) - .when(active, |this| this.bg(palette.accent.opacity(0.13))) + .rounded(px(radius::MD)) + .when(active, |this| this.bg(palette.tokens.press())) .text_color(if active { palette.accent } else { palette.muted }) - .child(Icon::new(icon).w(px(14.)).h(px(14.))) + .child(Icon::new(icon).size(px(size::ICON_SM))) } diff --git a/crates/client/src/gui/community_settings.rs b/crates/client/src/gui/community_settings.rs index 5c5b38d..f03ff23 100644 --- a/crates/client/src/gui/community_settings.rs +++ b/crates/client/src/gui/community_settings.rs @@ -32,6 +32,7 @@ use super::{ Editable, Picture, danger_section, delete_control, page, picked_avatar, picture_card, row, section, small_button, text_row, }, + style::{radius, size, space, text as text_token}, text, widget::search_text, }; @@ -97,8 +98,8 @@ impl Yumush { image: community_icon( palette, community, - px(64.), - text(24.), + px(size::AVATAR_LG), + text(text_token::TITLE), &self.chat.avatars, ), title: community.name.clone(), @@ -154,10 +155,10 @@ impl Yumush { div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() - .text_size(text(12.)) + .text_size(text(text_token::CAPTION)) .text_color(palette.muted) .child(bans_count.to_string()), ) @@ -500,11 +501,11 @@ fn sort_control( select: fn(&mut Yumush, T, &mut Window, &mut Context), ) -> impl IntoElement { div() - .h(px(24.)) - .p(px(2.)) + .h(px(size::CONTROL_SM)) + .p(px(space::XXS)) .flex() - .gap(px(2.)) - .rounded(px(6.)) + .gap(px(space::XXS)) + .rounded(px(radius::MD)) .border_1() .border_color(palette.border) .bg(palette.field) @@ -518,11 +519,11 @@ fn sort_control( select(yumush, choice, window, cx) }), ) - .px(px(8.)) + .px(px(space::SM)) .flex() .items_center() - .rounded(px(4.)) - .text_size(text(12.)) + .rounded(px(radius::SM)) + .text_size(text(text_token::CAPTION)) .text_color(if active { palette.text } else { palette.muted }) .when(active, |this| this.bg(palette.hover)) .child(label) @@ -539,7 +540,7 @@ fn moderation_body( ) -> impl IntoElement { let list = if rows.is_empty() { div() - .text_size(text(13.)) + .text_size(text(text_token::LABEL)) .text_color(palette.muted) .child(empty) .into_any_element() @@ -550,10 +551,10 @@ fn moderation_body( div() .flex() .flex_col() - .gap(px(12.)) + .gap(px(space::MD)) .child(Input::new(search)) .child(sort) - .child(div().id(id).max_h(px(360.)).overflow_y_scroll().child(list)) + .child(div().id(id).max_h(px(size::SHEET)).overflow_y_scroll().child(list)) } fn ban_list<'a>(bans: &'a [Ban], query: &str, sort: BanSort) -> Vec<&'a Ban> { @@ -617,22 +618,22 @@ fn log_text(entry: &LogEntry) -> String { fn log_row(entry: &LogEntry, palette: Palette, avatars: &HashMap>) -> Div { div() - .min_h(px(40.)) - .px(px(12.)) + .min_h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .children( entry .actor .as_ref() - .map(|actor| avatar(palette, actor, px(20.), text(10.), avatars)), + .map(|actor| avatar(palette, actor, px(size::AVATAR), text(text_token::CAPTION), avatars)), ) .child(div().flex_1().min_w_0().truncate().child(log_text(entry))) .child( div() .flex_shrink_0() - .text_size(text(11.)) + .text_size(text(text_token::CAPTION)) .text_color(palette.muted) .child(millis_time(entry.created_at, STAMP)), ) @@ -652,7 +653,7 @@ fn leave_control(entity: &Entity, community_id: Id, palette: Palette) -> }, ) .border_1() - .border_color(palette.danger.opacity(0.5)) + .border_color(palette.border) .child("Leave") } @@ -667,16 +668,16 @@ fn ban_row( let user_id = user.id; div() - .h(px(48.)) - .px(px(12.)) + .h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child(user_link( format!("ban_avatar_{user_id}"), Some(user), &entity, - avatar(palette, user, px(20.), text(10.), avatars), + avatar(palette, user, px(size::AVATAR), text(text_token::CAPTION), avatars), )) .child( div() @@ -692,7 +693,7 @@ fn ban_row( )) .children(ban.reason.clone().map(|reason| { div() - .text_size(text(11.)) + .text_size(text(text_token::CAPTION)) .text_color(palette.muted) .truncate() .child(reason) @@ -702,11 +703,11 @@ fn ban_row( clickable(format!("unban_{}", user.id), palette, move |window, cx| { entity.update(cx, |yumush, cx| yumush.unban(user_id, window, cx)); }) - .h(px(28.)) - .px(px(8.)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) .flex() .items_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.danger) .child("Unban"), ) diff --git a/crates/client/src/gui/composer.rs b/crates/client/src/gui/composer.rs index 4e59e3e..06ae1fb 100644 --- a/crates/client/src/gui/composer.rs +++ b/crates/client/src/gui/composer.rs @@ -1,3 +1,4 @@ +use super::style::{radius, size, space, stroke, text}; use super::text; use super::widget::{compact_field, icon_button, panel, spawn_done}; use common::model::Id; @@ -24,7 +25,9 @@ use gpui_kit::{ popover::Popover, text::TextView, }, - div, px, + div, + prelude::FluentBuilder as _, + px, }; use super::{ @@ -89,13 +92,13 @@ pub fn selection_bar(ids: &[Id], entity: &Entity, palette: Palette) -> i let forward_entity = entity.clone(); div() - .h(px(40.)) - .pl(px(14.)) - .pr(px(6.)) + .h(px(size::ROW)) + .pl(px(space::LG)) + .pr(px(space::XS)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(8.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .border_1() .border_color(palette.border) .bg(palette.field) @@ -105,12 +108,12 @@ pub fn selection_bar(ids: &[Id], entity: &Entity, palette: Palette) -> i let selected = selected.clone(); forward_entity.update(cx, |yumush, cx| yumush.open_forward(selected, window, cx)); }) - .h(px(28.)) - .px(px(10.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .rounded(px(6.)) - .text_size(text(12.)) + .rounded(px(radius::MD)) + .text_size(text(text::CAPTION)) .child("Forward"), ) .child(cancel_button(entity, palette)) @@ -118,15 +121,15 @@ pub fn selection_bar(ids: &[Id], entity: &Entity, palette: Palette) -> i fn bar(palette: Palette) -> Div { div() - .h(px(28.)) - .mb(px(8.)) - .px(px(8.)) + .h(px(size::CONTROL_SM)) + .mb(px(space::SM)) + .pl(px(space::SM)) .flex() .items_center() - .gap(px(6.)) - .rounded(px(6.)) - .bg(palette.hover) - .text_size(text(12.)) + .gap(px(space::SM)) + .border_l(px(stroke::LINE)) + .border_color(palette.border) + .text_size(text(text::CAPTION)) .text_color(palette.muted) } @@ -163,13 +166,13 @@ fn reply_bar( fn slow_bar(seconds: u64, palette: Palette) -> impl IntoElement { bar(palette) .text_color(palette.danger) - .child(Icon::new(IconName::Hourglass).w(px(12.)).h(px(12.))) + .child(Icon::new(IconName::Hourglass).size(px(size::ICON_SM))) .child(format!("Slow down, you can send again in {seconds}s")) } fn edit_bar(entity: &Entity, palette: Palette) -> impl IntoElement { bar(palette) - .child(Icon::new(IconName::Pencil).w(px(12.)).h(px(12.))) + .child(Icon::new(IconName::Pencil).size(px(size::ICON_SM))) .child("Editing") .child(div().flex_1()) .child(cancel_button(entity, palette)) @@ -529,9 +532,9 @@ pub(super) fn trigger_icon( .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.muted) - .child(Icon::new(icon).w(px(14.)).h(px(14.))), + .child(Icon::new(icon).size(px(size::ICON_SM))), palette, )) } @@ -540,23 +543,28 @@ pub fn format_popover(palette: Palette) -> impl IntoElement { Popover::new("format_popover") .anchor(Anchor::BottomLeft) .appearance(false) - .trigger(trigger_icon("format_trigger", IconName::Type, 28., palette)) + .trigger(trigger_icon( + "format_trigger", + IconName::Type, + size::CONTROL_SM, + palette, + )) .content(move |_, _, _| { pop_in( "format_list", panel(palette) - .w(px(340.)) - .p(px(8.)) + .w(px(size::SHEET)) + .p(px(space::SM)) .flex() .flex_col() - .gap(px(6.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .children(FORMAT_ROWS.map(|(syntax, shortcut)| { div() .flex() .items_center() - .gap(px(12.)) - .child(div().w(px(100.)).text_color(palette.muted).child(syntax)) + .gap(px(space::MD)) + .child(div().w(px(size::THUMB)).text_color(palette.muted).child(syntax)) .child(div().flex_1().child(TextView::markdown(syntax, syntax))) .child( div() @@ -584,16 +592,16 @@ fn plus_row( on_click: impl Fn(&mut Window, &mut App) + 'static, ) -> impl IntoElement { clickable(id, palette, on_click) - .h(px(32.)) - .px(px(8.)) - .gap(px(8.)) - .rounded(px(6.)) + .h(px(size::CONTROL)) + .px(px(space::SM)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .flex() .items_center() .child( div() .text_color(palette.muted) - .child(Icon::new(icon).w(px(14.)).h(px(14.))), + .child(Icon::new(icon).size(px(size::ICON_SM))), ) .child(label) } @@ -614,13 +622,13 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i hoverable( "plus_trigger", div() - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.muted) - .child(Icon::new(IconName::Plus).w(px(16.)).h(px(16.))), + .child(Icon::new(IconName::Plus).size(px(size::ICON_SM))), palette, ) .on_mouse_down(MouseButton::Left, move |_, _, cx| { @@ -635,11 +643,11 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i return pop_in( "plus_menu", panel(palette) - .w(px(180.)) - .p(px(4.)) + .w(px(size::SIDEBAR)) + .p(px(space::XS)) .flex() .flex_col() - .gap(px(4.)) + .gap(px(space::XS)) .child(plus_row( "plus_file", IconName::File, @@ -673,12 +681,12 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i pop_in( "poll_form", panel(palette) - .w(px(300.)) - .p(px(8.)) + .w(px(size::POPOVER)) + .p(px(space::SM)) .flex() .flex_col() - .gap(px(6.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .child(compact_field(palette, &question)) .children(options.iter().enumerate().map(|(index, option)| { let remove = entity.clone(); @@ -687,7 +695,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child( div() .flex_1() @@ -716,9 +724,9 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i div() .flex() .items_center() - .gap(px(4.)) + .gap(px(space::XS)) .text_color(palette.muted) - .child(Icon::new(IconName::Timer).w(px(14.)).h(px(14.))) + .child(Icon::new(IconName::Timer).size(px(size::ICON_SM))) .children(POLL_DURATIONS.map(|(label, seconds)| { let set = duration_entity.clone(); let active = duration == seconds; @@ -728,15 +736,15 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i cx.notify(); }) }) - .px(px(6.)) - .py(px(2.)) - .rounded(px(4.)) + .px(px(space::SM)) + .py(px(space::XXS)) + .rounded(px(radius::SM)) .text_color(if active { palette.accent } else { palette.muted }) - .bg(palette.accent.opacity(if active { 0.15 } else { 0. })) + .when(active, |this| this.bg(palette.tokens.press())) .child(label) })), ) @@ -745,7 +753,7 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i div() .flex() .items_center() - .gap(px(12.)) + .gap(px(space::MD)) .child( Checkbox::new("poll_multiple") .label("Multiple answers") @@ -776,11 +784,11 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i popover.update(cx, |state, cx| state.dismiss(window, cx)); } }) - .h(px(28.)) + .h(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .child("Create"), ), Anchor::BottomLeft, diff --git a/crates/client/src/gui/forward.rs b/crates/client/src/gui/forward.rs index 6c6a273..1b07315 100644 --- a/crates/client/src/gui/forward.rs +++ b/crates/client/src/gui/forward.rs @@ -1,4 +1,4 @@ -use super::text; +use super::style::{radius, size, space, text}; use common::call::ForwardMessages; use common::model::Id; use gpui_kit::{ @@ -80,13 +80,13 @@ impl Render for Forward { yumush.forward_to(selected, community_id, keep_authors, window, cx) }); }) - .h(px(28.)) - .px(px(8.)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(6.)) - .child(yumush.community_badge(community, px(16.), text(9.), palette)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) + .child(yumush.community_badge(community, px(size::ICON), super::text(text::CAPTION), palette)) .child( div() .flex_1() @@ -101,7 +101,7 @@ impl Render for Forward { div() .flex() .flex_col() - .gap(px(10.)) + .gap(px(space::MD)) .child(compact_field(palette, &self.filter)) .child( Checkbox::new("keep_authors") @@ -117,10 +117,10 @@ impl Render for Forward { .child( div() .id("forward_list") - .max_h(px(320.)) + .max_h(px(size::POPOVER)) .flex() .flex_col() - .gap(px(1.)) + .gap(px(space::XXS)) .overflow_y_scroll() .children(rows), ) @@ -141,7 +141,7 @@ impl Yumush { let forward = cx.new(|cx| Forward::new(yumush, selected, window, cx)); window.open_dialog(cx, move |dialog, _, _| { - dialog.title("Forward").w(px(360.)).child(forward.clone()) + dialog.title("Forward").w(px(size::SHEET)).child(forward.clone()) }); } diff --git a/crates/client/src/gui/media_view.rs b/crates/client/src/gui/media_view.rs index 7fd779e..958f000 100644 --- a/crates/client/src/gui/media_view.rs +++ b/crates/client/src/gui/media_view.rs @@ -1,3 +1,4 @@ +use super::style::{radius, size, space, text}; use super::text; use common::model::Id; use std::{ @@ -33,9 +34,9 @@ use crate::{ net::{Fail, NetworkHandle}, }; -const IMAGE_BOX: (f32, f32) = (400., 300.); -const VIDEO_BOX: (f32, f32) = (480., 270.); -const EMBED_IMAGE_BOX: (f32, f32) = (400., 225.); +const IMAGE_BOX: (f32, f32) = (size::MEDIA, 300.); +const VIDEO_BOX: (f32, f32) = (size::WIDE, 270.); +const EMBED_IMAGE_BOX: (f32, f32) = (size::MEDIA, 225.); pub struct LoadedEmbed { embed: Embed, @@ -536,7 +537,7 @@ pub fn attachments( return None; } Some( - div().flex().flex_col().gap(px(6.)).children( + div().flex().flex_col().gap(px(space::SM)).children( attachments .iter() .map(|attachment| attachment_view(attachment, media, entity, palette)), @@ -585,7 +586,7 @@ fn image_view( .id(format!("attachment_{}", attachment.id)) .w(px(width)) .h(px(height)) - .rounded(px(8.)) + .rounded(px(radius::MD)) .overflow_hidden() .bg(palette.field) .cursor_pointer() @@ -603,12 +604,10 @@ fn card(palette: Palette) -> gpui_kit::Div { .max_w(px(VIDEO_BOX.0)) .flex() .items_center() - .gap(px(10.)) - .px(px(12.)) - .py(px(10.)) - .rounded(px(8.)) - .border_1() - .border_color(palette.border) + .gap(px(space::MD)) + .px(px(space::MD)) + .py(px(space::MD)) + .rounded(px(radius::MD)) .bg(palette.panel) } @@ -626,7 +625,7 @@ fn name_block(attachment: &Attachment, detail: String, palette: Palette) -> impl ) .child( div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(detail), ) @@ -641,14 +640,14 @@ fn icon_button( ) -> impl IntoElement { clickable(id, palette, on_click) .tip(tip) - .size(px(32.)) + .size(px(size::CONTROL)) .flex_shrink_0() .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.text) - .child(Icon::new(icon).w(px(16.)).h(px(16.))) + .child(Icon::new(icon).size(px(size::ICON))) } fn file_view( @@ -659,8 +658,7 @@ fn file_view( card(palette) .child( Icon::new(IconName::File) - .w(px(20.)) - .h(px(20.)) + .size(px(size::ICON)) .text_color(palette.muted), ) .child(name_block(attachment, storage(attachment.size), palette)) @@ -720,7 +718,7 @@ fn player_view( this.child(waveform_view(attachment, media, entity, state, palette)) .child( div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(detail.clone()), ) @@ -733,7 +731,7 @@ fn player_view( Some(PlayState::Ready { seek, .. }) if !voice => Some(seek), _ => None, }, - |this, seek| this.child(div().w(px(140.)).child(Slider::new(seek))), + |this, seek| this.child(div().w(px(size::THUMB)).child(Slider::new(seek))), ); let video = match state { @@ -747,16 +745,16 @@ fn player_view( div() .flex() .flex_col() - .gap(px(4.)) + .gap(px(space::XS)) .when_some(video, |this, (frame, width, height)| { let (width, height) = fit(Some(width), Some(height), VIDEO_BOX); this.child( div() .w(px(width)) .h(px(height)) - .rounded(px(8.)) + .rounded(px(radius::MD)) .overflow_hidden() - .bg(gpui_kit::black()) + .bg(palette.tokens.ground()) .children(frame.clone().map(|frame| img(frame).size_full())), ) }) @@ -809,7 +807,7 @@ fn embed_view(loaded: &LoadedEmbed, palette: Palette) -> impl IntoElement { div() .max_w(px(EMBED_IMAGE_BOX.0)) .max_h(px(EMBED_IMAGE_BOX.1)) - .rounded(px(6.)) + .rounded(px(radius::MD)) .overflow_hidden() .child( img(image) @@ -826,17 +824,17 @@ fn embed_view(loaded: &LoadedEmbed, palette: Palette) -> impl IntoElement { .max_w(px(VIDEO_BOX.0)) .flex() .flex_col() - .gap(px(4.)) - .pl(px(12.)) - .pr(px(12.)) - .py(px(10.)) - .rounded(px(6.)) + .gap(px(space::XS)) + .pl(px(space::MD)) + .pr(px(space::MD)) + .py(px(space::MD)) + .rounded(px(radius::MD)) .border_l_2() .border_color(palette.border) .bg(palette.panel) .children(embed.site.clone().map(|site| { div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(site) })) @@ -852,7 +850,7 @@ fn embed_view(loaded: &LoadedEmbed, palette: Palette) -> impl IntoElement { })) .children(embed.description.clone().map(|description| { div() - .text_size(text(13.)) + .text_size(text(text::LABEL)) .text_color(palette.body) .line_clamp(3) .child(description) @@ -872,24 +870,24 @@ pub fn pending_row( div() .flex() .flex_wrap() - .gap(px(6.)) - .pb(px(8.)) + .gap(px(space::SM)) + .pb(px(space::SM)) .children(media.pending.iter().map(|attachment| { let entity = entity.clone(); let attachment_id = attachment.id; div() .flex() .items_center() - .gap(px(6.)) - .pl(px(10.)) - .pr(px(4.)) - .py(px(4.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .pl(px(space::MD)) + .pr(px(space::XS)) + .py(px(space::XS)) + .rounded(px(radius::MD)) .bg(palette.hover) - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .child( div() - .max_w(px(180.)) + .max_w(px(size::SIDEBAR)) .truncate() .child(attachment.name.clone()), ) @@ -904,20 +902,20 @@ pub fn pending_row( }, ) .tip("Remove") - .size(px(18.)) + .size(px(size::CHIP)) .flex() .items_center() .justify_center() - .rounded(px(4.)) - .child(Icon::new(IconName::Close).w(px(12.)).h(px(12.))), + .rounded(px(radius::SM)) + .child(Icon::new(IconName::Close).size(px(size::ICON_SM))), ) })) .when(media.uploading(), |this| { this.child( div() - .px(px(10.)) - .py(px(4.)) - .text_size(text(12.)) + .px(px(space::MD)) + .py(px(space::XS)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child("…"), ) diff --git a/crates/client/src/gui/message_actions.rs b/crates/client/src/gui/message_actions.rs index df80b21..d4372e7 100644 --- a/crates/client/src/gui/message_actions.rs +++ b/crates/client/src/gui/message_actions.rs @@ -25,6 +25,7 @@ use super::{ clickable, composer::trigger_icon, entity_action, millis_time, notify_error, pop_in, primary_button, sidebar, + style::{radius, size, space, text}, widget::{field, icon_button, panel, spawn_done}, }; @@ -39,7 +40,7 @@ pub fn reactions( div() .flex() .flex_wrap() - .gap(px(4.)) + .gap(px(space::XS)) .children(message.reactions.iter().map(|reaction| { let mine = me_id .as_ref() @@ -62,18 +63,18 @@ pub fn reactions( ) .flex() .items_center() - .gap(px(4.)) - .h(px(22.)) - .px(px(6.)) + .gap(px(space::XS)) + .h(px(size::CHIP)) + .px(px(space::SM)) .rounded_full() .border_1() .border_color(if mine { palette.accent } else { palette.border }) .bg(if mine { - palette.accent.opacity(0.15) + palette.tokens.press() } else { palette.panel }) - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .child(chip_emoji) .child(div().text_color(palette.muted).child(count.to_string())) })) @@ -102,8 +103,8 @@ pub fn react_popover( "react_list", panel(palette) .flex() - .gap(px(2.)) - .p(px(4.)) + .gap(px(space::XXS)) + .p(px(space::XS)) .children(REACTIONS.map(|emoji| { let entity = entity.clone(); let popover = popover.clone(); @@ -122,12 +123,12 @@ pub fn react_popover( }); }, ) - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) - .text_size(text(16.)) + .rounded(px(radius::MD)) + .text_size(text(text::BODY)) .child(emoji) })), Anchor::TopRight, @@ -158,13 +159,13 @@ pub fn quote_line(message: &Message, chat: &Chat, palette: Palette) -> Option Option impl IntoElement { div() - .size(px(16.)) + .size(px(size::ICON)) .flex_shrink_0() .flex() .items_center() @@ -203,8 +204,7 @@ pub fn selection_mark(selected: bool, palette: Palette) -> impl IntoElement { }) .children(selected.then(|| { Icon::new(IconName::Check) - .w(px(10.)) - .h(px(10.)) + .size(px(size::ICON_SM)) .text_color(palette.on_accent) })) } @@ -213,7 +213,7 @@ pub fn pin_mark(palette: Palette) -> impl IntoElement { div() .flex_shrink_0() .text_color(palette.muted) - .child(Icon::new(IconName::Pin).w(px(12.)).h(px(12.))) + .child(Icon::new(IconName::Pin).size(px(size::ICON_SM))) } struct Hit { @@ -245,11 +245,11 @@ fn jump_row( }, ) .flex() - .gap(px(6.)) - .px(px(8.)) - .py(px(4.)) - .rounded(px(6.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .px(px(space::SM)) + .py(px(space::XS)) + .rounded(px(radius::MD)) + .text_size(text(text::CAPTION)) .child( div() .flex_shrink_0() @@ -290,11 +290,11 @@ pub fn search_popover(chat: &Chat, entity: &Entity, palette: Palette) -> pop_in( "search_list", panel(palette) - .w(px(320.)) - .p(px(4.)) + .w(px(size::POPOVER)) + .p(px(space::XS)) .flex() .flex_col() - .gap(px(4.)) + .gap(px(space::XS)) .child(sidebar::input_box(&input, palette)) .children(hits.iter().map(|hit| { jump_row("search_hit", hit, &entity, &popover, palette) @@ -336,11 +336,11 @@ pub fn pins_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i pop_in( "pins_list", panel(palette) - .w(px(260.)) - .p(px(4.)) + .w(px(size::POPOVER)) + .p(px(space::XS)) .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .children(pins.iter().map(|hit| { jump_row("pin_hit", hit, &entity, &popover, palette).child( div() @@ -375,8 +375,8 @@ pub fn actions( panel(palette) .flex() .items_center() - .gap(px(2.)) - .p(px(2.)) + .gap(px(space::XXS)) + .p(px(space::XXS)) .when(!armed, |this| this.invisible()) .group_hover(group, |style| style.visible()) .child(action( @@ -449,7 +449,7 @@ pub fn actions( ) .when(armed, |this| { this.text_color(palette.danger) - .bg(palette.danger.opacity(0.15)) + .bg(palette.tokens.press()) }) })) } @@ -462,7 +462,7 @@ pub fn report_bar( div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child(div().flex_1().min_w_0().child(field(palette, reason))) .child( primary_button( @@ -470,11 +470,11 @@ pub fn report_bar( palette, entity_action(entity, |yumush, window, cx| yumush.send_report(window, cx)), ) - .h(px(28.)) - .px(px(10.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .child("Send"), ) } @@ -586,5 +586,5 @@ fn action( entity.update(cx, |yumush, cx| run(yumush, message_id, window, cx)); }, ) - .size(px(24.)) + .size(px(size::CONTROL_SM)) } diff --git a/crates/client/src/gui/parts.rs b/crates/client/src/gui/parts.rs index 9c201c2..ed9aa64 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -19,7 +19,6 @@ pub enum Text { Ui, Body, Title, - Display, } impl Text { @@ -30,7 +29,6 @@ impl Text { Text::Ui => text::UI, Text::Body => text::BODY, Text::Title => text::TITLE, - Text::Display => text::DISPLAY, } } } @@ -56,7 +54,7 @@ impl Ink { pub fn words(content: impl Into, style: Text, ink: Ink, t: Tokens) -> Div { let weight = match style { - Text::Title | Text::Display => FontWeight::SEMIBOLD, + Text::Title => FontWeight::SEMIBOLD, _ => FontWeight::NORMAL, }; div() diff --git a/crates/client/src/gui/poll.rs b/crates/client/src/gui/poll.rs index 2245b21..9e6fed3 100644 --- a/crates/client/src/gui/poll.rs +++ b/crates/client/src/gui/poll.rs @@ -12,6 +12,7 @@ use super::{ Palette, Tooltip as _, Trigger, Yumush, avatar, chat::Chat, clickable, hoverable, pop_in, text, + style::{radius, size, space, text}, widget::{icon_button, panel, spawn_done}, }; @@ -61,15 +62,15 @@ fn status_icon( .tip(tip) .flex_shrink_0() .text_color(palette.muted) - .child(Icon::new(icon).w(px(12.)).h(px(12.))) + .child(Icon::new(icon).size(px(size::ICON_SM))) } fn voters_label(voters: usize) -> Div { div() .flex() .items_center() - .gap(px(4.)) - .child(Icon::new(IconName::Users).w(px(12.)).h(px(12.))) + .gap(px(space::XS)) + .child(Icon::new(IconName::Users).size(px(size::ICON_SM))) .child(format!("{voters}")) } @@ -97,11 +98,11 @@ fn voters_popover(key: &str, poll: &Poll, entity: &Entity, palette: Pale .flex_col() .child( div() - .h(px(26.)) + .h(px(size::CONTROL_SM)) .flex() .items_center() - .gap(px(8.)) - .text_size(text(11.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child( div() @@ -119,12 +120,12 @@ fn voters_popover(key: &str, poll: &Poll, entity: &Entity, palette: Pale .children(option.voter_ids.iter().filter_map(|id| { chat.author(*id).map(|user| { div() - .h(px(26.)) + .h(px(size::CONTROL_SM)) .flex() .items_center() - .gap(px(8.)) - .text_size(text(12.)) - .child(avatar(palette, user, px(18.), text(8.), &chat.avatars)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) + .child(avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &chat.avatars)) .child( div() .flex_1() @@ -138,11 +139,11 @@ fn voters_popover(key: &str, poll: &Poll, entity: &Entity, palette: Pale pop_in( list.clone(), panel(palette) - .w(px(260.)) + .w(px(size::SIDEBAR)) .id(list.clone()) - .max_h(px(320.)) + .max_h(px(size::POPOVER)) .overflow_y_scroll() - .p(px(6.)) + .p(px(space::SM)) .flex() .flex_col() .children(rows), @@ -218,17 +219,17 @@ pub fn poll_card( None => div().id(id), } .relative() - .h(px(36.)) - .px(px(10.)) + .h(px(size::CONTROL)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(8.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .border_1() .border_color(if picked { palette.accent } else { - palette.accent.opacity(0.) + palette.field }) .overflow_hidden() .bg(palette.field) @@ -239,12 +240,16 @@ pub fn poll_card( .top_0() .h_full() .w(relative(share as f32 / 100.)) - .bg(palette.accent.opacity(if picked { 0.35 } else { 0.15 })), + .bg(if picked { + palette.tokens.press() + } else { + palette.hover + }), ) .child( div() .flex_shrink_0() - .size(px(14.)) + .size(px(size::ICON_SM)) .flex() .items_center() .justify_center() @@ -259,7 +264,7 @@ pub fn poll_card( marker .bg(palette.accent) .text_color(palette.on_accent) - .child(Icon::new(IconName::Check).w(px(10.)).h(px(10.))) + .child(Icon::new(IconName::Check).size(px(size::ICON_SM))) }), ) .child( @@ -280,17 +285,17 @@ pub fn poll_card( .enumerate() .filter_map(|(index, id)| { chat.author(*id).map(|user| { - avatar(palette, user, px(18.), text(8.), &chat.avatars) + avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &chat.avatars) .border_2() .border_color(palette.panel) - .when(index > 0, |el| el.ml(px(-6.))) + .when(index > 0, |el| el.ml(px(-space::SM))) }) }), ) .children((voters_here.len() > 3).then(|| { div() - .ml(px(4.)) - .text_size(text(11.)) + .ml(px(space::XS)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(format!("+{}", voters_here.len() - 3)) })) @@ -298,7 +303,7 @@ pub fn poll_card( .child( div() .flex_shrink_0() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .font_weight(FontWeight::SEMIBOLD) .text_color(if picked { palette.text } else { palette.muted }) .child(format!("{share}%")), @@ -315,8 +320,8 @@ pub fn poll_card( div() .flex() .items_center() - .gap(px(4.)) - .child(Icon::new(IconName::Timer).w(px(12.)).h(px(12.))) + .gap(px(space::XS)) + .child(Icon::new(IconName::Timer).size(px(size::ICON_SM))) .child(remaining(end)) }); @@ -324,14 +329,14 @@ pub fn poll_card( .flex() .items_center() .justify_between() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(voters_view) .child( div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .children(timer) .children(close_id.map(|close_id| { let close_entity = entity.clone(); @@ -357,25 +362,23 @@ pub fn poll_card( div() .flex() .flex_col() - .gap(px(8.)) - .p(px(14.)) - .w(px(360.)) + .gap(px(space::SM)) + .p(px(space::LG)) + .w(px(size::SHEET)) .max_w_full() - .rounded(px(12.)) - .border_1() - .border_color(palette.border) + .rounded(px(radius::LG)) .bg(palette.panel) .child( div() .flex() .items_start() .justify_between() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() .min_w_0() .font_weight(FontWeight::SEMIBOLD) - .text_size(text(15.)) + .text_size(text(text::UI)) .child(poll.question.clone()), ) .child( @@ -383,7 +386,7 @@ pub fn poll_card( .flex_shrink_0() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child(status_icon( format!("poll_public_{key}_{}", poll.public), visibility, @@ -438,9 +441,9 @@ impl Yumush { div() .flex() .flex_col() - .gap(px(6.)) - .px(px(16.)) - .py(px(8.)) + .gap(px(space::SM)) + .px(px(space::LG)) + .py(px(space::SM)) .border_b_1() .border_color(palette.border) .bg(palette.panel) @@ -448,7 +451,7 @@ impl Yumush { div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child( clickable("poll_banner_toggle", palette, move |_, cx| { toggle.update(cx, |yumush, cx| { @@ -460,13 +463,13 @@ impl Yumush { .flex_1() .min_w_0() .items_center() - .gap(px(8.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .child( div() .flex_shrink_0() .text_color(palette.muted) - .child(Icon::new(IconName::ChartBar).w(px(14.)).h(px(14.))), + .child(Icon::new(IconName::ChartBar).size(px(size::ICON_SM))), ) .child( div() @@ -488,8 +491,7 @@ impl Yumush { } else { IconName::ChevronDown }) - .w(px(14.)) - .h(px(14.)), + .size(px(size::ICON_SM)), ), ), ) @@ -497,8 +499,8 @@ impl Yumush { div() .flex() .items_center() - .gap(px(2.)) - .text_size(text(11.)) + .gap(px(space::XXS)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(page_button( "poll_page_back", diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index d5c247a..f926f35 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -28,6 +28,9 @@ use super::{ DAY_YEAR, Palette, Trigger, Yumush, avatar, clickable, entity_action, input_dialog, millis_time, notify_error, palette, pop_in, presence_color, rank_tag, swap_in, text, }; +use super::style::{radius, size, space, stroke, text}; + +const ACCOUNTS_MAX_H: f32 = 180.; #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum Removal { @@ -220,23 +223,23 @@ impl Card { rows.extend(self.moderation_rows(entity, &popover, palette)); rows }; - let divider = (!rows.is_empty()).then(|| div().h(px(1.)).my(px(4.)).bg(palette.border)); + let divider = (!rows.is_empty()).then(|| div().h(px(stroke::LINE)).my(px(space::XS)).bg(palette.border)); panel(palette) - .w(px(260.)) - .p(px(16.)) + .w(px(size::SIDEBAR)) + .p(px(space::LG)) .flex() .flex_col() - .gap(px(10.)) - .child(avatar(palette, &self.user, px(48.), text(18.), avatars)) + .gap(px(space::MD)) + .child(avatar(palette, &self.user, px(size::AVATAR_LG), text(text::BODY), avatars)) .child( div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child( div() - .text_size(text(15.)) + .text_size(text(text::UI)) .font_weight(FontWeight::SEMIBOLD) .child(self.user.username.clone()), ) @@ -246,21 +249,21 @@ impl Card { div() .flex() .items_center() - .gap(px(6.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(presence_dot(self.presence, palette)) .child(self.presence.label()) })) .children((!self.user.status.is_empty()).then(|| { div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(self.user.status.clone()) })) .child( div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(format!( "Joined {}", @@ -271,12 +274,12 @@ impl Card { div() .flex() .items_center() - .gap(px(8.)) - .text_size(text(12.)) + .gap(px(space::SM)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(Icon::new(IconName::Volume2).w(px(14.)).h(px(14.))) + .child(Icon::new(IconName::Volume2).size(px(size::ICON_SM))) .child(Slider::new(&slider).flex_1()) - .child(div().w(px(36.)).text_right().child(format!("{volume:.0}%"))) + .child(div().w(px(size::CONTROL)).text_right().child(format!("{volume:.0}%"))) })) .children( self.reporting @@ -285,7 +288,7 @@ impl Card { .children(divider) .child(swap_in( ("profile_rows", self.card_menu as usize), - div().flex().flex_col().gap(px(10.)).children(rows), + div().flex().flex_col().gap(px(space::MD)).children(rows), self.card_menu != CardMenu::Main, )) } @@ -473,7 +476,7 @@ fn accounts_rows( .into_any_element(), div() .id("profile_accounts") - .max_h(px(180.)) + .max_h(px(ACCOUNTS_MAX_H)) .overflow_y_scroll() .flex() .flex_col() @@ -535,7 +538,7 @@ fn card_menu_action( fn presence_dot(presence: Presence, palette: Palette) -> Div { div() - .size(px(8.)) + .size(px(space::SM)) .rounded_full() .bg(presence_color(presence, palette)) } @@ -576,7 +579,7 @@ fn delete_user_action( } fn menu_icon(icon: IconName) -> Icon { - Icon::new(icon).w(px(14.)).h(px(14.)) + Icon::new(icon).size(px(size::ICON_SM)) } fn menu_row( @@ -588,12 +591,12 @@ fn menu_row( on_click: impl Fn(&mut Window, &mut App) + 'static, ) -> Stateful
{ clickable(id, palette, on_click) - .h(px(30.)) - .px(px(8.)) + .h(px(size::CONTROL)) + .px(px(space::SM)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .text_color(color) .child(leading) .child(label.into()) diff --git a/crates/client/src/gui/settings_page.rs b/crates/client/src/gui/settings_page.rs index a8debb0..a32ab2e 100644 --- a/crates/client/src/gui/settings_page.rs +++ b/crates/client/src/gui/settings_page.rs @@ -24,7 +24,7 @@ use super::{ widget::{field, icon_button}, }; use crate::{ - gui::style::Theme, + gui::style::{Theme, radius, size, space, stroke, text}, settings::{self, FontSize}, }; @@ -41,7 +41,7 @@ impl Yumush { picture_card( Picture { id: "avatar_picker", - image: avatar(palette, user, px(64.), text(24.), &self.chat.avatars), + image: avatar(palette, user, px(size::AVATAR_LG), text(text::TITLE), &self.chat.avatars), title: user.username.clone(), subtitle: user.status.clone(), removable: user.avatar_id.is_some(), @@ -307,11 +307,11 @@ pub(super) fn header( let entity = entity.clone(); div() - .h(px(44.)) - .px(px(12.)) + .h(px(size::ROW)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .border_b_1() .border_color(palette.border) .child(icon_button( @@ -350,46 +350,39 @@ pub(super) fn page( .child( div() .w_full() - .max_w(px(600.)) - .px(px(24.)) - .py(px(32.)) + .max_w(px(size::PAGE)) + .px(px(space::XL)) + .py(px(space::XXL)) .flex() .flex_col() - .gap(px(28.)) + .gap(px(space::XXL)) .children(sections), ), ) } pub(super) fn section(title: &'static str, palette: Palette, rows: Vec
) -> impl IntoElement { - card(title, palette.muted, palette.border, palette, rows) + card(title, palette.muted, palette, rows) } pub(super) fn danger_section(palette: Palette, rows: Vec
) -> impl IntoElement { - card( - "Danger zone", - palette.danger, - palette.danger.opacity(0.35), - palette, - rows, - ) + card("Danger zone", palette.danger, palette, rows) } fn card( title: &'static str, title_color: Hsla, - border: Hsla, palette: Palette, rows: Vec
, ) -> impl IntoElement { div() .flex() .flex_col() - .gap(px(8.)) + .gap(px(space::SM)) .child( div() - .px(px(2.)) - .text_size(text(12.)) + .px(px(space::XXS)) + .text_size(text(text::CAPTION)) .font_weight(FontWeight::MEDIUM) .text_color(title_color) .child(title), @@ -398,10 +391,6 @@ fn card( div() .flex() .flex_col() - .rounded(px(10.)) - .border_1() - .border_color(border) - .bg(palette.panel) .children(rows.into_iter().enumerate().map(|(index, row)| { row.when(index > 0, |row| { row.border_t_1().border_color(palette.border) @@ -429,13 +418,13 @@ pub(super) fn text_row( let save = editable.save; div() - .p(px(12.)) + .p(px(space::MD)) .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::SM)) .child( div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(editable.label), ) @@ -443,18 +432,18 @@ pub(super) fn text_row( div() .flex() .items_center() - .gap(px(8.)) + .gap(px(space::SM)) .child(field(palette, editable.input).flex_1()) .when(dirty, |this| { this.child( primary_button(editable.id, palette, move |window, cx| { entity.update(cx, |yumush, cx| save(yumush, window, cx)); }) - .h(px(32.)) - .px(px(14.)) + .h(px(size::CONTROL)) + .px(px(space::LG)) .flex() .items_center() - .rounded(px(8.)) + .rounded(px(radius::MD)) .font_weight(FontWeight::MEDIUM) .child("Save"), ) @@ -486,19 +475,14 @@ pub(super) fn picture_card(picture: Picture, entity: &Entity, palette: P let remove_entity = entity.clone(); div() - .p(px(16.)) + .p(px(space::LG)) .flex() .items_center() - .gap(px(16.)) - .rounded(px(10.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) + .gap(px(space::LG)) .child( div() .id(id) .cursor_pointer() - .hover(|style| style.opacity(0.8)) .on_click(move |_, window, cx| { picture_entity.update(cx, |yumush, cx| upload(yumush, window, cx)); }) @@ -511,10 +495,10 @@ pub(super) fn picture_card(picture: Picture, entity: &Entity, palette: P .min_w_0() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child( div() - .text_size(text(16.)) + .text_size(text(text::BODY)) .font_weight(FontWeight::SEMIBOLD) .truncate() .child(title), @@ -522,7 +506,7 @@ pub(super) fn picture_card(picture: Picture, entity: &Entity, palette: P .when(!subtitle.is_empty(), |this| { this.child( div() - .text_size(text(12.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .truncate() .child(subtitle), @@ -549,12 +533,12 @@ pub(super) fn small_button( on_click: impl Fn(&mut Window, &mut App) + 'static, ) -> Stateful
{ clickable(id, palette, on_click) - .h(px(28.)) - .px(px(10.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .rounded(px(6.)) - .text_size(text(13.)) + .rounded(px(radius::MD)) + .text_size(text(text::LABEL)) .text_color(color) } @@ -572,7 +556,7 @@ pub(super) fn delete_control( entity.update(cx, |yumush, cx| action(yumush, window, cx)); }) .border_1() - .border_color(palette.danger.opacity(0.5)) + .border_color(palette.border) .when(confirming, |this| { this.bg(palette.danger).text_color(palette.on_accent) }) @@ -581,9 +565,9 @@ pub(super) fn delete_control( pub(super) fn row(label: &'static str, control: impl IntoElement) -> Div { div() - .min_h(px(48.)) - .py(px(10.)) - .px(px(12.)) + .min_h(px(size::ROW)) + .py(px(space::MD)) + .px(px(space::MD)) .flex() .items_center() .justify_between() @@ -593,11 +577,11 @@ pub(super) fn row(label: &'static str, control: impl IntoElement) -> Div { pub(super) fn segment_track(palette: Palette) -> Div { div() - .h(px(30.)) - .p(px(3.)) + .h(px(size::CONTROL)) + .p(px(space::XXS)) .flex() - .gap(px(2.)) - .rounded(px(8.)) + .gap(px(space::XXS)) + .rounded(px(radius::MD)) .border_1() .border_color(palette.border) .bg(palette.window) @@ -613,7 +597,7 @@ pub(super) fn segment(item: E, active: bool, palette: Palette) -> E { item.flex() .items_center() .justify_center() - .rounded(px(5.)) + .rounded(px(radius::SM)) .border_1() .border_color(border) .bg(background) @@ -627,17 +611,30 @@ pub(super) fn segmented( palette: Palette, select: fn(&mut Yumush, T, &mut Context), ) -> impl IntoElement { - segment_track(palette).children(options.into_iter().map(|(choice, label)| { - let entity = entity.clone(); - - segment( - clickable(label, palette, move |_, cx| { - entity.update(cx, |yumush, cx| select(yumush, choice, cx)); - }), - choice == selected, - palette, - ) - .px(px(10.)) - .child(label) - })) + div() + .flex() + .gap(px(space::LG)) + .children(options.into_iter().map(|(choice, label)| { + let entity = entity.clone(); + let on = choice == selected; + + div() + .id(label) + .cursor_pointer() + .flex() + .flex_col() + .gap(px(space::XXS)) + .text_size(text(text::UI)) + .font_weight(FontWeight::MEDIUM) + .text_color(if on { palette.tokens.paper() } else { palette.muted }) + .on_click(move |_, _, cx| { + entity.update(cx, |yumush, cx| select(yumush, choice, cx)); + }) + .child(label) + .child(div().h(px(stroke::LINE)).bg(if on { + palette.tokens.paper() + } else { + transparent_black() + })) + })) } diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index b86ac7a..a06749c 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -7,6 +7,8 @@ use std::{ use common::share::{Codec, Fps, Kind, Mode, Quality, Resolution, clamp, options}; const FULL_VOLUME: f32 = 100.; +const VOLUME_WIDTH: f32 = 80.; +const APPS_HEIGHT: f32 = 160.; const TOP_QUALITY: Quality = Quality { resolution: Resolution::P2160, @@ -36,6 +38,7 @@ use super::{ notify_error, pop_in, settings_page::segmented, stream_stats::{stream_card, watch_stats}, + style::{radius, size, space, text}, surface::Surface, text, widget::{icon_button, spawn_warn}, @@ -576,7 +579,7 @@ impl Yumush { .min_h_0() .relative() .occlude() - .bg(gpui_kit::black()) + .bg(palette.window) .on_mouse_move({ let entity = entity.clone(); move |_, _, cx| { @@ -606,9 +609,9 @@ impl Yumush { .child( camera_view::tile_label(self, palette, (viewer.user_id, viewer.kind)) .absolute() - .left(px(10.)) - .top(px(10.)) - .when(!bar, |this| this.opacity(0.)), + .left(px(space::MD)) + .top(px(space::MD)) + .when(!bar, |this| this.invisible()), ) .children(stats.map(|_| { let entity = entity.clone(); @@ -616,21 +619,21 @@ impl Yumush { div() .occlude() .absolute() - .right(px(10.)) - .top(px(10.)) - .when(!bar && !viewer.stats, |this| this.opacity(0.)) + .right(px(space::MD)) + .top(px(space::MD)) + .when(!bar && !viewer.stats, |this| this.invisible()) .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child( div() - .h(px(22.)) - .px(px(8.)) + .h(px(size::CHIP)) + .px(px(space::SM)) .flex() .items_center() - .rounded(px(11.)) - .bg(gpui_kit::black().opacity(0.72)) - .text_size(text(11.)) + .rounded(px(radius::MD)) + .bg(palette.field) + .text_size(text(text::CAPTION)) .text_color(tone) .child(format!("{}p{}", top.resolution.height(), top.fps.value())), ) @@ -638,14 +641,14 @@ impl Yumush { div() .id("viewer_stats_button") .tip("Stream stats") - .size(px(26.)) + .size(px(size::CONTROL_SM)) .flex() .flex_shrink_0() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .cursor_pointer() - .bg(gpui_kit::black().opacity(0.72)) + .bg(palette.field) .text_color(if viewer.stats { tone } else { palette.muted }) .hover(|style| style.bg(palette.hover).text_color(palette.text)) .on_click(move |_, _, cx| { @@ -656,7 +659,7 @@ impl Yumush { cx.notify(); }) }) - .child(Icon::new(IconName::ChartBar).w(px(14.)).h(px(14.))), + .child(Icon::new(IconName::ChartBar).size(px(size::ICON_SM))), ) })) .when(viewer.stats, |this| { @@ -664,8 +667,8 @@ impl Yumush { div() .occlude() .absolute() - .right(px(10.)) - .top(px(42.)) + .right(px(space::MD)) + .top(px(space::XXL)) .child(stream_card(self, user_id, kind, palette)), ) }) @@ -674,22 +677,20 @@ impl Yumush { .absolute() .left_0() .right_0() - .bottom(px(12.)) + .bottom(px(space::MD)) .flex() .justify_center() .on_mouse_up(MouseButton::Left, |_, _, cx| cx.stop_propagation()) - .when(!bar, |this| this.opacity(0.)) + .when(!bar, |this| this.invisible()) .child( div() - .h(px(38.)) - .px(px(4.)) + .h(px(size::CONTROL)) + .px(px(space::XS)) .flex() .items_center() - .gap(px(4.)) - .rounded(px(10.)) - .bg(gpui_kit::black().opacity(0.85)) - .border_1() - .border_color(palette.border) + .gap(px(space::XS)) + .rounded(px(radius::LG)) + .bg(palette.field) .children(audio.then(|| { let muted = self.settings.share.volume == 0.; icon_button( @@ -707,7 +708,7 @@ impl Yumush { ) })) .children(audio.then(|| { - div().w(px(80.)).child( + div().w(px(VOLUME_WIDTH)).child( Slider::new(&viewer.volume) .bg(palette.screen) .text_color(palette.text), @@ -749,16 +750,14 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> let screen = kind == Kind::Screen; div() - .w(px(320.)) - .p(px(10.)) + .w(px(size::POPOVER)) + .p(px(space::MD)) .flex() .flex_col() - .gap(px(12.)) - .text_size(text(12.)) - .rounded(px(8.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) + .gap(px(space::MD)) + .text_size(text(text::CAPTION)) + .rounded(px(radius::LG)) + .bg(palette.field) .child(field( "Resolution", segmented( @@ -836,7 +835,7 @@ fn audio_list(entity: &Entity, yumush: &Yumush, palette: Palette) -> Opt .filter(|app| app.kind == AudioKind::App) .collect(); (!apps.is_empty()).then(|| { - let rows = div().flex().flex_col().gap(px(2.)).children( + let rows = div().flex().flex_col().gap(px(space::XXS)).children( apps.into_iter() .map(|app| include_row(entity, settings, app, palette)), ); @@ -852,7 +851,7 @@ fn audio_list(entity: &Entity, yumush: &Yumush, palette: Palette) -> Opt fn app_list(rows: impl IntoElement) -> impl IntoElement { div() .id("share_apps") - .max_h(px(160.)) + .max_h(px(APPS_HEIGHT)) .overflow_y_scroll() .child(rows) } @@ -872,7 +871,7 @@ fn pick_list( div() .flex() .flex_col() - .gap(px(8.)) + .gap(px(space::SM)) .children(groups.into_iter().filter_map(|(kind, label)| { let rows: Vec<_> = apps .iter() @@ -887,11 +886,11 @@ fn group(label: &'static str, rows: Vec, palette: Palette) -> div() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child( div() - .px(px(8.)) - .text_size(text(11.)) + .px(px(space::SM)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(label), ) @@ -902,10 +901,10 @@ fn field(label: &'static str, control: impl IntoElement, palette: Palette) -> Di div() .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::SM)) .child( div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(label), ) @@ -913,12 +912,12 @@ fn field(label: &'static str, control: impl IntoElement, palette: Palette) -> Di } fn row_style(item: E) -> E { - item.h(px(28.)) - .px(px(8.)) + item.h(px(size::CONTROL_SM)) + .px(px(space::SM)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) } fn name_cell(app: &AudioApp, palette: Palette) -> Div { @@ -927,13 +926,13 @@ fn name_cell(app: &AudioApp, palette: Palette) -> Div { .min_w_0() .flex() .items_baseline() - .gap(px(6.)) + .gap(px(space::SM)) .child(div().flex_none().child(app.name.clone())) .child( div() .min_w_0() .truncate() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(app.detail.clone()), ) @@ -982,8 +981,7 @@ fn pick_row( .child(name_cell(app, palette)) .children(chosen.then(|| { Icon::new(IconName::Check) - .w(px(14.)) - .h(px(14.)) + .size(px(size::ICON_SM)) .flex_shrink_0() .text_color(palette.ok) })) diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 62140ec..f7c164a 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -10,7 +10,7 @@ use common::{ }; use gpui_kit::{ Anchor, AnimationExt, AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement, - IntoElement, ParentElement, Pixels, StatefulInteractiveElement, Styled, Window, + IntoElement, ParentElement, StatefulInteractiveElement, Styled, Window, assets::IconName, component::{ Icon, @@ -25,18 +25,15 @@ use gpui_kit::{ use super::{ Palette, Tooltip as _, Yumush, avatar, chat::{View, create_community}, - clickable, community_icon, community_name, entity_action, hoverable, hoverable_with, - input_dialog, motion, presence_avatar, + clickable, community_icon, community_name, entity_action, hoverable, input_dialog, motion, + presence_avatar, profile::profile_popover, - settings_page::{segment, segment_track}, social::Relation, + style::{radius, size, space, stroke, text}, wave::mini_wave, widget::{bare_input, compact_frame, icon_button}, }; -const SIDEBAR_WIDTH: f32 = 232.; -const SIDEBAR_COLLAPSED_WIDTH: f32 = 48.; - #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum SidebarTab { Messages, @@ -52,9 +49,9 @@ impl Yumush { ) -> impl IntoElement { let collapsed = self.chat.sidebar_collapsed; let (from, to, id) = if collapsed { - (SIDEBAR_WIDTH, SIDEBAR_COLLAPSED_WIDTH, "sidebar_collapsing") + (size::SIDEBAR, size::ROW, "sidebar_collapsing") } else { - (SIDEBAR_COLLAPSED_WIDTH, SIDEBAR_WIDTH, "sidebar_expanding") + (size::ROW, size::SIDEBAR, "sidebar_expanding") }; let content = if collapsed { self.collapsed_sidebar(entity, palette).into_any_element() @@ -75,19 +72,19 @@ impl Yumush { fn collapsed_sidebar(&self, entity: &Entity, palette: Palette) -> Div { div() .h_full() - .w(px(SIDEBAR_COLLAPSED_WIDTH)) + .w(px(size::ROW)) .flex() .flex_col() .items_center() .justify_between() - .py(px(12.)) + .py(px(space::MD)) .child(self.collapse_button(entity, palette)) .child( div() .flex() .flex_col() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .children(self.voice_dot(entity, palette)) .children( self.user @@ -112,17 +109,17 @@ impl Yumush { div() .h_full() - .w(px(SIDEBAR_WIDTH)) + .w(px(size::SIDEBAR)) .flex() .flex_col() - .py(px(12.)) - .px(px(10.)) - .gap(px(14.)) + .py(px(space::MD)) + .px(px(space::MD)) + .gap(px(space::LG)) .child( div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child(self.tab_bar(entity, palette)) .child(self.collapse_button(entity, palette)), ) @@ -145,21 +142,27 @@ impl Yumush { .iter() .filter(|id| self.chat.waves.speaking.contains(id)) .find_map(|id| self.chat.waves.voice(*id)); + let voice = if wave.is_some() { + super::parts::Voice::Live(palette.ok) + } else { + super::parts::Voice::Quiet + }; div() .id(format!("voice_chip_{community_id}")) .tip("In call") - .h(px(18.)) - .px(px(5.)) .flex() .items_center() - .gap(px(4.)) - .rounded(px(4.)) - .bg(palette.ok.opacity(0.15)) - .children(wave.map(|history| mini_wave(history, 12., palette.ok))) + .gap(px(space::XS)) .child( div() - .text_size(text(11.)) - .text_color(palette.ok) + .w(px(size::CONTROL)) + .h(px(space::MD)) + .child(super::parts::voice_line(wave, voice, palette.tokens)), + ) + .child( + div() + .text_size(text(text::CAPTION)) + .text_color(palette.muted) .child(ids.len().to_string()), ) .into_any_element() @@ -178,15 +181,15 @@ impl Yumush { Some( div() - .ml(px(18.)) - .pl(px(10.)) + .ml(px(space::LG)) + .pl(px(space::MD)) .border_l_1() .border_color(palette.border) .flex() .flex_col() - .gap(px(1.)) - .mt(px(2.)) - .mb(px(4.)) + .gap(px(space::XXS)) + .mt(px(space::XXS)) + .mb(px(space::XS)) .children(members), ) } @@ -205,10 +208,11 @@ impl Yumush { let speaking = self.chat.waves.speaking.contains(&user_id); let shown = speaking || (me && !muted); let wave = shown.then(|| self.chat.waves.voice(user_id)).flatten(); - let wave_tone = - self.chat - .waves - .tone(user_id, self.user.as_ref().map(|user| user.id), palette.ok); + let voice = if wave.is_some() { + super::parts::Voice::Live(palette.tinted(user_id)) + } else { + super::parts::Voice::Quiet + }; let camera = self .chat .share_of(community_id, user_id, Kind::Camera) @@ -222,37 +226,41 @@ impl Yumush { let identity = div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .flex_1() .min_w_0() .cursor_pointer() - .child(avatar(palette, user, px(18.), text(9.), &self.chat.avatars)) .child( div() .min_w_0() .truncate() - .text_size(text(12.)) - .text_color(if speaking { palette.text } else { palette.body }) + .text_size(text(text::LABEL)) + .text_color(if speaking { palette.text } else { palette.muted }) .when(speaking, |name| name.font_weight(FontWeight::SEMIBOLD)) .child(user.username.clone()), ) - .children(wave.map(|history| mini_wave(history, 12., wave_tone))) + .child( + div() + .w(px(size::CONTROL)) + .h(px(space::MD)) + .flex_none() + .child(super::parts::voice_line(wave, voice, palette.tokens)), + ) .children((muted && wave.is_none()).then(|| { Icon::new(IconName::MicOff) - .w(px(12.)) - .h(px(12.)) + .size(px(size::ICON_SM)) .text_color(palette.danger) })); div() - .h(px(26.)) - .px(px(6.)) - .rounded(px(6.)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) + .rounded(px(radius::MD)) .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .hover(move |style| style.bg(palette.hover)) - .when(ghost, |row| row.opacity(0.5)) + .when(ghost, |row| row.text_color(palette.tokens.faint())) .child(div().flex_1().min_w_0().child(profile_popover( format!("call_member_{user_id}"), Anchor::BottomLeft, @@ -286,24 +294,20 @@ impl Yumush { let community = self.chat.voice_room()?; Some( - call_style( - clickable( - "voice_panel_go_collapsed", - palette, - go_to_call(entity, community), - ), + clickable( + "voice_panel_go_collapsed", palette, + go_to_call(entity, community), ) .tip("Go to call") - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .child( Icon::new(IconName::AudioLines) - .w(px(14.)) - .h(px(14.)) + .size(px(size::ICON_SM)) .text_color(palette.ok), ), ) @@ -372,25 +376,35 @@ impl Yumush { ), ]; - segment_track(palette) + div() .flex_1() + .flex() + .items_center() + .gap(px(space::LG)) .children(tabs.map(|(tab, label, alert)| { - let item = segment( - clickable( - label, - palette, - entity_action(entity, move |yumush, window, cx| { - yumush.set_sidebar_tab(tab, window, cx) - }), - ), - self.chat.tab == tab, + let active = self.chat.tab == tab; + let item = clickable( + label, palette, + entity_action(entity, move |yumush, window, cx| { + yumush.set_sidebar_tab(tab, window, cx) + }), ) - .flex_1() - .gap(px(6.)) - .text_size(text(12.)) - .child(label) - .children(unread_badge(palette, false, Some(&alert))); + .flex() + .flex_col() + .gap(px(space::XXS)) + .text_size(text(text::CAPTION)) + .text_color(if active { palette.text } else { palette.muted }) + .when(active, |item| item.font_weight(FontWeight::MEDIUM)) + .child( + div() + .flex() + .items_center() + .gap(px(space::XS)) + .child(label) + .children(unread_badge(palette, false, Some(&alert))), + ) + .children(active.then(|| div().h(px(stroke::LINE)).bg(palette.text))); match tab { SidebarTab::Communities => item @@ -411,7 +425,7 @@ impl Yumush { div() .flex() .flex_col() - .gap(px(14.)) + .gap(px(space::LG)) .child(self.notes_row(entity, palette)) .children(found.map(|user| self.found_row(entity, user, palette))) .children( @@ -424,7 +438,7 @@ impl Yumush { div() .flex() .flex_col() - .gap(px(1.)) + .gap(px(space::XXS)) .children(self.direct_rows(entity, query, palette)), ) .children(group( @@ -440,19 +454,18 @@ impl Yumush { let unread = notes.and_then(|notes| self.chat.unread.get(¬es.id)); let open = entity.clone(); - hoverable_with( + hoverable( "notes", entry( palette, active, Icon::new(IconName::Bookmark) - .w(px(20.)) - .h(px(20.)) + .size(px(size::ICON)) .text_color(palette.accent), "Notes", unread_badge(palette, false, unread), ), - palette.accent.opacity(0.1), + palette, ) .on_click(move |_, window, cx| open.update(cx, |yumush, cx| yumush.open_notes(window, cx))) .into_any_element() @@ -474,7 +487,7 @@ impl Yumush { } fn communities_list(&self, entity: &Entity, palette: Palette) -> Div { - div().flex().flex_col().gap(px(1.)).children( + div().flex().flex_col().gap(px(space::XXS)).children( self.chat .communities .iter() @@ -489,7 +502,6 @@ impl Yumush { entity, community, palette, - px(16.), "community", community_menu(entity, community.id, can_leave, muted), ); @@ -508,7 +520,6 @@ impl Yumush { entity: &Entity, community: &Community, palette: Palette, - size: Pixels, key: &str, menu: impl Fn(PopupMenu, &mut Window, &mut Context) -> PopupMenu + 'static, ) -> AnyElement { @@ -523,17 +534,25 @@ impl Yumush { } else { Some(self.voice_chip(community_id, palette)) }; - let themed = palette; - hoverable_with( + hoverable( format!("{key}_{}", community.id), - entry( - themed, - active, - self.community_badge(community, size, text(10.), palette), - community_name(community).to_string(), - trailing, - ), - themed.accent.opacity(0.1), + div() + .h(px(size::CONTROL)) + .px(px(space::SM)) + .rounded(px(radius::MD)) + .flex() + .items_center() + .gap(px(space::XS)) + .text_color(if active { palette.text } else { palette.muted }) + .when(active, |row| row.font_weight(FontWeight::MEDIUM)) + .child( + div() + .min_w_0() + .truncate() + .child(community_name(community).to_string()), + ) + .children(trailing), + palette, ) .on_click(move |_, window, cx| { select.update(cx, |yumush, cx| { @@ -582,7 +601,6 @@ impl Yumush { entity, community, palette, - px(20.), "direct", move |menu, _, _| mute_item(menu, &menu_entity, menu_id, muted), ) @@ -668,9 +686,9 @@ impl Yumush { palette, false, presence_avatar( - avatar(palette, user, px(20.), text(10.), &self.chat.avatars), + avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), self.presence_of(user.id), - px(20.), + px(size::AVATAR), palette, ), user.username.clone(), @@ -732,7 +750,7 @@ impl Yumush { let community = &invitation.community; let label = div().flex().flex_col().child(community.name.clone()).child( div() - .text_size(text(11.)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(format!("from {}", invitation.inviter.username)), ); @@ -740,7 +758,13 @@ impl Yumush { entry( palette, false, - community_icon(palette, community, px(16.), text(10.), &self.chat.avatars), + community_icon( + palette, + community, + px(size::ICON), + text(text::CAPTION), + &self.chat.avatars, + ), label, [ row_button( @@ -770,10 +794,10 @@ impl Yumush { let user = self.user.as_ref()?; Some( div() - .h(px(36.)) + .h(px(size::CONTROL)) .flex() .items_center() - .gap(px(4.)) + .gap(px(space::XS)) .child(self.account_trigger(entity, user, true, palette)) .children(self.is_builder().then(|| { icon_button( @@ -806,14 +830,14 @@ impl Yumush { div() .flex() .items_center() - .h(px(36.)) - .gap(px(8.)) - .px(px(6.)) - .rounded(px(6.)) + .h(px(size::CONTROL)) + .gap(px(space::SM)) + .px(px(space::SM)) + .rounded(px(radius::MD)) .child(presence_avatar( - avatar(palette, user, px(24.), text(12.), &self.chat.avatars), + avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), self.presence_of(user.id), - px(24.), + px(size::AVATAR), palette, )) .when(named, |trigger| { @@ -872,9 +896,9 @@ fn watch_pill( wave: Option<&VecDeque>, palette: Palette, ) -> impl IntoElement { - let (color, icon) = match kind { - Kind::Camera => (palette.camera, IconName::Video), - Kind::Screen => (palette.screen, IconName::ScreenShare), + let icon = match kind { + Kind::Camera => IconName::Video, + Kind::Screen => IconName::ScreenShare, }; let tip = match (watching, kind) { (true, _) => "Stop watching", @@ -889,24 +913,20 @@ fn watch_pill( }), ) .tip(tip) - .h(px(18.)) - .px(px(5.)) + .h(px(size::CHIP)) + .px(px(space::XS)) .flex() .items_center() - .gap(px(4.)) - .rounded(px(5.)) - .bg(color.opacity(0.12)) - .child(Icon::new(icon).w(px(12.)).h(px(12.)).text_color(color)) + .gap(px(space::XS)) + .rounded(px(radius::SM)) + .child( + Icon::new(icon) + .size(px(size::ICON_SM)) + .text_color(if watching { palette.text } else { palette.muted }), + ) .children(wave.map(|history| mini_wave(history, 10., palette.screen))) } -fn call_style(element: E, palette: Palette) -> E { - element - .border_1() - .border_color(palette.ok.opacity(0.35)) - .bg(palette.ok.opacity(0.08)) -} - pub(super) fn unread_badge( palette: Palette, muted: bool, @@ -916,32 +936,28 @@ pub(super) fn unread_badge( return Some( div() .text_color(palette.muted) - .child(Icon::new(IconName::BellOff).w(px(12.)).h(px(12.))) + .child(Icon::new(IconName::BellOff).size(px(size::ICON_SM))) .into_any_element(), ); } let unread = unread.filter(|unread| unread.messages > 0)?; - let (fill, ink) = if unread.mentions > 0 { - (palette.accent, palette.on_accent) - } else { - (palette.muted, palette.window) - }; + if unread.mentions == 0 { + return Some( + div() + .size(px(space::XS + space::XXS)) + .rounded_full() + .bg(palette.text) + .into_any_element(), + ); + } let count = match unread.messages { 1..=99 => unread.messages.to_string(), _ => "99+".to_string(), }; Some( div() - .h(px(16.)) - .min_w(px(16.)) - .px(px(4.)) - .flex() - .items_center() - .justify_center() - .rounded_full() - .text_size(text(10.)) - .bg(fill) - .text_color(ink) + .text_size(text(text::CAPTION)) + .text_color(palette.text) .child(count) .into_any_element(), ) @@ -1033,9 +1049,9 @@ fn new_community_menu( pub(super) fn input_box(input: &Entity, palette: Palette) -> Div { compact_frame(palette) - .gap(px(8.)) + .gap(px(space::SM)) .text_color(palette.muted) - .child(Icon::new(IconName::Search).w(px(14.)).h(px(14.))) + .child(Icon::new(IconName::Search).size(px(size::ICON_SM))) .child(bare_input(palette, Input::new(input))) } @@ -1044,11 +1060,11 @@ fn group(title: &'static str, palette: Palette, rows: Vec) -> Option div() .flex() .flex_col() - .gap(px(1.)) + .gap(px(space::XXS)) .child( div() - .px(px(8.)) - .text_size(text(11.)) + .px(px(space::SM)) + .text_size(text(text::CAPTION)) .text_color(palette.muted) .child(title), ) @@ -1064,14 +1080,14 @@ fn entry( trailing: impl IntoIterator, ) -> Div { div() - .h(px(36.)) - .px(px(6.)) + .h(px(size::CONTROL)) + .px(px(space::SM)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .text_color(if active { palette.text } else { palette.body }) - .when(active, |this| this.bg(palette.accent.opacity(0.18))) + .when(active, |this| this.bg(palette.tokens.press())) .child(leading) .child(div().flex_1().min_w_0().truncate().child(label)) .children(trailing) diff --git a/crates/client/src/gui/snippet.rs b/crates/client/src/gui/snippet.rs index 71f220f..77dc66f 100644 --- a/crates/client/src/gui/snippet.rs +++ b/crates/client/src/gui/snippet.rs @@ -1,4 +1,4 @@ -use super::text; +use super::style::{size, space, text}; use crate::gui::CLOCK; use common::model::{Message, Role, SnippetMessage, User}; use gpui_kit::{ @@ -27,11 +27,11 @@ pub fn snippet_card( panel(palette) .flex() .flex_col() - .gap(px(10.)) - .p(px(10.)) + .gap(px(space::MD)) + .p(px(space::MD)) .child( div() - .text_size(text(12.)) + .text_size(super::text(text::CAPTION)) .text_color(palette.muted) .child(header), ) @@ -61,12 +61,12 @@ fn snippet_row( div() .flex() - .gap(px(8.)) + .gap(px(space::SM)) .child(user_link( format!("snippet_avatar_{}", item.id), Some(&user), entity, - avatar(palette, &user, px(20.), text(10.), &chat.avatars), + avatar(palette, &user, px(size::AVATAR), super::text(text::CAPTION), &chat.avatars), )) .child( div() @@ -74,12 +74,12 @@ fn snippet_row( .min_w_0() .flex() .flex_col() - .gap(px(4.)) + .gap(px(space::XS)) .child( div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child(user_link( format!("snippet_name_{}", item.id), Some(&user), @@ -91,7 +91,7 @@ fn snippet_row( )) .child( div() - .text_size(text(11.)) + .text_size(super::text(text::CAPTION)) .text_color(palette.muted) .child(millis_time(item.created_at, CLOCK)), ), diff --git a/crates/client/src/gui/social.rs b/crates/client/src/gui/social.rs index 6ae950c..f886d36 100644 --- a/crates/client/src/gui/social.rs +++ b/crates/client/src/gui/social.rs @@ -22,6 +22,7 @@ use gpui_kit::{ use super::{ Palette, Yumush, avatar, new_input, notify_error, primary_button, text, + style::{radius, size, space}, widget::{search_text, spawn_done}, }; @@ -303,7 +304,7 @@ impl Yumush { div() .flex() .flex_col() - .gap(px(12.)) + .gap(px(space::MD)) .child(Input::new(&dialog_input)) .children(result), ) @@ -399,7 +400,7 @@ fn invite_result( InviteLookup::Idle => None, InviteLookup::Missing => Some( div() - .text_size(text(13.)) + .text_size(text(super::style::text::LABEL)) .text_color(palette.muted) .child("No such user") .into_any_element(), @@ -408,7 +409,7 @@ fn invite_result( user_row(user, yumush, palette) .child( div() - .text_size(text(13.)) + .text_size(text(super::style::text::LABEL)) .text_color(palette.muted) .child(Rank::Member.label()), ) @@ -425,11 +426,11 @@ fn invite_result( yumush.send_invite(community_id, window, cx) }) }) - .h(px(30.)) - .px(px(14.)) + .h(px(size::CONTROL)) + .px(px(space::LG)) .flex() .items_center() - .rounded(px(8.)) + .rounded(px(radius::MD)) .child("Invite"), ) .into_any_element(), @@ -442,12 +443,12 @@ fn user_row(user: &User, yumush: &Yumush, palette: Palette) -> Div { div() .flex() .items_center() - .gap(px(10.)) + .gap(px(space::MD)) .child(avatar( palette, user, - px(32.), - text(14.), + px(size::AVATAR), + text(super::style::text::UI), &yumush.chat.avatars, )) .child( diff --git a/crates/client/src/gui/stream_stats.rs b/crates/client/src/gui/stream_stats.rs index 88cdbd0..c75c76c 100644 --- a/crates/client/src/gui/stream_stats.rs +++ b/crates/client/src/gui/stream_stats.rs @@ -1,12 +1,14 @@ use common::{model::Id, share::Kind}; use gpui_kit::{Div, FontWeight, Hsla, ParentElement, Styled, component::Icon, div, px}; -use super::{Palette, Yumush, share_view::kind_icon, text, voice_stats::rate}; +use super::{ + Palette, Yumush, + share_view::kind_icon, + style::{radius, size, space, text}, + voice_stats::rate, +}; use crate::{media::decode::Engine, share::session::WatchStats}; -const GRAPH_HEIGHT: f32 = 48.; -const AXIS_WIDTH: f32 = 34.; - pub(super) fn watch_stats(yumush: &Yumush, user_id: Id, kind: Kind) -> Option<&WatchStats> { yumush .chat @@ -38,25 +40,22 @@ pub(super) fn stream_card(yumush: &Yumush, user_id: Id, kind: Kind, palette: Pal let value = |format: fn(&WatchStats) -> String| stats.map_or("…".to_string(), format); div() - .w(px(300.)) - .p(px(12.)) + .w(px(size::POPOVER)) + .p(px(space::MD)) .flex() .flex_col() - .gap(px(12.)) - .text_size(text(12.)) - .rounded(px(10.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) + .gap(px(space::MD)) + .text_size(super::text(text::CAPTION)) + .rounded(px(radius::LG)) + .bg(palette.field) .child( div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child( Icon::new(kind_icon(kind)) - .w(px(14.)) - .h(px(14.)) + .size(px(size::ICON_SM)) .flex_none() .text_color(tone), ) @@ -145,16 +144,16 @@ fn graph(losses: &[f32], color: Hsla, palette: Palette) -> Div { div() .flex() - .gap(px(6.)) - .h(px(GRAPH_HEIGHT)) + .gap(px(space::SM)) + .h(px(size::ROW)) .child( div() - .w(px(AXIS_WIDTH)) + .w(px(size::CONTROL)) .h_full() .flex() .flex_col() .justify_between() - .text_size(text(10.)) + .text_size(super::text(text::CAPTION)) .text_color(palette.muted) .children([top, top / 2., 0.].map(|value| div().child(format!("{value:.1}%")))), ) @@ -162,7 +161,7 @@ fn graph(losses: &[f32], color: Hsla, palette: Palette) -> Div { div() .flex_1() .h_full() - .rounded(px(4.)) + .rounded(px(radius::SM)) .bg(palette.window) .child(super::wave::line(levels, color)), ) @@ -172,10 +171,10 @@ fn section(title: &'static str, rows: Vec
, palette: Palette) -> Div { div() .flex() .flex_col() - .gap(px(4.)) + .gap(px(space::XS)) .child( div() - .text_size(text(11.)) + .text_size(super::text(text::CAPTION)) .font_weight(FontWeight::SEMIBOLD) .text_color(palette.muted) .child(title), @@ -188,8 +187,8 @@ fn row(key: &'static str, value: String, palette: Palette) -> Div { .flex() .items_center() .justify_between() - .gap(px(8.)) - .text_size(text(11.)) + .gap(px(space::SM)) + .text_size(super::text(text::CAPTION)) .child(div().text_color(palette.muted).child(key)) .child( div() diff --git a/crates/client/src/gui/style.rs b/crates/client/src/gui/style.rs index ac35181..fcaa038 100644 --- a/crates/client/src/gui/style.rs +++ b/crates/client/src/gui/style.rs @@ -125,42 +125,7 @@ mod tests { assert_eq!(names, HUE_NAMES); } - const UNMIGRATED: [&str; 34] = [ - "gui/auth.rs", - "gui/builder.rs", - "gui/builder/access.rs", - "gui/builder/backups.rs", - "gui/builder/communities.rs", - "gui/builder/log.rs", - "gui/builder/messages.rs", - "gui/builder/overview.rs", - "gui/builder/reports.rs", - "gui/builder/server.rs", - "gui/builder/storage.rs", - "gui/builder/ui.rs", - "gui/builder/users.rs", - "gui/builder/voice.rs", - "gui/camera_view.rs", - "gui/chat.rs", - "gui/community_settings.rs", - "gui/composer.rs", - "gui/forward.rs", - "gui/media_view.rs", - "gui/message_actions.rs", - "gui/poll.rs", - "gui/profile.rs", - "gui/settings_page.rs", - "gui/share_view.rs", - "gui/sidebar.rs", - "gui/snippet.rs", - "gui/social.rs", - "gui/stream_stats.rs", - "gui/surface.rs", - "gui/voice_note.rs", - "gui/voice_settings.rs", - "gui/voice_stats.rs", - "gui/wave.rs", - ]; + const UNMIGRATED: [&str; 0] = []; const FREE: [&str; 2] = ["gui/style.rs", "gui/parts.rs"]; fn sources(dir: &std::path::Path, out: &mut Vec) { diff --git a/crates/client/src/gui/voice_note.rs b/crates/client/src/gui/voice_note.rs index 2d552a8..b131a59 100644 --- a/crates/client/src/gui/voice_note.rs +++ b/crates/client/src/gui/voice_note.rs @@ -20,7 +20,9 @@ use super::{ chat::VoiceState, clickable, media_view::{time_text, upload_file}, - notify_error, primary_button, text, + notify_error, primary_button, + style::{self, radius, size, space}, + text, widget::ok_or_notify, }; use crate::{ @@ -105,7 +107,7 @@ pub fn bars( div() .w(px(BAR_WIDTH)) .h(px((BAR_MAX * level).max(BAR_MIN))) - .rounded(px(BAR_WIDTH / 2.)) + .rounded_full() .bg(color), ) })) @@ -121,39 +123,37 @@ pub fn recording_row( let send = entity.clone(); div() - .min_h(px(40.)) - .pl(px(4.)) - .pr(px(4.)) - .py(px(4.)) + .min_h(px(size::ROW)) + .pl(px(space::XS)) + .pr(px(space::XS)) + .py(px(space::XS)) .flex() .items_center() - .gap(px(8.)) - .rounded(px(8.)) - .border_1() - .border_color(palette.border) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .bg(palette.field) .child( clickable("cancel_voice_note", palette, move |_, cx| { cancel.update(cx, |yumush, cx| yumush.cancel_voice_note(cx)) }) .tip("Cancel") - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.muted) - .child(Icon::new(IconName::X).w(px(16.)).h(px(16.))), + .child(Icon::new(IconName::X).size(px(size::ICON))), ) .child( div() .flex_1() .flex() .items_center() - .gap(px(6.)) - .text_size(text(13.)) + .gap(px(space::SM)) + .text_size(text(style::text::LABEL)) .text_color(palette.text) - .child(Icon::new(IconName::Mic).w(px(14.)).h(px(14.))) + .child(Icon::new(IconName::Mic).size(px(size::ICON_SM))) .child(time_text( started .elapsed() @@ -166,12 +166,12 @@ pub fn recording_row( send.update(cx, |yumush, cx| yumush.send_voice_note(window, cx)) }) .tip("Send") - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) - .child(Icon::new(IconName::ArrowUp).w(px(14.)).h(px(14.))), + .rounded(px(radius::MD)) + .child(Icon::new(IconName::ArrowUp).size(px(size::ICON_SM))), ) } @@ -182,13 +182,13 @@ pub fn mic_button(entity: &Entity, palette: Palette) -> impl IntoElement entity.update(cx, |yumush, cx| yumush.start_voice_note(window, cx)) }) .tip("Voice message") - .size(px(28.)) + .size(px(size::CONTROL_SM)) .flex() .items_center() .justify_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .text_color(palette.muted) - .child(Icon::new(IconName::Mic).w(px(16.)).h(px(16.))) + .child(Icon::new(IconName::Mic).size(px(size::ICON))) } impl Yumush { diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index dc8b9e3..54b4d1a 100644 --- a/crates/client/src/gui/voice_settings.rs +++ b/crates/client/src/gui/voice_settings.rs @@ -18,6 +18,7 @@ use gpui_kit::{ use super::{ Palette, Yumush, clickable, settings_page::{row, segmented}, + style::{radius, size, space}, }; use crate::{ settings::{Activation, Profile, SENSITIVITY_DB, VOLUME, VoiceSettings}, @@ -175,11 +176,11 @@ fn volume_control(state: &Entity, value: f32, palette: Palette) -> div() .flex() .items_center() - .gap(px(8.)) - .child(Slider::new(state).w(px(160.))) + .gap(px(space::SM)) + .child(Slider::new(state).w(px(size::THUMB))) .child( div() - .w(px(44.)) + .w(px(size::ROW)) .text_right() .text_color(palette.muted) .child(format!("{value:.0}%")), @@ -198,15 +199,15 @@ fn level_bar(level: Option, threshold: f32, palette: Palette) -> Div { }; div() - .h(px(4.)) + .h(px(space::XS)) .w_full() - .rounded(px(2.)) + .rounded(px(radius::SM)) .bg(palette.border) .child( div() .h_full() .w(relative(fraction)) - .rounded(px(2.)) + .rounded(px(radius::SM)) .bg(color), ) } @@ -219,11 +220,11 @@ impl Yumush { let mut rows = vec![ row( "Input device", - div().child(Select::new(&controls.inputs).w(px(200.))), + div().child(Select::new(&controls.inputs).w(px(size::SIDEBAR))), ), row( "Output device", - div().child(Select::new(&controls.outputs).w(px(200.))), + div().child(Select::new(&controls.outputs).w(px(size::SIDEBAR))), ), row( "Input volume", @@ -279,12 +280,12 @@ impl Yumush { div() .flex() .items_center() - .gap(px(6.)) + .gap(px(space::SM)) .child( test_button("mic_test_button", palette, testing, move |_, cx| { mic.update(cx, |yumush, cx| yumush.toggle_mic_test(cx)); }) - .child(Icon::new(IconName::Mic).w(px(14.)).h(px(14.))) + .child(Icon::new(IconName::Mic).size(px(size::ICON_SM))) .child(if testing { "Stop" } else { "Hear yourself" }), ) .child( @@ -293,7 +294,7 @@ impl Yumush { yumush.network.play_chime(&yumush.settings.voice) }); }) - .child(Icon::new(IconName::Volume2).w(px(14.)).h(px(14.))) + .child(Icon::new(IconName::Volume2).size(px(size::ICON_SM))) .child("Play sound"), ) } @@ -301,12 +302,12 @@ impl Yumush { fn sensitivity_control(&self, palette: Palette) -> Div { let level = self.network.voice_level_db(); - div().flex().items_center().gap(px(8.)).child( + div().flex().items_center().gap(px(space::SM)).child( div() - .w(px(200.)) + .w(px(size::SIDEBAR)) .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::SM)) .child(Slider::new(&self.voice.sensitivity)) .child(level_bar( level, @@ -335,11 +336,11 @@ impl Yumush { clickable("ptt_key_button", palette, move |window, cx| { entity.update(cx, |yumush, cx| yumush.capture_key(window, cx)); }) - .h(px(28.)) - .px(px(8.)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) .flex() .items_center() - .rounded(px(6.)) + .rounded(px(radius::MD)) .child(content) } @@ -533,12 +534,12 @@ fn test_button( on_click: impl Fn(&mut Window, &mut App) + 'static, ) -> Stateful
{ clickable(id, palette, on_click) - .h(px(28.)) - .px(px(10.)) + .h(px(size::CONTROL_SM)) + .px(px(space::MD)) .flex() .items_center() - .gap(px(6.)) - .rounded(px(6.)) + .gap(px(space::SM)) + .rounded(px(radius::MD)) .border_1() .border_color(if active { palette.accent diff --git a/crates/client/src/gui/voice_stats.rs b/crates/client/src/gui/voice_stats.rs index 5090a82..11dc8e5 100644 --- a/crates/client/src/gui/voice_stats.rs +++ b/crates/client/src/gui/voice_stats.rs @@ -1,23 +1,32 @@ use std::collections::VecDeque; use common::{ - model::Id, + model::{Hue, Id}, share::{Kind, Layer}, }; use gpui_kit::{ - Div, FontWeight, Hsla, ParentElement, Styled, assets::IconName, component::Icon, div, hsla, - prelude::FluentBuilder as _, px, relative, rgb, + Div, FontWeight, Hsla, ParentElement, Styled, assets::IconName, component::Icon, div, + prelude::FluentBuilder as _, px, relative, }; -use super::{Palette, chat::Chat, share_view::kind_icon, text, wave}; +use super::{ + Palette, + chat::Chat, + share_view::kind_icon, + style::{radius, size, space, stroke, text}, + text as text_size, wave, +}; use crate::media::decode::Engine; use crate::share::session::{LayerStats, WatchStats}; use crate::usage::{Gpu, Usage}; use crate::voice::VoiceSample; pub const SAMPLE_HISTORY: usize = 60; -const GRAPH_HEIGHT: f32 = 32.; -const MIRROR_HALF: f32 = 22.; +const MIRROR_HALF: f32 = size::CHIP; +const LAYER_W: f32 = 70.; +const WATCH_LAYER_W: f32 = 64.; +const RATE_W: f32 = 52.; +const VALUE_W: f32 = 76.; const PING_SCALE: f32 = 150.; const GOOD_LOSS: f32 = 2.; const FAIR_LOSS: f32 = 8.; @@ -63,7 +72,7 @@ impl Quality { pub fn color(self, palette: Palette) -> Hsla { match self { Self::Good => palette.ok, - Self::Fair => hsla(0.11, 0.85, 0.55, 1.), + Self::Fair => palette.tokens.hue(Hue::Gold), Self::Poor => palette.danger, } } @@ -78,7 +87,7 @@ pub fn stats_panel(chat: &Chat, palette: Palette) -> Div { div() .flex() .flex_col() - .gap(px(16.)) + .gap(px(space::LG)) .child(network_block(chat, palette)) .children(sending_blocks(&share.sending, palette)) .child(receiving_block(&share.watching, chat, palette)) @@ -103,12 +112,12 @@ fn network_block(chat: &Chat, palette: Palette) -> Div { div() .flex() .flex_col() - .gap(px(8.)) - .child(header(IconName::Activity, "Network", color).child(chip(word, color))) + .gap(px(space::SM)) + .child(header(IconName::Activity, "Network", color).child(chip(word, color, palette))) .child( div() .flex() - .gap(px(8.)) + .gap(px(space::SM)) .child(stat_cell("ping", ping, color, palette)) .child(stat_cell("jitter", jitter, color, palette)) .child(stat_cell("loss", loss, color, palette)) @@ -116,9 +125,9 @@ fn network_block(chat: &Chat, palette: Palette) -> Div { ) .child( div() - .h(px(GRAPH_HEIGHT)) - .p(px(2.)) - .rounded(px(4.)) + .h(px(size::CONTROL)) + .p(px(space::XXS)) + .rounded(px(radius::SM)) .bg(palette.window) .child(wave::line( chat.voice_samples @@ -141,11 +150,11 @@ fn traffic(chat: &Chat, palette: Palette) -> Div { div() .flex() .flex_col() - .gap(px(2.)) - .text_size(text(10.)) + .gap(px(space::XXS)) + .text_size(text_size(text::CAPTION)) .child( div() - .text_color(up_color()) + .text_color(up_color(palette)) .child(format!("↑ {}", rate(up_latest as u32))), ) .child( @@ -158,22 +167,22 @@ fn traffic(chat: &Chat, palette: Palette) -> Div { .h(px(MIRROR_HALF)) .flex() .items_end() - .gap(px(1.)) - .children(bars(&up, max, up_color())), + .gap(px(space::XXS)) + .children(bars(&up, max, up_color(palette))), ) - .child(div().h(px(1.)).bg(palette.border)) + .child(div().h(px(stroke::LINE)).bg(palette.border)) .child( div() .h(px(MIRROR_HALF)) .flex() .items_start() - .gap(px(1.)) - .children(bars(&down, max, down_color())), + .gap(px(space::XXS)) + .children(bars(&down, max, down_color(palette))), ), ) .child( div() - .text_color(down_color()) + .text_color(down_color(palette)) .child(format!("↓ {}", rate(down_latest as u32))), ) } @@ -190,12 +199,12 @@ fn bars(values: &[f32], max: f32, color: Hsla) -> Vec
{ .collect() } -fn up_color() -> Hsla { - rgb(0xa78bfa).into() +fn up_color(palette: Palette) -> Hsla { + palette.tokens.hue(Hue::Violet) } -fn down_color() -> Hsla { - rgb(0x22d3ee).into() +fn down_color(palette: Palette) -> Hsla { + palette.tokens.hue(Hue::Teal) } fn sending_blocks(sending: &[(Kind, LayerStats)], palette: Palette) -> Vec
{ @@ -221,7 +230,7 @@ fn sending_block(kind: Kind, layers: &[&LayerStats], palette: Palette) -> Div { div() .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::SM)) .child(header(kind_icon(kind), kind_name(kind), color).child(label(engine, color))) .children( layers @@ -237,16 +246,16 @@ fn layer_row(index: usize, stats: &LayerStats, max: f32, kind: Kind, palette: Pa div() .flex() .items_center() - .gap(px(8.)) - .h(px(28.)) - .px(px(8.)) - .rounded(px(7.)) - .bg(color.opacity(0.08)) - .text_size(text(11.)) - .when(stats.kbps == 0, |this| this.opacity(0.45)) + .gap(px(space::SM)) + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) + .rounded(px(radius::MD)) + .bg(palette.hover) + .text_size(text_size(text::CAPTION)) + .when(stats.kbps == 0, |this| this.text_color(palette.tokens.faint())) .child( div() - .w(px(22.)) + .w(px(size::CHIP)) .flex_none() .font_weight(FontWeight::SEMIBOLD) .text_color(color) @@ -254,14 +263,14 @@ fn layer_row(index: usize, stats: &LayerStats, max: f32, kind: Kind, palette: Pa ) .child( div() - .w(px(70.)) + .w(px(LAYER_W)) .flex_none() .text_color(palette.text) .child(resolution_text(stats.layer, stats.fps)), ) .child( div() - .w(px(32.)) + .w(px(size::CONTROL)) .flex_none() .text_color(palette.muted) .child(stats.layer.codec.name()), @@ -269,7 +278,7 @@ fn layer_row(index: usize, stats: &LayerStats, max: f32, kind: Kind, palette: Pa .child(bar(stats.kbps as f32 / max, color, palette)) .child( div() - .w(px(52.)) + .w(px(RATE_W)) .flex_none() .text_right() .text_color(palette.text) @@ -281,7 +290,7 @@ fn receiving_block(watching: &[(Id, Kind, WatchStats)], chat: &Chat, palette: Pa div() .flex() .flex_col() - .gap(px(6.)) + .gap(px(space::XS)) .child(header(IconName::Eye, "Receiving", palette.text)) .children( watching @@ -303,13 +312,13 @@ fn watch_row(chat: &Chat, user_id: Id, kind: Kind, stats: &WatchStats, palette: div() .flex() .items_center() - .gap(px(4.)) - .h(px(30.)) - .px(px(6.)) - .rounded(px(7.)) - .bg(kind_color(kind, palette).opacity(0.06)) - .text_size(text(11.)) - .child(avatar_dot(&name, color)) + .gap(px(space::XS)) + .h(px(size::CONTROL)) + .px(px(space::SM)) + .rounded(px(radius::MD)) + .bg(palette.hover) + .text_size(text_size(text::CAPTION)) + .child(avatar_dot(&name, color, palette)) .child( div() .flex_1() @@ -321,13 +330,12 @@ fn watch_row(chat: &Chat, user_id: Id, kind: Kind, stats: &WatchStats, palette: ) .child( Icon::new(kind_icon(kind)) - .w(px(11.)) - .h(px(11.)) + .size(px(size::ICON_SM)) .flex_none() .text_color(kind_color(kind, palette)), ) .child( - div().w(px(64.)).flex_none().text_color(palette.text).child( + div().w(px(WATCH_LAYER_W)).flex_none().text_color(palette.text).child( stats .layer .map_or("…".to_string(), |layer| resolution_text(layer, stats.fps)), @@ -335,7 +343,7 @@ fn watch_row(chat: &Chat, user_id: Id, kind: Kind, stats: &WatchStats, palette: ) .child( div() - .w(px(52.)) + .w(px(RATE_W)) .flex_none() .text_color(palette.muted) .child(format!( @@ -346,7 +354,7 @@ fn watch_row(chat: &Chat, user_id: Id, kind: Kind, stats: &WatchStats, palette: ) .child( div() - .w(px(44.)) + .w(px(size::ROW)) .flex_none() .text_right() .text_color(palette.text) @@ -354,13 +362,13 @@ fn watch_row(chat: &Chat, user_id: Id, kind: Kind, stats: &WatchStats, palette: ) .child( div() - .w(px(52.)) + .w(px(RATE_W)) .flex_none() .text_right() .text_color(palette.muted) .child(latency), ) - .child(chip(format!("{loss:.1}%"), loss_color)) + .child(chip(format!("{loss:.1}%"), loss_color, palette)) } fn usage_block(usage: &Usage, palette: Palette) -> Div { @@ -404,24 +412,24 @@ fn usage_block(usage: &Usage, palette: Palette) -> Div { )); div() .flex() - .gap(px(20.)) + .gap(px(space::XL)) .child(cpu) .children(usage.gpu.as_ref().map(|gpu| gpu_column(gpu, palette))) } fn column() -> Div { - div().flex().flex_col().gap(px(6.)).flex_1().min_w_0() + div().flex().flex_col().gap(px(space::SM)).flex_1().min_w_0() } fn model_header(icon: IconName, title: &'static str, model: &str, palette: Palette) -> Div { div() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child(header(icon, title, palette.text)) .child( div() - .text_size(text(10.)) + .text_size(text_size(text::CAPTION)) .text_color(palette.muted) .truncate() .child(model.to_string()), @@ -514,11 +522,11 @@ fn row(label: &'static str, value: String, bar: Div, palette: Palette) -> Div { div() .flex() .items_center() - .gap(px(6.)) - .text_size(text(11.)) + .gap(px(space::SM)) + .text_size(text_size(text::CAPTION)) .child( div() - .w(px(46.)) + .w(px(size::ROW)) .flex_none() .text_color(palette.muted) .child(label), @@ -526,7 +534,7 @@ fn row(label: &'static str, value: String, bar: Div, palette: Palette) -> Div { .child(bar) .child( div() - .w(px(76.)) + .w(px(VALUE_W)) .flex_none() .text_right() .text_color(palette.text) @@ -578,18 +586,17 @@ fn header(icon: IconName, title: &'static str, color: Hsla) -> Div { div() .flex() .items_center() - .gap(px(7.)) + .gap(px(space::SM)) .child( Icon::new(icon) - .w(px(13.)) - .h(px(13.)) + .size(px(size::ICON_SM)) .flex_none() .text_color(color), ) .child( div() .font_weight(FontWeight::SEMIBOLD) - .text_size(text(12.)) + .text_size(text_size(text::CAPTION)) .text_color(color) .child(title), ) @@ -597,17 +604,17 @@ fn header(icon: IconName, title: &'static str, color: Hsla) -> Div { } fn label(value: &'static str, color: Hsla) -> Div { - div().text_size(text(11.)).text_color(color).child(value) + div().text_size(text_size(text::CAPTION)).text_color(color).child(value) } -fn chip(value: impl gpui_kit::IntoElement, color: Hsla) -> Div { +fn chip(value: impl gpui_kit::IntoElement, color: Hsla, palette: Palette) -> Div { div() .flex_none() - .px(px(6.)) - .py(px(1.)) - .rounded(px(5.)) - .bg(color.opacity(0.13)) - .text_size(text(10.)) + .px(px(space::SM)) + .py(px(space::XXS)) + .rounded(px(radius::SM)) + .bg(palette.hover) + .text_size(text_size(text::CAPTION)) .text_color(color) .child(value) } @@ -618,37 +625,37 @@ fn stat_cell(label: &'static str, value: String, color: Hsla, palette: Palette) .min_w_0() .flex() .flex_col() - .gap(px(2.)) + .gap(px(space::XXS)) .child( div() - .text_size(text(10.)) + .text_size(text_size(text::CAPTION)) .text_color(palette.muted) .child(label), ) - .child(div().text_size(text(14.)).text_color(color).child(value)) + .child(div().text_size(text_size(text::UI)).text_color(color).child(value)) } -fn avatar_dot(name: &str, color: Hsla) -> Div { +fn avatar_dot(name: &str, color: Hsla, palette: Palette) -> Div { let initial = name .chars() .next() .map_or('?', |letter| letter.to_ascii_uppercase()); div() - .size(px(18.)) + .size(px(size::CHIP)) .flex_none() .rounded_full() .flex() .items_center() .justify_center() .bg(color) - .text_size(text(9.)) + .text_size(text_size(text::CAPTION)) .font_weight(FontWeight::BOLD) - .text_color(hsla(0., 0., 0.07, 1.)) + .text_color(palette.on_accent) .child(initial.to_string()) } fn dual_bar(own: f32, machine: f32, color: Hsla, palette: Palette) -> Div { - bar(machine, palette.muted.opacity(0.5), palette).child( + bar(machine, palette.tokens.faint(), palette).child( div() .absolute() .top_0() @@ -665,7 +672,7 @@ fn bar(fraction: f32, color: Hsla, palette: Palette) -> Div { .relative() .flex_1() .min_w_0() - .h(px(4.)) + .h(px(space::XS)) .rounded_full() .bg(palette.border) .child( diff --git a/crates/client/src/gui/wave.rs b/crates/client/src/gui/wave.rs index ca685ff..f3b4f6d 100644 --- a/crates/client/src/gui/wave.rs +++ b/crates/client/src/gui/wave.rs @@ -5,7 +5,10 @@ use gpui_kit::{ Div, Hsla, IntoElement, ParentElement, PathBuilder, Styled, canvas, div, point, px, }; -use super::voice_stats::SAMPLE_HISTORY; +use super::{ + style::{radius, stroke}, + voice_stats::SAMPLE_HISTORY, +}; use crate::net::Levels; @@ -17,6 +20,7 @@ const AUDIBLE: f32 = 0.1; const BAR_WIDTH: f32 = 2.; const MIN_BAR: f32 = 1.5; const MINI_BARS: usize = 11; +const GAP: f32 = 1.; pub struct Wave { bars: VecDeque, @@ -129,14 +133,6 @@ impl Waves { *self = Self::default(); } - pub fn tone(&self, id: Id, me: Option, color: Hsla) -> Hsla { - if Some(id) == me && !self.own_live { - color.opacity(0.35) - } else { - color - } - } - pub fn voice(&self, id: Id) -> Option<&VecDeque> { self.voice.get(&id).map(|wave| &wave.bars) } @@ -164,7 +160,7 @@ pub fn mini_wave(history: &VecDeque, size: f32, color: Hsla) -> Div { fn slot(count: usize, bars: Option>, size: f32, color: Hsla) -> Div { div() .flex_shrink_0() - .w(px(count as f32 * (BAR_WIDTH + 1.) - 1.)) + .w(px(count as f32 * (BAR_WIDTH + GAP) - GAP)) .children(bars.map(|bars| wave(&bars, size, color))) } @@ -172,13 +168,13 @@ fn wave(bars: &[f32], size: f32, color: Hsla) -> Div { div() .flex() .items_center() - .gap(px(1.)) + .gap(px(GAP)) .h(px(size)) .children(bars.iter().map(|bar| { div() .w(px(BAR_WIDTH)) .h(px((size * bar).max(MIN_BAR))) - .rounded(px(1.)) + .rounded(px(radius::SM)) .bg(color) })) } @@ -192,7 +188,7 @@ pub fn line_of(levels: Vec, slots: usize, color: Hsla) -> impl IntoElement |_, _, _| {}, move |bounds, _, window, _| { let first = slots.saturating_sub(levels.len()); - let mut path = PathBuilder::stroke(px(1.5)); + let mut path = PathBuilder::stroke(px(stroke::LINE)); for (index, &level) in levels.iter().enumerate() { let step = (first + index) as f32 / slots.saturating_sub(1).max(1) as f32; let x = bounds.origin.x + bounds.size.width * step;