diff --git a/web/src/app.rs b/web/src/app.rs index 9f2a307..8c5577a 100644 --- a/web/src/app.rs +++ b/web/src/app.rs @@ -23,6 +23,7 @@ pub fn App() -> impl IntoView { let screen_width = window().screen().map(|x| x.avail_width().unwrap_or_default()).unwrap_or_default(); let (menu, set_menu) = create_signal(screen_width <= 786); + let (advanced, set_advanced) = create_signal(false); spawn_local(async move { if let Err(e) = server_tl.more(auth).await { @@ -62,7 +63,11 @@ pub fn App() -> impl IntoView {

- + {move || if advanced.get() { view! { + + }} else { view! { + + }}}
>) -> impl IntoView { } } +pub const PRIVACY_PUBLIC : &str = "💿"; +pub const PRIVACY_FOLLOWERS : &str = "🔒"; +pub const PRIVACY_PRIVATE : &str = "📨"; + #[component] pub fn PrivacyMarker(addressed: Vec) -> impl IntoView { let privacy = if addressed.iter().any(|x| x == apb::target::PUBLIC) { - "🌐" + PRIVACY_PUBLIC } else if addressed.iter().any(|x| x.ends_with("/followers")) { - "🔒" + PRIVACY_FOLLOWERS } else { - "🔗" + PRIVACY_PRIVATE }; let audience = format!("[ {} ]", addressed.join(", ")); view! { diff --git a/web/src/control.rs b/web/src/control.rs index 4e49f42..97a2cf7 100644 --- a/web/src/control.rs +++ b/web/src/control.rs @@ -1,4 +1,4 @@ -use apb::ObjectMut; +use apb::{ActivityMut, ObjectMut}; use leptos::*; use crate::prelude::*; @@ -15,68 +15,224 @@ pub fn Navigator() -> impl IntoView { } #[component] -pub fn PostBox(username: Signal>) -> impl IntoView { +pub fn PostBox(username: Signal>, advanced: WriteSignal) -> impl IntoView { let auth = use_context::().expect("missing auth context"); + let (posting, set_posting) = create_signal(false); + let (error, set_error) = create_signal(None); let summary_ref: NodeRef = create_node_ref(); let content_ref: NodeRef = create_node_ref(); let public_ref: NodeRef = create_node_ref(); let followers_ref: NodeRef = create_node_ref(); + let private_ref: NodeRef = create_node_ref(); view! {
- - - + + +
+ + + + - - - - + + + + + + + + + +
- -
- {PRIVACY_PUBLIC} +
{PRIVACY_FOLLOWERS}
{PRIVACY_PRIVATE}
+ {move|| error.get().map(|x| view! {
{x}
})}
} } +#[component] +pub fn AdvancedPostBox(username: Signal>, advanced: WriteSignal) -> impl IntoView { + let auth = use_context::().expect("missing auth context"); + let (posting, set_posting) = create_signal(false); + let (error, set_error) = create_signal(None); + let (value, set_value) = create_signal("Like".to_string()); + let (embedded, set_embedded) = create_signal(false); + let summary_ref: NodeRef = create_node_ref(); + let content_ref: NodeRef = create_node_ref(); + let context_ref: NodeRef = create_node_ref(); + let name_ref: NodeRef = create_node_ref(); + let reply_ref: NodeRef = create_node_ref(); + let to_ref: NodeRef = create_node_ref(); + let object_id_ref: NodeRef = create_node_ref(); + let bto_ref: NodeRef = create_node_ref(); + let cc_ref: NodeRef = create_node_ref(); + let bcc_ref: NodeRef = create_node_ref(); + view! { +
+ + + + + + + +
+ + + + + +
+
+ + + + + + + +
+
+ +
+ + + + + + + + + + +
+ + + {move|| error.get().map(|x| view! {
{x}
})} +
+ } +} + +fn get_if_some(node: NodeRef) -> Option { + node.get() + .filter(|x| !x.value().is_empty()) + .map(|x| x.value()) +} + +fn get_vec_if_some(node: NodeRef) -> Vec { + node.get() + .filter(|x| !x.value().is_empty()) + .map(|x| x.value()) + .map(|x| + x.split(',') + .map(|x| x.to_string()) + .collect() + ).unwrap_or_default() +} + +fn get_checked(node: NodeRef) -> bool { + node.get() + .map(|x| x.checked()) + .unwrap_or_default() +} + #[component] pub fn Breadcrumb( #[prop(optional)] @@ -92,3 +248,12 @@ pub fn Breadcrumb(
} } + +#[component] +fn SelectOption(is: &'static str, value: ReadSignal) -> impl IntoView { + view! { + + } +}