feat(indicator): Update icon type (#280)

This commit is contained in:
Floyd Wang 2024-09-27 11:58:14 +08:00 committed by GitHub
parent e1bf3556a9
commit 708e373ab6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,13 +3,13 @@ use std::time::Duration;
use crate::{Icon, IconName, Sizable, Size};
use gpui::{
div, ease_in_out, percentage, prelude::FluentBuilder as _, Animation, AnimationExt as _, Hsla,
IntoElement, ParentElement, RenderOnce, Styled as _, Transformation,
IntoElement, ParentElement, RenderOnce, Styled as _, Transformation, WindowContext,
};
#[derive(IntoElement)]
pub struct Indicator {
size: Size,
icon: IconName,
icon: Icon,
speed: Duration,
color: Option<Hsla>,
}
@ -19,13 +19,13 @@ impl Indicator {
Self {
size: Size::Medium,
speed: Duration::from_secs_f64(0.8),
icon: IconName::Loader,
icon: Icon::new(IconName::Loader),
color: None,
}
}
pub fn icon(mut self, icon: IconName) -> Self {
self.icon = icon;
pub fn icon(mut self, icon: impl Into<Icon>) -> Self {
self.icon = icon.into();
self
}
@ -43,10 +43,10 @@ impl Sizable for Indicator {
}
impl RenderOnce for Indicator {
fn render(self, _: &mut gpui::WindowContext) -> impl IntoElement {
fn render(self, _: &mut WindowContext) -> impl IntoElement {
div()
.child(
Icon::new(self.icon.clone())
self.icon
.with_size(self.size)
.when_some(self.color, |this, color| this.text_color(color))
.with_animation(