Files
todo-baggins/src/components/task_list.rs
Matouš Volf d4235ef2ab
All checks were successful
actionlint check / actionlint check (pull_request) Successful in 39s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 8s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 10s
GitLeaks check / GitLeaks check (pull_request) Successful in 46s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 48s
hadolint check / hadolint check (pull_request) Successful in 51s
checkov check / checkov check (pull_request) Successful in 2m37s
htmlhint check / htmlhint check (pull_request) Successful in 1m9s
markdownlint check / markdownlint check (pull_request) Successful in 50s
Prettier check / Prettier check (pull_request) Successful in 30s
ShellCheck check / ShellCheck check (pull_request) Successful in 55s
Stylelint check / Stylelint check (pull_request) Successful in 54s
yamllint check / yamllint check (pull_request) Successful in 1m6s
Rust check / Rust check (pull_request) Successful in 24m52s
feat: update Font Awesome to 7.1.0
2026-01-24 17:52:43 +01:00

76 lines
3.0 KiB
Rust

use crate::components::task_list_item::TaskListItem;
use crate::models::category::Category;
use crate::models::task::{Task, TaskWithSubtasks};
use crate::server::tasks::complete_task;
use dioxus::core_macro::rsx;
use dioxus::dioxus_core::Element;
use dioxus::prelude::*;
use dioxus_free_icons::Icon;
use dioxus_free_icons::icons::fa_regular_icons::FaSquare;
use dioxus_free_icons::icons::fa_solid_icons::FaSquareCheck;
#[component]
pub(crate) fn TaskList(tasks: Vec<TaskWithSubtasks>, class: Option<&'static str>) -> Element {
let mut task_being_edited = use_context::<Signal<Option<Task>>>();
rsx! {
div {
class: format!("flex flex-col {}", class.unwrap_or("")),
for task in tasks.clone() {
div {
key: "{task.task.id}",
class: format!(
"px-7 pt-4.25 {} flex flex-row items-start gap-4 select-none {}",
if task.task.deadline.is_some() || !task.subtasks.is_empty() {
"pb-0.25"
} else if let Category::Calendar { time, .. } = &task.task.category {
if time.is_some() {
"pb-0.25"
} else {
"pb-4.25"
}
} else {
"pb-4.25"
},
if task_being_edited().is_some_and(|t| t.id == task.task.id) {
"bg-zinc-700"
} else { "" }
),
onclick: {
let task = task.clone();
move |_| task_being_edited.set(Some(task.task.clone()))
},
button {
class: "text-zinc-500",
onclick: {
move |event: Event<MouseData>| {
// To prevent editing the task.
event.stop_propagation();
async move {
let _ = complete_task(task.task.id).await;
}
}
},
if let Category::Done = task.task.category {
Icon {
icon: FaSquareCheck,
height: 30,
width: 30
}
} else {
Icon {
class: "cursor-pointer",
icon: FaSquare,
height: 30,
width: 30
}
}
},
TaskListItem {
task: task.clone()
}
}
}
}
}
}