diff --git a/crates/client/src/gui/poll.rs b/crates/client/src/gui/poll.rs index e31a1dd..085c48e 100644 --- a/crates/client/src/gui/poll.rs +++ b/crates/client/src/gui/poll.rs @@ -3,10 +3,10 @@ use std::collections::HashSet; use common::model::{Message, Poll, Rank, User}; use gpui_kit::{ Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement, Styled, - Window, assets::IconName, component::Icon, div, px, relative, + Window, assets::IconName, component::Icon, div, prelude::FluentBuilder as _, px, relative, }; -use super::{Palette, Yumush, chat::Chat, clickable, notify_error, text}; +use super::{Palette, Tooltip as _, Yumush, chat::Chat, clickable, notify_error, text}; pub fn voter_count(poll: &Poll) -> usize { poll.options @@ -92,20 +92,14 @@ pub fn poll_card( None => div().id(id), } .relative() - .h(px(30.)) + .h(px(32.)) .px(px(10.)) .flex() .items_center() - .justify_between() .gap(px(8.)) .rounded(px(6.)) .overflow_hidden() - .border_1() - .border_color(if picked { - palette.accent - } else { - palette.border - }) + .bg(palette.field) .child( div() .absolute() @@ -113,28 +107,43 @@ pub fn poll_card( .top_0() .h_full() .w(relative(share as f32 / 100.)) - .bg(palette.accent.opacity(0.18)), + .bg(palette.accent.opacity(if picked { 0.35 } else { 0.15 })), ) .child( div() + .flex_shrink_0() + .size(px(14.)) .flex() .items_center() - .gap(px(6.)) + .justify_center() + .rounded_full() + .border_1() + .border_color(if picked { + palette.accent + } else { + palette.muted + }) + .when(picked, |marker| { + marker + .bg(palette.accent) + .text_color(palette.on_accent) + .child(Icon::new(IconName::Check).w(px(10.)).h(px(10.))) + }), + ) + .child( + div() + .flex_1() .min_w_0() - .children(picked.then(|| { - div() - .flex_shrink_0() - .text_color(palette.accent) - .child(Icon::new(IconName::Check).w(px(12.)).h(px(12.))) - })) - .child(div().min_w_0().truncate().child(option.text.clone())), + .truncate() + .child(option.text.clone()), ) .child( div() .flex_shrink_0() .text_size(text(12.)) - .text_color(palette.muted) - .child(format!("{count} ยท {share}%")), + .font_weight(FontWeight::SEMIBOLD) + .text_color(if picked { palette.text } else { palette.muted }) + .child(format!("{share}%")), ) }); @@ -145,49 +154,56 @@ pub fn poll_card( .text_size(text(12.)) .text_color(palette.muted) .child(match voters { - 1 => "1 voter".to_string(), - _ => format!("{voters} voters"), + 1 => "1 vote".to_string(), + _ => format!("{voters} votes"), }) - .child( - div() - .flex() - .items_center() - .gap(px(8.)) - .children(poll.closed.then_some("Closed")) - .children(close_id.map(|close_id| { - let close_entity = entity.clone(); - clickable( - format!("poll_close_{close_id}"), - palette, - move |window, cx| { - let close_id = close_id.clone(); - close_entity - .update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx)); - }, - ) - .px(px(6.)) - .py(px(2.)) - .rounded(px(6.)) - .border_1() - .border_color(palette.border) - .child("Close") - })), - ); + .children(poll.closed.then_some("Closed")) + .children(close_id.map(|close_id| { + let close_entity = entity.clone(); + clickable( + format!("poll_close_{close_id}"), + palette, + move |window, cx| { + let close_id = close_id.clone(); + close_entity.update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx)); + }, + ) + .tip("End poll") + .size(px(22.)) + .flex() + .items_center() + .justify_center() + .rounded(px(6.)) + .child(Icon::new(IconName::CircleStop).w(px(13.)).h(px(13.))) + })); div() .flex() .flex_col() .gap(px(6.)) - .p(px(10.)) - .max_w(px(420.)) - .rounded(px(8.)) - .border_1() - .border_color(palette.border) + .p(px(12.)) + .w(px(320.)) + .max_w_full() + .rounded(px(10.)) .bg(palette.panel) .child( div() - .font_weight(FontWeight::SEMIBOLD) - .child(poll.question.clone()), + .flex() + .items_center() + .gap(px(8.)) + .mb(px(2.)) + .child( + div() + .flex_shrink_0() + .text_color(palette.accent) + .child(Icon::new(IconName::ChartBar).w(px(14.)).h(px(14.))), + ) + .child( + div() + .min_w_0() + .font_weight(FontWeight::SEMIBOLD) + .child(poll.question.clone()), + ), ) .children(rows) .child(footer)