Compare commits

...

2 commits

Author SHA1 Message Date
a7bcea7653
feat(web): added audience badge 2024-06-06 21:47:23 +02:00
86a45d6082
fix(web): items are responsive to filters changes
is this excessive? having everything in a closure...
2024-06-06 21:46:47 +02:00
4 changed files with 58 additions and 37 deletions

View file

@ -118,9 +118,14 @@
background-color: var(--background); background-color: var(--background);
} }
div.border { div.border {
padding: 1em;
border: 1px dashed var(--accent); border: 1px dashed var(--accent);
} }
div.border-solid {
border: 1px solid var(--background-dim);
}
div.inline {
display: inline;
}
@media screen and (max-width: 786px) { @media screen and (max-width: 786px) {
div.sticky { div.sticky {
top: 1.75rem; top: 1.75rem;

View file

@ -45,39 +45,41 @@ pub fn Item(
let config = use_context::<Signal<crate::Config>>().expect("missing config context"); let config = use_context::<Signal<crate::Config>>().expect("missing config context");
let id = item.id().unwrap_or_default().to_string(); let id = item.id().unwrap_or_default().to_string();
let sep = if sep { Some(view! { <hr /> }) } else { None }; let sep = if sep { Some(view! { <hr /> }) } else { None };
if !replies && !config.get().filters.visible(&item) { move || {
return None; if !replies && !config.get().filters.visible(&item) {
} return None;
match item.object_type().unwrap_or(apb::ObjectType::Object) { }
// special case for placeholder activities match item.object_type().unwrap_or(apb::ObjectType::Object) {
apb::ObjectType::Note | apb::ObjectType::Document(_) => // special case for placeholder activities
Some(view! { <Object object=item.clone() />{sep.clone()} }.into_view()), apb::ObjectType::Note | apb::ObjectType::Document(_) =>
// everything else Some(view! { <Object object=item.clone() />{sep.clone()} }.into_view()),
apb::ObjectType::Activity(t) => { // everything else
let object_id = item.object().id().str().unwrap_or_default(); apb::ObjectType::Activity(t) => {
let object = match t { let object_id = item.object().id().str().unwrap_or_default();
apb::ActivityType::Create | apb::ActivityType::Announce => let object = match t {
CACHE.get(&object_id).map(|obj| { apb::ActivityType::Create | apb::ActivityType::Announce =>
view! { <Object object=obj /> } CACHE.get(&object_id).map(|obj| {
}.into_view()), view! { <Object object=obj /> }
apb::ActivityType::Follow => }.into_view()),
CACHE.get(&object_id).map(|obj| { apb::ActivityType::Follow =>
view! { CACHE.get(&object_id).map(|obj| {
<div class="ml-1"> view! {
<ActorBanner object=obj /> <div class="ml-1">
<FollowRequestButtons activity_id=id.clone() actor_id=object_id /> <ActorBanner object=obj />
</div> <FollowRequestButtons activity_id=id.clone() actor_id=object_id />
} </div>
}.into_view()), }
_ => None, }.into_view()),
}; _ => None,
Some(view! { };
<ActivityLine activity=item.clone() /> Some(view! {
{object} <ActivityLine activity=item.clone() />
{sep.clone()} {object}
}.into_view()) {sep.clone()}
}, }.into_view())
// should never happen },
t => Some(view! { <p><code>type not implemented : {t.as_ref().to_string()}</code></p> }.into_view()), // should never happen
t => Some(view! { <p><code>type not implemented : {t.as_ref().to_string()}</code></p> }.into_view()),
}
} }
} }

View file

@ -131,6 +131,19 @@ pub fn Object(object: crate::Object) -> impl IntoView {
} else { } else {
Some(view! { <div class="pb-1"></div> }) Some(view! { <div class="pb-1"></div> })
}; };
let audience_badge = object.audience().id().str()
.map(|x| view! {
<div class="inline border-solid">
<code class="color">@</code>
<small>
<a class="clean dim" href={x.clone()} target="_blank" rel="nofollow noreferrer">
{Uri::pretty(&x)}
</a>
</small>
</div>
});
let post_inner = view! { let post_inner = view! {
<Summary summary=object.summary().ok().map(|x| x.to_string()) > <Summary summary=object.summary().ok().map(|x| x.to_string()) >
<p inner_html={content}></p> <p inner_html={content}></p>
@ -145,7 +158,7 @@ pub fn Object(object: crate::Object) -> impl IntoView {
}.into_view(), }.into_view(),
// lemmy with Page, peertube with Video // lemmy with Page, peertube with Video
Ok(apb::ObjectType::Document(t)) => view! { Ok(apb::ObjectType::Document(t)) => view! {
<div class="border ml-1 mr-1 mt-1"> <div class="border pa-1 ml-1 mr-1 mt-1">
<b>{object.name().unwrap_or_default().to_string()}</b> <b>{object.name().unwrap_or_default().to_string()}</b>
<hr /> <hr />
{post_inner} {post_inner}
@ -188,6 +201,7 @@ pub fn Object(object: crate::Object) -> impl IntoView {
</table> </table>
{post} {post}
<div class="mt-s ml-1 rev"> <div class="mt-s ml-1 rev">
{audience_badge}
<ReplyButton n=comments target=oid.clone() /> <ReplyButton n=comments target=oid.clone() />
<LikeButton n=likes liked=already_liked target=oid.clone() author=author_id private=!public /> <LikeButton n=likes liked=already_liked target=oid.clone() author=author_id private=!public />
<RepostButton n=shares target=oid /> <RepostButton n=shares target=oid />

View file

@ -15,7 +15,7 @@ pub fn RegisterPage() -> impl IntoView {
view! { view! {
<div class="two-col"> <div class="two-col">
<Breadcrumb>register</Breadcrumb> <Breadcrumb>register</Breadcrumb>
<div class="border ma-2"> <div class="border ma-2 pa-1">
<form on:submit=move|ev| { <form on:submit=move|ev| {
ev.prevent_default(); ev.prevent_default();
logging::log!("registering new user..."); logging::log!("registering new user...");