diff --git a/crates/app/src/story_workspace.rs b/crates/app/src/story_workspace.rs index 72e26cbd..49a419fe 100644 --- a/crates/app/src/story_workspace.rs +++ b/crates/app/src/story_workspace.rs @@ -278,11 +278,13 @@ impl Render for StoryWorkspace { .gap_2() .child( Button::new("theme-mode", cx) - .when_else( - cx.theme().mode.is_dark(), - |this| this.icon(IconName::Moon), - |this| this.icon(IconName::Sun), - ) + .map(|this| { + if cx.theme().mode.is_dark() { + this.icon(IconName::Sun) + } else { + this.icon(IconName::Moon) + } + }) .size(Size::Small) .style(ButtonStyle::Ghost) .on_click(move |_, cx| { diff --git a/crates/ui/src/input/otp_input.rs b/crates/ui/src/input/otp_input.rs index 6f4f59cf..996c3af0 100644 --- a/crates/ui/src/input/otp_input.rs +++ b/crates/ui/src/input/otp_input.rs @@ -1,7 +1,7 @@ use gpui::{ - div, prelude::FluentBuilder as _, AnyElement, Context, EventEmitter, FocusHandle, - FocusableView, InteractiveElement, IntoElement, KeyDownEvent, Model, MouseButton, - MouseDownEvent, ParentElement as _, Render, SharedString, Styled as _, ViewContext, + div, prelude::FluentBuilder, AnyElement, Context, EventEmitter, FocusHandle, FocusableView, + InteractiveElement, IntoElement, KeyDownEvent, Model, MouseButton, MouseDownEvent, + ParentElement as _, Render, SharedString, Styled as _, ViewContext, }; use crate::{h_flex, theme::ActiveTheme, v_flex}; @@ -174,27 +174,22 @@ impl Render for OtpInput { .h_8() .text_lg() .on_mouse_down(MouseButton::Left, cx.listener(Self::on_input_mouse_down)) - .when_some_else( - c, - |this, c| { - this.child(if self.masked { - SharedString::from("•") - } else { - SharedString::from(c.to_string()) - }) - }, - |this| { - this.when(is_input_focused && blink_show, |this| { - this.child( - div() - .h_4() - .w_0() - .border_l_3() - .border_color(crate::blue_500()), - ) - }) - }, - ) + .map(|this| match c { + Some(c) => this.child(if self.masked { + SharedString::from("•") + } else { + SharedString::from(c.to_string()) + }), + None => this.when(is_input_focused && blink_show, |this| { + this.child( + div() + .h_4() + .w_0() + .border_l_3() + .border_color(crate::blue_500()), + ) + }), + }) .into_any_element(), ); } diff --git a/crates/ui/src/svg_img.rs b/crates/ui/src/svg_img.rs index e3cf8cb3..64a1837b 100644 --- a/crates/ui/src/svg_img.rs +++ b/crates/ui/src/svg_img.rs @@ -5,6 +5,8 @@ use gpui::{ Interactivity, IntoElement, IsZero, Pixels, SharedString, Size, StyleRefinement, Styled, WindowContext, }; +use image::Frame; +use smallvec::SmallVec; use image::ImageBuffer; @@ -124,7 +126,10 @@ impl Asset for Image { pixel.swap(0, 2); } - Ok(Arc::new(ImageData::new(buffer))) + Ok(Arc::new(ImageData::new(SmallVec::from_elem( + Frame::new(buffer), + 1, + )))) } } } @@ -257,7 +262,7 @@ impl Element for SvgImg { origin: new_origin, }; - match cx.paint_image(img_bounds, px(0.).into(), data, false) { + match cx.paint_image(img_bounds, px(0.).into(), data, 0, false) { Ok(_) => {} Err(err) => eprintln!("failed to paint svg image: {:?}", err), }