Files
todo-baggins/src/components/category_input.rs
Matouš Volf 2f933d5302
All checks were successful
actionlint check / actionlint check (pull_request) Successful in 5s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 7s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 5s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 10s
hadolint check / hadolint check (pull_request) Successful in 16s
GitLeaks check / GitLeaks check (pull_request) Successful in 10s
htmlhint check / htmlhint check (pull_request) Successful in 35s
Prettier check / Prettier check (pull_request) Successful in 26s
markdownlint check / markdownlint check (pull_request) Successful in 31s
checkov check / checkov check (pull_request) Successful in 1m15s
ShellCheck check / ShellCheck check (pull_request) Successful in 30s
Stylelint check / Stylelint check (pull_request) Successful in 29s
yamllint check / yamllint check (pull_request) Successful in 27s
Rust check / Rust check (pull_request) Successful in 11m44s
chore: upgrade to Dioxus 0.7
2025-12-18 20:07:21 +01:00

105 lines
3.7 KiB
Rust

use crate::models::category::Category;
use dioxus::core_macro::rsx;
use dioxus::dioxus_core::Element;
use dioxus::prelude::*;
#[component]
pub(crate) fn CategoryInput(
selected_category: Signal<Category>,
class: Option<&'static str>,
) -> Element {
rsx! {
div {
class: format!("flex flex-row gap-2 {}", class.unwrap_or("")),
button {
r#type: "button",
class: format!(
"py-2 rounded-lg grow basis-0 {} cursor-pointer",
if selected_category() == Category::SomedayMaybe { "bg-zinc-500/50" }
else { "bg-zinc-800/50" }
),
onclick: move |_| {
selected_category.set(Category::SomedayMaybe);
},
i {
class: "fa-solid fa-question"
}
},
button {
r#type: "button",
class: format!(
"py-2 rounded-lg grow basis-0 {} cursor-pointer",
if selected_category() == Category::LongTerm { "bg-zinc-500/50" }
else { "bg-zinc-800/50" }
),
onclick: move |_| {
selected_category.set(Category::LongTerm);
},
i {
class: "fa-solid fa-water"
}
},
button {
r#type: "button",
class: format!(
"py-2 rounded-lg grow basis-0 {} cursor-pointer",
if let Category::WaitingFor(_) = selected_category() { "bg-zinc-500/50" }
else { "bg-zinc-800/50" }
),
onclick: move |_| {
selected_category.set(Category::WaitingFor(String::new()));
},
i {
class: "fa-solid fa-hourglass-half"
}
},
button {
r#type: "button",
class: format!(
"py-2 rounded-lg grow basis-0 {} cursor-pointer",
if selected_category() == Category::NextSteps { "bg-zinc-500/50" }
else { "bg-zinc-800/50" }
),
onclick: move |_| {
selected_category.set(Category::NextSteps);
},
i {
class: "fa-solid fa-forward"
}
},
button {
r#type: "button",
class: format!(
"py-2 rounded-lg grow basis-0 {} cursor-pointer",
if let Category::Calendar { .. } = selected_category() { "bg-zinc-500/50" }
else { "bg-zinc-800/50" }
),
onclick: move |_| {
selected_category.set(Category::Calendar {
date: chrono::Local::now().date_naive(),
reoccurrence: None,
time: None,
});
},
i {
class: "fa-solid fa-calendar-days"
}
},
button {
r#type: "button",
class: format!(
"py-2 rounded-lg grow basis-0 {} cursor-pointer",
if selected_category() == Category::Inbox { "bg-zinc-500/50" }
else { "bg-zinc-800/50" }
),
onclick: move |_| {
selected_category.set(Category::Inbox);
},
i {
class: "fa-solid fa-inbox"
}
}
}
}
}