forge
Explore
Log in

Don't you dare go Hollow

Login server toggle shows only the host

Browse files at this commit

05309cdb692ffdf629ba8deda2edef883c84dd29Ahmet Kaan GümüşParent: 9b5b78c
  • style
    • login server toggle shows only the host
    • chevron turns and server fields slide in
Show full message
💄 style: login server toggle shows only the host; chevron turns and server fields slide in
crates/client/src/gui/auth.rsmodified+29 -8
@@ -1,6 +1,6 @@
11 use gpui_kit::prelude::FluentBuilder as _;
22 use gpui_kit::{
3- AnyElement, Context, Div, Entity, FontWeight, IntoElement, ParentElement,
3+ AnimationExt as _, AnyElement, Context, Div, Entity, FontWeight, IntoElement, ParentElement,
44 StatefulInteractiveElement, Styled, Window,
55 assets::IconName,
66 component::{
@@ -144,17 +144,30 @@ fn server_toggle(
144144 .gap(px(space::XS))
145145 .text_size(text(text::CAPTION))
146146 .text_color(palette.muted)
147- .child(address.to_string())
147+ .child(host(address).to_string())
148148 .child(
149- Icon::new(if open {
150- IconName::ChevronDown
151- } else {
152- IconName::ChevronRight
153- })
154- .size(px(size::ICON_SM)),
149+ Icon::new(IconName::ChevronRight)
150+ .size(px(size::ICON_SM))
151+ .with_animation(
152+ ("server_chevron", open as u64),
153+ super::parts::motion(),
154+ move |icon, delta| {
155+ let turn = if open { delta } else { 1. - delta };
156+ icon.rotate(gpui_kit::radians(std::f32::consts::FRAC_PI_2 * turn))
157+ },
158+ ),
155159 )
156160 }
157161
162+fn host(address: &str) -> &str {
163+ match address.rsplit_once(':') {
164+ Some((host, port)) if port.chars().all(|c| c.is_ascii_digit()) => {
165+ host.trim_start_matches('[').trim_end_matches(']')
166+ }
167+ _ => address,
168+ }
169+}
170+
158171 fn password_field(palette: Palette, input: &Entity<InputState>) -> Div {
159172 frame(palette, Input::new(input).mask_toggle())
160173 }
@@ -237,6 +250,7 @@ impl Yumush {
237250 ))
238251 .child(
239252 div()
253+ .relative()
240254 .when(!self.auth.server_open, |this| this.invisible())
241255 .flex()
242256 .flex_col()
@@ -265,6 +279,13 @@ impl Yumush {
265279 }
266280 },
267281 )),
282+ )
283+ .with_animation(
284+ ("server_fields", self.auth.server_open as u64),
285+ super::parts::motion(),
286+ |fields, delta| {
287+ fields.opacity(delta).top(px(space::SM * (delta - 1.)))
288+ },
268289 ),
269290 ),
270291 )