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 @@
1 use gpui_kit::prelude::FluentBuilder as _;1 use gpui_kit::prelude::FluentBuilder as _;
2 use gpui_kit::{2 use gpui_kit::{
3- AnyElement, Context, Div, Entity, FontWeight, IntoElement, ParentElement,3+ AnimationExt as _, AnyElement, Context, Div, Entity, FontWeight, IntoElement, ParentElement,
4 StatefulInteractiveElement, Styled, Window,4 StatefulInteractiveElement, Styled, Window,
5 assets::IconName,5 assets::IconName,
6 component::{6 component::{
@@ -144,17 +144,30 @@ fn server_toggle(
144 .gap(px(space::XS))144 .gap(px(space::XS))
145 .text_size(text(text::CAPTION))145 .text_size(text(text::CAPTION))
146 .text_color(palette.muted)146 .text_color(palette.muted)
147- .child(address.to_string())147+ .child(host(address).to_string())
148 .child(148 .child(
149- Icon::new(if open {149+ Icon::new(IconName::ChevronRight)
150- IconName::ChevronDown150+ .size(px(size::ICON_SM))
151- } else {151+ .with_animation(
152- IconName::ChevronRight152+ ("server_chevron", open as u64),
153- })153+ super::parts::motion(),
154- .size(px(size::ICON_SM)),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+ ),
155 )159 )
156 }160 }
157 161
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+
158 fn password_field(palette: Palette, input: &Entity<InputState>) -> Div {171 fn password_field(palette: Palette, input: &Entity<InputState>) -> Div {
159 frame(palette, Input::new(input).mask_toggle())172 frame(palette, Input::new(input).mask_toggle())
160 }173 }
@@ -237,6 +250,7 @@ impl Yumush {
237 ))250 ))
238 .child(251 .child(
239 div()252 div()
253+ .relative()
240 .when(!self.auth.server_open, |this| this.invisible())254 .when(!self.auth.server_open, |this| this.invisible())
241 .flex()255 .flex()
242 .flex_col()256 .flex_col()
@@ -265,6 +279,13 @@ impl Yumush {
265 }279 }
266 },280 },
267 )),281 )),
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+ },
268 ),289 ),
269 ),290 ),
270 )291 )