Some checks failed
actionlint check / actionlint check (pull_request) Successful in 5s
checkov check / checkov check (pull_request) Successful in 52s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 4s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 2s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 5s
GitLeaks check / GitLeaks check (pull_request) Successful in 6s
hadolint check / hadolint check (pull_request) Successful in 7s
htmlhint check / htmlhint check (pull_request) Successful in 9s
markdownlint check / markdownlint check (pull_request) Successful in 9s
Prettier check / Prettier check (pull_request) Successful in 10s
Rust check / Rust check (pull_request) Failing after 6m20s
ShellCheck check / ShellCheck check (pull_request) Successful in 12s
Stylelint check / Stylelint check (pull_request) Successful in 11s
yamllint check / yamllint check (pull_request) Successful in 13s
76 lines
2.9 KiB
Rust
76 lines
2.9 KiB
Rust
use crate::components::navigation::Navigation;
|
||
use crate::components::project_form::ProjectForm;
|
||
use crate::components::task_form::TaskForm;
|
||
use crate::models::project::Project;
|
||
use crate::models::task::Task;
|
||
use crate::route::Route;
|
||
use dioxus::prelude::*;
|
||
|
||
#[component]
|
||
pub(crate) fn BottomPanel(display_form: Signal<bool>) -> Element {
|
||
// A signal for delaying the application of styles.
|
||
#[allow(clippy::redundant_closure)]
|
||
let mut expanded = use_signal(|| display_form());
|
||
let navigation_expanded = use_signal(|| false);
|
||
let current_route = use_route();
|
||
|
||
let mut project_being_edited = use_context::<Signal<Option<Project>>>();
|
||
let mut task_being_edited = use_context::<Signal<Option<Task>>>();
|
||
|
||
use_effect(use_reactive(&display_form, move |display_form| {
|
||
if display_form() {
|
||
expanded.set(true);
|
||
} else {
|
||
spawn(async move {
|
||
// Necessary for a smooth – not instant – height transition.
|
||
async_std::task::sleep(std::time::Duration::from_millis(500)).await;
|
||
/* The check is necessary for the situation when the user expands the panel while
|
||
it is being closed. */
|
||
if !display_form() {
|
||
expanded.set(false);
|
||
}
|
||
});
|
||
}
|
||
}));
|
||
|
||
rsx! {
|
||
div {
|
||
class: format!(
|
||
"pointer-events-auto bg-zinc-700/50 rounded-t-xl border-t-zinc-600 border-t backdrop-blur drop-shadow-[0_-5px_10px_rgba(0,0,0,0.2)] transition-[height] duration-[500ms] ease-[cubic-bezier(0.79,0.14,0.15,0.86)] overflow-y-scroll {}",
|
||
match (display_form(), current_route, navigation_expanded()) {
|
||
(false, _, false) => "h-[66px]",
|
||
(false, _, true) => "h-[130px]",
|
||
(true, Route::ProjectsPage, _) => "h-[130px]",
|
||
(true, _, _) => "h-[506px]",
|
||
}
|
||
),
|
||
if expanded() {
|
||
match current_route {
|
||
Route::ProjectsPage => rsx! {
|
||
ProjectForm {
|
||
project: project_being_edited(),
|
||
on_successful_submit: move |_| {
|
||
display_form.set(false);
|
||
project_being_edited.set(None);
|
||
}
|
||
}
|
||
},
|
||
_ => rsx! {
|
||
TaskForm {
|
||
task: task_being_edited(),
|
||
on_successful_submit: move |_| {
|
||
display_form.set(false);
|
||
task_being_edited.set(None);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
Navigation {
|
||
expanded: navigation_expanded,
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|