chore: audit components
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
use std::cell::Cell;
|
||||
use std::f32::consts::{PI, TAU};
|
||||
use std::rc::Rc;
|
||||
use std::time::Duration;
|
||||
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
@@ -13,12 +12,10 @@ use gpui::{
|
||||
Window, canvas, div, percentage, point, px,
|
||||
};
|
||||
use gpui_native_icons::{Icon, IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
use gpui_native_theme::{ActiveTheme as _, SPINNER_PERIOD, Size};
|
||||
|
||||
use crate::common::Sizable;
|
||||
|
||||
/// One revolution takes this long, the system loaders' cadence.
|
||||
const SPIN_PERIOD: Duration = Duration::from_millis(800);
|
||||
/// The share of the circle the spinning arc paints.
|
||||
const SPIN_SWEEP: f32 = 0.75;
|
||||
/// The ring stroke as a share of the side.
|
||||
@@ -36,6 +33,7 @@ pub enum SpinnerVariant {
|
||||
|
||||
/// A loading ring.
|
||||
#[derive(IntoElement)]
|
||||
#[must_use]
|
||||
pub struct Spinner {
|
||||
id: ElementId,
|
||||
value: Option<f32>,
|
||||
@@ -178,7 +176,7 @@ fn spinning_ring(side: Pixels, stroke: Pixels, accent: Hsla) -> AnimationElement
|
||||
.size(side)
|
||||
.with_animation(
|
||||
"spin",
|
||||
Animation::new(SPIN_PERIOD).repeat().with_max_fps(60.),
|
||||
Animation::new(SPINNER_PERIOD).repeat().with_max_fps(60.),
|
||||
move |ring, delta| {
|
||||
angle.set(delta * TAU);
|
||||
ring
|
||||
@@ -192,7 +190,7 @@ fn spinning_icon(side: Pixels, accent: Hsla) -> AnimationElement<Icon> {
|
||||
.color(accent)
|
||||
.with_animation(
|
||||
"spin",
|
||||
Animation::new(SPIN_PERIOD).repeat().with_max_fps(60.),
|
||||
Animation::new(SPINNER_PERIOD).repeat().with_max_fps(60.),
|
||||
|glyph, delta| glyph.with_transformation(Transformation::rotate(percentage(delta))),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user