#[allow(dead_code)]
pub(crate) trait IntoHTMLElement {
fn html_element(&self) -> Option<HTMLElement>;
}
impl IntoHTMLElement for () {
fn html_element(&self) -> Option<HTMLElement> {
None
}
}
impl IntoHTMLElement for HTMLElement {
fn html_element(&self) -> Option<HTMLElement> {
Some(self.clone())
}
}
#[derive(Debug, Clone)]
pub struct HTMLElement {
html: String,
}
impl HTMLElement {
pub fn new(html: &str) -> HTMLElement {
Self {
html: html.to_string(),
}
}
pub fn html(&self) -> &str {
&self.html
}
}
pub trait OptionalExtraHTMLData {
fn extra_html_data(&self) -> Option<ExtraHTMLData>;
}
impl OptionalExtraHTMLData for () {
fn extra_html_data(&self) -> Option<ExtraHTMLData> {
None
}
}
impl OptionalExtraHTMLData for ExtraHTMLData {
fn extra_html_data(&self) -> Option<ExtraHTMLData> {
Some(self.clone())
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum CustomHtmlElementTag {
#[default]
Div,
Button,
}
impl CustomHtmlElementTag {
pub const fn as_json_str(self) -> &'static str {
match self {
Self::Div => "div",
Self::Button => "button",
}
}
}
#[derive(Clone, Debug, Default)]
pub struct ExtraHTMLData {
pub tag: CustomHtmlElementTag,
pub extra_style: Option<String>,
}