Start re-styling diagnostic indicator in status bar
This commit is contained in:
parent
b23ff7c3ad
commit
9e87be722e
15 changed files with 1245 additions and 354 deletions
|
@ -1,4 +1,3 @@
|
|||
use crate::render_summary;
|
||||
use gpui::{
|
||||
elements::*, platform::CursorStyle, serde_json, Entity, ModelHandle, RenderContext, View,
|
||||
ViewContext,
|
||||
|
@ -50,19 +49,91 @@ impl View for DiagnosticSummary {
|
|||
enum Tag {}
|
||||
|
||||
let in_progress = self.in_progress;
|
||||
MouseEventHandler::new::<Tag, _, _>(0, cx, |_, cx| {
|
||||
let theme = &cx.global::<Settings>().theme.project_diagnostics;
|
||||
if in_progress {
|
||||
Label::new(
|
||||
"Checking... ".to_string(),
|
||||
theme.status_bar_item.text.clone(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.status_bar_item.container)
|
||||
.boxed()
|
||||
MouseEventHandler::new::<Tag, _, _>(0, cx, |state, cx| {
|
||||
let style = &cx
|
||||
.global::<Settings>()
|
||||
.theme
|
||||
.workspace
|
||||
.status_bar
|
||||
.diagnostics;
|
||||
let summary_style = if self.summary.error_count > 0 {
|
||||
if state.hovered {
|
||||
&style.summary_error_hover
|
||||
} else {
|
||||
&style.summary_error
|
||||
}
|
||||
} else if self.summary.warning_count > 0 {
|
||||
if state.hovered {
|
||||
&style.summary_warning_hover
|
||||
} else {
|
||||
&style.summary_warning
|
||||
}
|
||||
} else if state.hovered {
|
||||
&style.summary_ok_hover
|
||||
} else {
|
||||
render_summary(&self.summary, &theme.status_bar_item.text, &theme)
|
||||
&style.summary_ok
|
||||
};
|
||||
|
||||
let mut row = Flex::row();
|
||||
if self.summary.error_count > 0 {
|
||||
row.add_children([
|
||||
Svg::new("icons/error-solid-14.svg")
|
||||
.with_color(style.icon_color_error)
|
||||
.constrained()
|
||||
.with_width(style.icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_right(style.icon_spacing)
|
||||
.named("error-icon"),
|
||||
Label::new(
|
||||
self.summary.error_count.to_string(),
|
||||
summary_style.text.clone(),
|
||||
)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
]);
|
||||
}
|
||||
|
||||
if self.summary.warning_count > 0 {
|
||||
row.add_children([
|
||||
Svg::new("icons/warning-solid-14.svg")
|
||||
.with_color(style.icon_color_warning)
|
||||
.constrained()
|
||||
.with_width(style.icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_right(style.icon_spacing)
|
||||
.with_margin_left(if self.summary.error_count > 0 {
|
||||
style.summary_spacing
|
||||
} else {
|
||||
0.
|
||||
})
|
||||
.named("warning-icon"),
|
||||
Label::new(
|
||||
self.summary.warning_count.to_string(),
|
||||
summary_style.text.clone(),
|
||||
)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
]);
|
||||
}
|
||||
|
||||
if self.summary.error_count == 0 && self.summary.warning_count == 0 {
|
||||
row.add_child(
|
||||
Svg::new("icons/no-error-solid-14.svg")
|
||||
.with_color(style.icon_color_ok)
|
||||
.constrained()
|
||||
.with_width(style.icon_width)
|
||||
.aligned()
|
||||
.named("ok-icon"),
|
||||
);
|
||||
}
|
||||
|
||||
row.constrained()
|
||||
.with_height(style.height)
|
||||
.contained()
|
||||
.with_style(summary_style.container)
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.on_click(|cx| cx.dispatch_action(crate::Deploy))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue