tabs: Remove underline variant TabBar paddings. (#1126)
<img width="1167" height="1044" alt="image" src="https://github.com/user-attachments/assets/0a2b34b7-5629-402b-a54a-f975aab77e78" />
This commit is contained in:
parent
85e2a72d03
commit
b1f4a4f642
2 changed files with 10 additions and 12 deletions
|
|
@ -100,7 +100,7 @@ impl TabVariant {
|
|||
};
|
||||
|
||||
if matches!(self, TabVariant::Underline) {
|
||||
padding_x = padding_x / 2.;
|
||||
padding_x = px(0.);
|
||||
}
|
||||
|
||||
Edges {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub struct SelectTab(usize);
|
|||
#[derive(IntoElement)]
|
||||
pub struct TabBar {
|
||||
base: Stateful<Div>,
|
||||
style: StyleRefinement,
|
||||
scroll_handle: Option<ScrollHandle>,
|
||||
prefix: Option<AnyElement>,
|
||||
suffix: Option<AnyElement>,
|
||||
|
|
@ -40,6 +41,7 @@ impl TabBar {
|
|||
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||
Self {
|
||||
base: div().id(id).px(px(-1.)),
|
||||
style: StyleRefinement::default(),
|
||||
children: SmallVec::new(),
|
||||
scroll_handle: None,
|
||||
prefix: None,
|
||||
|
|
@ -149,7 +151,7 @@ impl TabBar {
|
|||
|
||||
impl Styled for TabBar {
|
||||
fn style(&mut self) -> &mut StyleRefinement {
|
||||
self.base.style()
|
||||
&mut self.style
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -198,18 +200,13 @@ impl RenderOnce for TabBar {
|
|||
TabVariant::Underline => {
|
||||
// This gap is same as the tab inner_paddings
|
||||
let gap = match self.size {
|
||||
Size::XSmall => px(8.),
|
||||
Size::Small => px(10.),
|
||||
Size::Large => px(16.),
|
||||
_ => px(12.),
|
||||
Size::XSmall => px(10.),
|
||||
Size::Small => px(12.),
|
||||
Size::Large => px(20.),
|
||||
_ => px(16.),
|
||||
};
|
||||
|
||||
let padding = Edges {
|
||||
left: gap,
|
||||
right: gap,
|
||||
..Default::default()
|
||||
};
|
||||
(cx.theme().transparent, padding, gap)
|
||||
(cx.theme().transparent, Edges::all(px(0.)), gap)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -251,6 +248,7 @@ impl RenderOnce for TabBar {
|
|||
|this| this.rounded(cx.theme().radius),
|
||||
)
|
||||
.paddings(paddings)
|
||||
.refine_style(&self.style)
|
||||
.when_some(self.prefix, |this, prefix| this.child(prefix))
|
||||
.child(
|
||||
h_flex()
|
||||
|
|
|
|||
Loading…
Reference in a new issue