project_panel: Fix validation error style alignment (#28214)

Use px over rem for positioning as rem is dependent on font
size.

Release Notes:

- N/A
This commit is contained in:
Smit Barmase 2025-04-07 17:03:21 +05:30 committed by GitHub
parent d6d9c383cb
commit 3b46fca64c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,7 +22,7 @@ use gpui::{
Hsla, InteractiveElement, KeyContext, ListHorizontalSizingBehavior, ListSizingBehavior, Hsla, InteractiveElement, KeyContext, ListHorizontalSizingBehavior, ListSizingBehavior,
MouseButton, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, Render, ScrollStrategy, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, Render, ScrollStrategy,
Stateful, Styled, Subscription, Task, UniformListScrollHandle, WeakEntity, Window, actions, Stateful, Styled, Subscription, Task, UniformListScrollHandle, WeakEntity, Window, actions,
anchored, deferred, div, impl_actions, point, px, size, transparent_black, uniform_list, anchored, deferred, div, impl_actions, point, px, size, uniform_list,
}; };
use indexmap::IndexMap; use indexmap::IndexMap;
use language::DiagnosticSeverity; use language::DiagnosticSeverity;
@ -4178,36 +4178,29 @@ impl ProjectPanel {
.overflow_x(), .overflow_x(),
) )
.when( .when(
validation_error, |this| {
validation_error, |el| { this
el
.relative() .relative()
.child( .child(
deferred( deferred(
// Wizardry of highest order to make error border align with entry border div()
div() .occlude()
.occlude() .absolute()
.absolute() .top_full()
.top_full() .left(px(-1.)) // Used px over rem so that it doesn't change with font size
.left_neg_0p5() .right(px(-0.5))
.right_neg_1() .py_1()
.border_x_1() .px_2()
.border_color(transparent_black()) .border_1()
.child( .border_color(Color::Error.color(cx))
div() .bg(cx.theme().colors().background)
.py_1() .child(
.px_2() Label::new(format!("{} already exists", self.filename_editor.read(cx).text(cx)))
.border_1() .color(Color::Error)
.border_color(Color::Error.color(cx)) .size(LabelSize::Small)
.bg(cx.theme().colors().background) .truncate()
.child(
Label::new(format!("{} already exists", self.filename_editor.read(cx).text(cx)))
.color(Color::Error)
.size(LabelSize::Small)
)
)
) )
)
) )
} }
) )