feat(indicator): Update icon type (#280)
This commit is contained in:
parent
e1bf3556a9
commit
708e373ab6
1 changed files with 7 additions and 7 deletions
|
|
@ -3,13 +3,13 @@ use std::time::Duration;
|
||||||
use crate::{Icon, IconName, Sizable, Size};
|
use crate::{Icon, IconName, Sizable, Size};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, ease_in_out, percentage, prelude::FluentBuilder as _, Animation, AnimationExt as _, Hsla,
|
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)]
|
#[derive(IntoElement)]
|
||||||
pub struct Indicator {
|
pub struct Indicator {
|
||||||
size: Size,
|
size: Size,
|
||||||
icon: IconName,
|
icon: Icon,
|
||||||
speed: Duration,
|
speed: Duration,
|
||||||
color: Option<Hsla>,
|
color: Option<Hsla>,
|
||||||
}
|
}
|
||||||
|
|
@ -19,13 +19,13 @@ impl Indicator {
|
||||||
Self {
|
Self {
|
||||||
size: Size::Medium,
|
size: Size::Medium,
|
||||||
speed: Duration::from_secs_f64(0.8),
|
speed: Duration::from_secs_f64(0.8),
|
||||||
icon: IconName::Loader,
|
icon: Icon::new(IconName::Loader),
|
||||||
color: None,
|
color: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn icon(mut self, icon: IconName) -> Self {
|
pub fn icon(mut self, icon: impl Into<Icon>) -> Self {
|
||||||
self.icon = icon;
|
self.icon = icon.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,10 +43,10 @@ impl Sizable for Indicator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Indicator {
|
impl RenderOnce for Indicator {
|
||||||
fn render(self, _: &mut gpui::WindowContext) -> impl IntoElement {
|
fn render(self, _: &mut WindowContext) -> impl IntoElement {
|
||||||
div()
|
div()
|
||||||
.child(
|
.child(
|
||||||
Icon::new(self.icon.clone())
|
self.icon
|
||||||
.with_size(self.size)
|
.with_size(self.size)
|
||||||
.when_some(self.color, |this, color| this.text_color(color))
|
.when_some(self.color, |this, color| this.text_color(color))
|
||||||
.with_animation(
|
.with_animation(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue