use egui::{RichText, Ui};
use crate::styles::typography;
use crate::tokens::DESIGN_TOKENS;
pub struct EmptyState<'a> {
message: &'a str,
description: Option<&'a str>,
}
impl<'a> EmptyState<'a> {
pub fn new(message: &'a str) -> Self {
Self {
message,
description: None,
}
}
#[must_use]
pub fn description(mut self, desc: &'a str) -> Self {
self.description = Some(desc);
self
}
pub fn show(self, ui: &mut Ui) {
ui.vertical_centered(|ui| {
ui.add_space(DESIGN_TOKENS.spacing.xl);
ui.label(
RichText::new(self.message)
.size(typography::MD)
.color(ui.visuals().weak_text_color()),
);
if let Some(desc) = self.description {
ui.add_space(DESIGN_TOKENS.spacing.sm);
ui.label(
RichText::new(desc)
.size(typography::SM)
.color(ui.visuals().weak_text_color()),
);
}
ui.add_space(DESIGN_TOKENS.spacing.xl);
});
}
}