From 138fc9c7b5dfde633427bc4174e7c5c7a062d6c9 Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Fri, 12 Jul 2024 18:25:09 +0800 Subject: [PATCH] Progress use positioning layout --- crates/app/src/story_workspace.rs | 2 +- crates/ui/src/progress.rs | 31 ++++++++++++------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/crates/app/src/story_workspace.rs b/crates/app/src/story_workspace.rs index f1e87b85..c70eb4bf 100644 --- a/crates/app/src/story_workspace.rs +++ b/crates/app/src/story_workspace.rs @@ -131,7 +131,7 @@ impl StoryWorkspace { StoryContainer::add_pane( "Table", - "Powerful table and datagrids built using TanStack Table.", + "Powerful table and datagrids built.", TableStory::view(cx).into(), workspace.clone(), cx, diff --git a/crates/ui/src/progress.rs b/crates/ui/src/progress.rs index 43729c52..46df9c6b 100644 --- a/crates/ui/src/progress.rs +++ b/crates/ui/src/progress.rs @@ -3,10 +3,7 @@ use gpui::{ WindowContext, }; -use crate::{ - h_flex, - theme::{ActiveTheme, Colorize}, -}; +use crate::theme::{ActiveTheme, Colorize}; #[derive(IntoElement)] pub struct Progress { @@ -37,27 +34,23 @@ impl RenderOnce for Progress { v => v / 100., }); - h_flex() + div() + .relative() .h(px(self.height)) + .rounded(rounded) + .bg(cx.theme().progress_bar.opacity(0.2)) .child( div() + .absolute() + .top_0() + .left_0() + .h_full() + .w(relative_w) + .bg(cx.theme().progress_bar) .map(|this| match self.value { v if v >= 100. => this.rounded(rounded), _ => this.rounded_l(rounded), - }) - .h_full() - .w(relative_w) - .bg(cx.theme().progress_bar), - ) - .child( - div() - .map(|this| match self.value { - v if v <= 0. => this.rounded(rounded), - _ => this.rounded_r(rounded), - }) - .h_full() - .flex_1() - .bg(cx.theme().progress_bar.opacity(0.2)), + }), ) } }