use crate::utils::defaults::{PARAMS_SIZE, SECTION_DEFAULT};
use crate::utils::types::{HTMLResult, SharedAppState, URLParams, URLPath};
use crate::{
rumtk_web_get_config, rumtk_web_get_text_item, rumtk_web_render_html, RUMWebTemplate,
};
#[derive(RUMWebTemplate, Debug)]
#[template(
source = "
{% if custom_css_enabled %}
<link href='/static/components/spacer.css' rel='stylesheet'>
{% endif %}
<div style='padding-bottom: {{size}}0px'></div>
",
ext = "html"
)]
pub struct Spacer {
size: usize,
custom_css_enabled: bool,
}
pub fn spacer(_path_components: URLPath, params: URLParams, state: SharedAppState) -> HTMLResult {
let size = rumtk_web_get_text_item!(params, PARAMS_SIZE, SECTION_DEFAULT)
.parse::<usize>()
.unwrap_or(0);
let custom_css_enabled = rumtk_web_get_config!(state).custom_css;
rumtk_web_render_html!(Spacer {
size,
custom_css_enabled
})
}