1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-29 06:51:10 +00:00

fix article list buttons

This commit is contained in:
Felix Ableitner 2024-11-21 13:12:37 +01:00
parent 995106dfc1
commit 53fce0db39

View file

@ -2,13 +2,11 @@ use crate::{
common::ListArticlesForm,
frontend::{api::CLIENT, article_link, article_title, components::connect::ConnectView},
};
use leptos::{html::Input, prelude::*};
use leptos::prelude::*;
#[component]
pub fn ListArticles() -> impl IntoView {
let (only_local, set_only_local) = signal(false);
let button_only_local = NodeRef::<Input>::new();
let button_all = NodeRef::<Input>::new();
let articles = Resource::new(
move || only_local.get(),
|only_local| async move {
@ -21,6 +19,28 @@ pub fn ListArticles() -> impl IntoView {
.unwrap()
},
);
let only_local_class = Resource::new(
move || only_local.get(),
|only_local| async move {
if only_local {
"btn rounded-r-none btn-primary"
} else {
"btn rounded-r-none"
}
.to_string()
},
);
let all_class = Resource::new(
move || only_local.get(),
|only_local| async move {
if !only_local {
"btn rounded-l-none btn-primary"
} else {
"btn rounded-l-none"
}
.to_string()
},
);
view! {
<h1 class="text-4xl font-bold font-serif my-4">Most recently edited Articles</h1>
@ -29,8 +49,7 @@ pub fn ListArticles() -> impl IntoView {
<input
type="button"
value="Only Local"
class="btn rounded-r-none"
node_ref=button_only_local
class=move || only_local_class.get()
on:click=move |_| {
set_only_local.set(true);
}
@ -38,8 +57,7 @@ pub fn ListArticles() -> impl IntoView {
<input
type="button"
value="All"
class="btn btn-primary rounded-l-none"
node_ref=button_all
class=move || all_class.get()
on:click=move |_| {
set_only_local.set(false);
}