use crate::utils::defaults::{PARAMS_SIZE, SECTION_DEFAULT};
use crate::utils::types::{SharedAppState, URLParams, URLPath};
use crate::{rumtk_web_get_config, rumtk_web_get_text_item, ComponentResult, 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) -> ComponentResult<Spacer> {
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).flags.custom_css;
Ok(Spacer {
size,
custom_css_enabled
})
}