Style empty project diagnostics state

This commit is contained in:
Antonio Scandurra 2022-01-27 10:21:26 +01:00
parent adf00fafdf
commit 4d9cdd474b
2 changed files with 47 additions and 43 deletions

View file

@ -103,7 +103,7 @@ impl View for ProjectDiagnosticsEditor {
if self.path_states.is_empty() { if self.path_states.is_empty() {
let theme = &self.settings.borrow().theme.project_diagnostics; let theme = &self.settings.borrow().theme.project_diagnostics;
Label::new( Label::new(
"No problems detected in the project".to_string(), "No problems in workspace".to_string(),
theme.empty_message.clone(), theme.empty_message.clone(),
) )
.aligned() .aligned()
@ -770,48 +770,52 @@ pub(crate) fn render_summary(
text_style: &TextStyle, text_style: &TextStyle,
theme: &theme::ProjectDiagnostics, theme: &theme::ProjectDiagnostics,
) -> ElementBox { ) -> ElementBox {
let icon_width = theme.tab_icon_width; if summary.error_count == 0 && summary.warning_count == 0 {
let icon_spacing = theme.tab_icon_spacing; Label::new("No problems".to_string(), text_style.clone()).boxed()
let summary_spacing = theme.tab_summary_spacing; } else {
Flex::row() let icon_width = theme.tab_icon_width;
.with_children([ let icon_spacing = theme.tab_icon_spacing;
Svg::new("icons/diagnostic-summary-error.svg") let summary_spacing = theme.tab_summary_spacing;
.with_color(text_style.color) Flex::row()
.constrained() .with_children([
.with_width(icon_width) Svg::new("icons/diagnostic-summary-error.svg")
.with_color(text_style.color)
.constrained()
.with_width(icon_width)
.aligned()
.contained()
.with_margin_right(icon_spacing)
.named("no-icon"),
Label::new(
summary.error_count.to_string(),
LabelStyle {
text: text_style.clone(),
highlight_text: None,
},
)
.aligned() .aligned()
.contained() .boxed(),
.with_margin_right(icon_spacing) Svg::new("icons/diagnostic-summary-warning.svg")
.named("no-icon"), .with_color(text_style.color)
Label::new( .constrained()
summary.error_count.to_string(), .with_width(icon_width)
LabelStyle { .aligned()
text: text_style.clone(), .contained()
highlight_text: None, .with_margin_left(summary_spacing)
}, .with_margin_right(icon_spacing)
) .named("warn-icon"),
.aligned() Label::new(
.boxed(), summary.warning_count.to_string(),
Svg::new("icons/diagnostic-summary-warning.svg") LabelStyle {
.with_color(text_style.color) text: text_style.clone(),
.constrained() highlight_text: None,
.with_width(icon_width) },
)
.aligned() .aligned()
.contained() .boxed(),
.with_margin_left(summary_spacing) ])
.with_margin_right(icon_spacing) .boxed()
.named("warn-icon"), }
Label::new(
summary.warning_count.to_string(),
LabelStyle {
text: text_style.clone(),
highlight_text: None,
},
)
.aligned()
.boxed(),
])
.boxed()
} }
fn compare_diagnostics<L: language::ToOffset, R: language::ToOffset>( fn compare_diagnostics<L: language::ToOffset, R: language::ToOffset>(

View file

@ -185,7 +185,7 @@ corner_radius = 6
[project_panel] [project_panel]
extends = "$panel" extends = "$panel"
padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2 padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2
[project_panel.entry] [project_panel.entry]
text = "$text.1" text = "$text.1"
@ -313,7 +313,7 @@ message.highlight_text.color = "$text.3.color"
[project_diagnostics] [project_diagnostics]
background = "$surface.1" background = "$surface.1"
empty_message = "$text.0" empty_message = { extends = "$text.0", size = 18 }
status_bar_item = { extends = "$text.2", margin.right = 10 } status_bar_item = { extends = "$text.2", margin.right = 10 }
tab_icon_width = 13 tab_icon_width = 13
tab_icon_spacing = 4 tab_icon_spacing = 4