2023-04-13 12:51:25 -05:00
|
|
|
use crate::components::void_buttons::*;
|
|
|
|
use crate::components::void_title::*;
|
2023-04-16 21:46:10 -05:00
|
|
|
use crate::utils::helpers;
|
|
|
|
use crate::utils::prop_structs::{PoemChildren, PoemData};
|
|
|
|
use super::super::utils::user_prefs::*;
|
|
|
|
use dioxus::prelude::*;
|
2023-04-13 12:51:25 -05:00
|
|
|
|
|
|
|
pub fn PoemList(cx: Scope) -> Element {
|
|
|
|
let poem_list = helpers::get_poem_list();
|
|
|
|
cx.render(rsx! {
|
|
|
|
ul { class: "flex flex-col space-y-4",
|
|
|
|
poem_list.into_iter().map(|p| {
|
|
|
|
let slug = format!("/poems/{}", p.1);
|
|
|
|
rsx!{
|
|
|
|
NavigationButton { title: p.0, slug: slug }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn MakePoem<'a>(cx: Scope<'a, PoemChildren<'a>>) -> Element {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div { class: "flex-col space-y-4",
|
|
|
|
&cx.props.children
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn GetPoem(cx: Scope<PoemData>) -> Element {
|
|
|
|
let slug = String::from(cx.props.slug.clone().expect("No slug specified."));
|
|
|
|
let (title, content, creation_date) = helpers::get_poem(slug.clone());
|
|
|
|
cx.render(rsx! {
|
2023-04-16 21:46:10 -05:00
|
|
|
Title { title: title, is_html: true, user_prefs: UserPrefs::new(ThemePref::Auto, FontPref::OpenDyslexic)}
|
2023-04-13 12:51:25 -05:00
|
|
|
MakePoem{
|
|
|
|
PoemContent { content: content, creation_date: creation_date }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn PoemContent(cx: Scope<PoemData>) -> Element {
|
|
|
|
let content = cx.props.content.clone().expect("No content specified.");
|
|
|
|
let creation_date = cx
|
|
|
|
.props
|
|
|
|
.creation_date
|
|
|
|
.clone()
|
|
|
|
.expect("No creation date specified.");
|
|
|
|
#[cfg(any(target_family = "unix", target_family = "windows"))]
|
|
|
|
return cx.render(rsx! {
|
|
|
|
div { class: "flex p-2 mx-auto max-w-full justify-center",
|
2023-04-17 12:34:20 -05:00
|
|
|
details { class: "group p-4 max-w-fit space-y-4 ring-4",
|
2023-04-16 21:46:10 -05:00
|
|
|
summary { class: "group-open:before:content-['Close'] before:content-['Open'] flex justify-center p-2 ring-2",
|
2023-04-13 12:51:25 -05:00
|
|
|
}
|
|
|
|
div { class: "font-nerd flex flex-col space-y-4 py-4", "{content}{creation_date}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
#[cfg(target_family = "wasm")]
|
|
|
|
return cx.render(rsx! {
|
|
|
|
div { class: "flex p-2 mx-auto max-w-full justify-center",
|
2023-04-16 21:46:10 -05:00
|
|
|
details { class: "group p-4 max-w-fit space-y-4",
|
|
|
|
summary { class: "group-open:before:content-['Close'] before:content-['Open'] flex justify-center p-2 ring-2",
|
2023-04-13 12:51:25 -05:00
|
|
|
}
|
|
|
|
div { class: "font-nerd flex flex-col space-y-4 py-4",
|
|
|
|
dangerous_inner_html: "{content}{creation_date}",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2023-04-16 21:46:10 -05:00
|
|
|
}
|