| 1 | use std::time::Duration; |
| 2 | |
| 3 | use gpui_kit::component::Icon; |
| 4 | use gpui_kit::*; |
| 5 | |
| 6 | use app_base::theme; |
| 7 | |
| 8 | const SPIN_PERIOD: Duration = Duration::from_millis(900); |
| 9 | |
| 10 | pub fn spinner(size: f32) -> Div { |
| 11 | let layer = |name: &str, color: Hsla| { |
| 12 | Icon::empty() |
| 13 | .path(format!("symbols/{name}.svg")) |
| 14 | .size(px(size)) |
| 15 | .text_color(color) |
| 16 | }; |
| 17 | div() |
| 18 | .relative() |
| 19 | .size(px(size)) |
| 20 | .flex_none() |
| 21 | .child(layer("spinner_track", theme::popup_hover())) |
| 22 | .child(div().absolute().top_0().left_0().child( |
| 23 | layer("spinner_arc", theme::accent()).with_animation( |
| 24 | "agent-spinner", |
| 25 | Animation::new(SPIN_PERIOD).repeat(), |
| 26 | |arc, progress| arc.rotate(percentage(progress)), |
| 27 | ), |
| 28 | )) |
| 29 | } |