Progress use positioning layout

This commit is contained in:
Floyd Wang 2024-07-12 18:25:09 +08:00
parent 7c99584862
commit 138fc9c7b5
2 changed files with 13 additions and 20 deletions

View file

@ -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,

View file

@ -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)),
}),
)
}
}