Skip to main content

logicaffeine_web/ui/pages/
terms.rs

1//! Terms of service page.
2//!
3//! Renders the terms of service from an embedded HTML file with consistent
4//! legal page styling and navigation.
5//!
6//! # Route
7//!
8//! Accessed via `Route::Terms`.
9
10use crate::ui::components::footer::Footer;
11use crate::ui::components::main_nav::{ActivePage, MainNav};
12use crate::ui::seo::{
13    breadcrumb_schema, organization_schema, pages as seo_pages, webpage_schema, BreadcrumbItem,
14    JsonLdMultiple, PageHead,
15};
16use dioxus::prelude::*;
17
18// Compiled in natively (tests, SSG prerender); wasm fetches the staged /data copy
19// so the ~135 KB of legal prose never rides inside the shipped binary.
20#[cfg(not(target_arch = "wasm32"))]
21const TERMS_HTML: &str = include_str!("../../../terms.html");
22
23const LEGAL_STYLE: &str = r#"
24.legal-container {
25    min-height: 100vh;
26    display: flex;
27    flex-direction: column;
28    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
29}
30
31.legal-content {
32    flex: 1;
33    max-width: 900px;
34    margin: 0 auto;
35    padding: 40px 20px 60px;
36    width: 100%;
37}
38
39.legal-content-inner {
40    background: rgba(255, 255, 255, 0.98);
41    border-radius: 16px;
42    padding: 40px;
43    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
44}
45
46.legal-footer {
47    border-top: 1px solid rgba(255,255,255,0.06);
48    padding: 24px 20px;
49    text-align: center;
50    color: rgba(229,231,235,0.56);
51    font-size: 13px;
52}
53
54.legal-footer a {
55    color: rgba(229,231,235,0.72);
56    text-decoration: none;
57    margin: 0 8px;
58}
59
60.legal-footer a:hover {
61    color: #a78bfa;
62}
63
64.github-link {
65    display: inline-flex;
66    align-items: center;
67    gap: 6px;
68}
69"#;
70
71#[component]
72pub fn Terms() -> Element {
73    let breadcrumbs = vec![
74        BreadcrumbItem {
75            name: "Home",
76            path: "/",
77        },
78        BreadcrumbItem {
79            name: "Terms of Service",
80            path: "/terms",
81        },
82    ];
83    let schemas = vec![
84        organization_schema(),
85        webpage_schema("Terms of Service", "Terms and conditions for using LOGICAFFEINE and its MIT-licensed software.", "/terms"),
86        breadcrumb_schema(&breadcrumbs),
87    ];
88
89    rsx! {
90        PageHead {
91            title: seo_pages::TERMS.title,
92            description: seo_pages::TERMS.description,
93            canonical_path: seo_pages::TERMS.canonical_path,
94        }
95        style { "{LEGAL_STYLE}" }
96        JsonLdMultiple { schemas }
97
98        div { class: "legal-container",
99            MainNav { active: ActivePage::Other, subtitle: Some("Terms of Use") }
100
101            main { class: "legal-content",
102                TermsBody {}
103            }
104
105            Footer {}
106        }
107    }
108}
109
110#[cfg(not(target_arch = "wasm32"))]
111#[component]
112fn TermsBody() -> Element {
113    rsx! {
114        div { class: "legal-content-inner", dangerous_inner_html: "{TERMS_HTML}" }
115    }
116}
117
118#[cfg(target_arch = "wasm32")]
119#[component]
120fn TermsBody() -> Element {
121    let mut body = use_resource(|| crate::ui::data_fetch::fetch_static_text("/data/terms.html"));
122    let state = body.read_unchecked();
123    match &*state {
124        Some(Ok(html)) => rsx! {
125            div { class: "legal-content-inner", dangerous_inner_html: "{html}" }
126        },
127        Some(Err(e)) => rsx! {
128            div { class: "legal-content-inner",
129                p { "The terms of service failed to load: {e}" }
130                button { onclick: move |_| body.restart(), "Retry" }
131            }
132        },
133        None => rsx! {
134            div { class: "legal-content-inner", p { "Loading\u{2026}" } }
135        },
136    }
137}