forge
Explore
Log in

Don't you dare go Hollow

b2c96e7d80a4cfe4c98b801a081fdcad4021748aAhmet Kaan GümüşParent: ff2ed3d
  • ui
    • cleaner poll card
Show full message
💄 ui: cleaner poll card
crates/client/src/gui/poll.rsmodified+71 -55
@@ -3,10 +3,10 @@ use std::collections::HashSet;
33 use common::model::{Message, Poll, Rank, User};
44 use gpui_kit::{
55 Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement, Styled,
6- Window, assets::IconName, component::Icon, div, px, relative,
6+ Window, assets::IconName, component::Icon, div, prelude::FluentBuilder as _, px, relative,
77 };
88
9-use super::{Palette, Yumush, chat::Chat, clickable, notify_error, text};
9+use super::{Palette, Tooltip as _, Yumush, chat::Chat, clickable, notify_error, text};
1010
1111 pub fn voter_count(poll: &Poll) -> usize {
1212 poll.options
@@ -92,20 +92,14 @@ pub fn poll_card(
9292 None => div().id(id),
9393 }
9494 .relative()
95- .h(px(30.))
95+ .h(px(32.))
9696 .px(px(10.))
9797 .flex()
9898 .items_center()
99- .justify_between()
10099 .gap(px(8.))
101100 .rounded(px(6.))
102101 .overflow_hidden()
103- .border_1()
104- .border_color(if picked {
105- palette.accent
106- } else {
107- palette.border
108- })
102+ .bg(palette.field)
109103 .child(
110104 div()
111105 .absolute()
@@ -113,28 +107,43 @@ pub fn poll_card(
113107 .top_0()
114108 .h_full()
115109 .w(relative(share as f32 / 100.))
116- .bg(palette.accent.opacity(0.18)),
110+ .bg(palette.accent.opacity(if picked { 0.35 } else { 0.15 })),
117111 )
118112 .child(
119113 div()
114+ .flex_shrink_0()
115+ .size(px(14.))
120116 .flex()
121117 .items_center()
122- .gap(px(6.))
118+ .justify_center()
119+ .rounded_full()
120+ .border_1()
121+ .border_color(if picked {
122+ palette.accent
123+ } else {
124+ palette.muted
125+ })
126+ .when(picked, |marker| {
127+ marker
128+ .bg(palette.accent)
129+ .text_color(palette.on_accent)
130+ .child(Icon::new(IconName::Check).w(px(10.)).h(px(10.)))
131+ }),
132+ )
133+ .child(
134+ div()
135+ .flex_1()
123136 .min_w_0()
124- .children(picked.then(|| {
125- div()
126- .flex_shrink_0()
127- .text_color(palette.accent)
128- .child(Icon::new(IconName::Check).w(px(12.)).h(px(12.)))
129- }))
130- .child(div().min_w_0().truncate().child(option.text.clone())),
137+ .truncate()
138+ .child(option.text.clone()),
131139 )
132140 .child(
133141 div()
134142 .flex_shrink_0()
135143 .text_size(text(12.))
136- .text_color(palette.muted)
137- .child(format!("{count} · {share}%")),
144+ .font_weight(FontWeight::SEMIBOLD)
145+ .text_color(if picked { palette.text } else { palette.muted })
146+ .child(format!("{share}%")),
138147 )
139148 });
140149
@@ -145,49 +154,56 @@ pub fn poll_card(
145154 .text_size(text(12.))
146155 .text_color(palette.muted)
147156 .child(match voters {
148- 1 => "1 voter".to_string(),
149- _ => format!("{voters} voters"),
157+ 1 => "1 vote".to_string(),
158+ _ => format!("{voters} votes"),
150159 })
151- .child(
152- div()
153- .flex()
154- .items_center()
155- .gap(px(8.))
156- .children(poll.closed.then_some("Closed"))
157- .children(close_id.map(|close_id| {
158- let close_entity = entity.clone();
159- clickable(
160- format!("poll_close_{close_id}"),
161- palette,
162- move |window, cx| {
163- let close_id = close_id.clone();
164- close_entity
165- .update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx));
166- },
167- )
168- .px(px(6.))
169- .py(px(2.))
170- .rounded(px(6.))
171- .border_1()
172- .border_color(palette.border)
173- .child("Close")
174- })),
175- );
160+ .children(poll.closed.then_some("Closed"))
161+ .children(close_id.map(|close_id| {
162+ let close_entity = entity.clone();
163+ clickable(
164+ format!("poll_close_{close_id}"),
165+ palette,
166+ move |window, cx| {
167+ let close_id = close_id.clone();
168+ close_entity.update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx));
169+ },
170+ )
171+ .tip("End poll")
172+ .size(px(22.))
173+ .flex()
174+ .items_center()
175+ .justify_center()
176+ .rounded(px(6.))
177+ .child(Icon::new(IconName::CircleStop).w(px(13.)).h(px(13.)))
178+ }));
176179
177180 div()
178181 .flex()
179182 .flex_col()
180183 .gap(px(6.))
181- .p(px(10.))
182- .max_w(px(420.))
183- .rounded(px(8.))
184- .border_1()
185- .border_color(palette.border)
184+ .p(px(12.))
185+ .w(px(320.))
186+ .max_w_full()
187+ .rounded(px(10.))
186188 .bg(palette.panel)
187189 .child(
188190 div()
189- .font_weight(FontWeight::SEMIBOLD)
190- .child(poll.question.clone()),
191+ .flex()
192+ .items_center()
193+ .gap(px(8.))
194+ .mb(px(2.))
195+ .child(
196+ div()
197+ .flex_shrink_0()
198+ .text_color(palette.accent)
199+ .child(Icon::new(IconName::ChartBar).w(px(14.)).h(px(14.))),
200+ )
201+ .child(
202+ div()
203+ .min_w_0()
204+ .font_weight(FontWeight::SEMIBOLD)
205+ .child(poll.question.clone()),
206+ ),
191207 )
192208 .children(rows)
193209 .child(footer)