rumtk_web/components/app/
app_footer.rs1use crate::components::buttons::goto_button::{goto_button, GotoButton};
22use crate::components::html::{footer, Footer};
23use crate::components::socials::{socials, Socials};
24use crate::utils::types::{SharedAppState, URLParams, URLPath};
25use crate::{rumtk_web_get_config, rumtk_web_params_map, ComponentResult, RUMWebTemplate, RUMWebTemplateSafe, PARAMS_ID, PARAMS_TARGET, PARAMS_TITLE};
26use rumtk_core::strings::RUMString;
27
28#[derive(RUMWebTemplate, Debug, Clone)]
29#[template(
30 source = "
31 <p class='f16'>
32 {{company}} © {{copyright}}
33 </p>
34 {% if !disable_contact_button %}
35 {{button|safe}}
36 {% endif %}
37 {{socials|safe}}
38 ",
39 ext = "html"
40)]
41pub struct FooterContents {
42 company: RUMString,
43 copyright: RUMString,
44 button: GotoButton,
45 socials: Socials,
46 disable_contact_button: bool
47}
48
49impl RUMWebTemplateSafe for FooterContents {}
50
51#[derive(RUMWebTemplate, Debug, Clone)]
52#[template(
53 source = "
54 {{footer}}
55 ",
56 ext = "html"
57)]
58pub struct AppFooter {
59 footer: Footer<FooterContents>
60}
61
62impl RUMWebTemplateSafe for AppFooter {}
63
64pub fn app_footer<'a>(_path_components: URLPath<'a, 'a>, params: URLParams<'a>, state: SharedAppState) -> ComponentResult<AppFooter> {
65 let company = rumtk_web_get_config!(state).company.clone();
66 let copyright = rumtk_web_get_config!(state).copyright.clone();
67
68 let disable_contact_button = rumtk_web_get_config!(state).footer_conf.disable_contact_button;
69
70 let contact_button_params = rumtk_web_params_map!([
71 (PARAMS_ID, "contact_button"),
72 (PARAMS_TITLE, "Contact"),
73 (PARAMS_TARGET, "./contact")
74 ]);
75 let contact_button = goto_button(
76 _path_components,
77 contact_button_params.get_inner(),
78 state.clone()
79 )?;
80
81 let socials = socials(_path_components, params, state.clone())?;
82
83 let footer_contents = FooterContents {
84 company,
85 copyright,
86 button: contact_button,
87 socials,
88 disable_contact_button
89 };
90
91 let app_footer = footer(
92 footer_contents,
93 params,
94 state
95 )?;
96
97 Ok(AppFooter {
98 footer: app_footer,
99 })
100}