use serde::{Deserialize, Serialize};
use crate::extras::button::Button;
use crate::extras::icon::Icon;
use crate::node::{Common, IntoNode, Node};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Empty {
#[serde(flatten)]
pub common: Common,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub icon: Option<Icon>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub action: Option<Box<Node>>,
}
impl Empty {
#[must_use]
pub fn new() -> Self {
Self {
common: Common::new(),
title: None,
message: None,
icon: None,
action: None,
}
}
#[must_use]
pub fn title(mut self, title: impl Into<String>) -> Self {
self.title = Some(title.into());
self
}
#[must_use]
pub fn message(mut self, message: impl Into<String>) -> Self {
self.message = Some(message.into());
self
}
#[must_use]
pub fn icon(mut self, icon: Icon) -> Self {
self.icon = Some(icon);
self
}
#[must_use]
pub fn action(mut self, action: Button) -> Self {
self.action = Some(Box::new(Node::Button(action)));
self
}
}
impl Default for Empty {
fn default() -> Self {
Self::new()
}
}
impl IntoNode for Empty {}
impl From<Empty> for Node {
fn from(e: Empty) -> Self {
Node::Empty(e)
}
}