diff --git a/crates/context-frontend/src/components/task_components.rs b/crates/context-frontend/src/components/task_components.rs index e3bbe6eb..2b21a627 100644 --- a/crates/context-frontend/src/components/task_components.rs +++ b/crates/context-frontend/src/components/task_components.rs @@ -1,4 +1,3 @@ -use leptos::ev; use leptos::prelude::*; use leptos::task::spawn_local; use thaw::*; @@ -67,12 +66,33 @@ fn status_bg_color(status: &str) -> &'static str { } } +/// Kanban column order and labels - drives both the rendered columns and the expanded grid template. +const KANBAN_STATUSES: [(&str, &str); 6] = [ + ("backlog", "Backlog"), + ("todo", "Todo"), + ("in_progress", "In Progress"), + ("review", "Review"), + ("done", "Done"), + ("cancelled", "Cancelled"), +]; + +/// Build the `grid-template-columns` value for one expanded column. +fn kanban_grid_template(expanded: &str) -> String { + KANBAN_STATUSES + .iter() + .map(|(status, _)| if *status == expanded { "4fr" } else { "1fr" }) + .collect::>() + .join(" ") +} + #[component] pub fn KanbanColumn( status: &'static str, label: &'static str, list_id: String, total_count: usize, + expanded: Signal, + on_toggle: Callback<()>, ) -> impl IntoView { let (tasks, set_tasks) = signal(Vec::::new()); let (offset, set_offset) = signal(0); @@ -208,12 +228,32 @@ pub fn KanbanColumn( } }; + let column_class = move || { + if expanded.get() { + format!( + "{bg_color} rounded-lg p-4 flex flex-col h-full overflow-hidden ring-1 ring-ctp-blue" + ) + } else { + format!("{bg_color} rounded-lg p-4 flex flex-col h-full overflow-hidden") + } + }; + view! { -
-

- {label} - - {total_count} +
+

+ {label} + + + {total_count} + +

, - on_click: Callback, -) -> impl IntoView { - let subtask_id = subtask.id.clone(); - let subtask_id_for_click = subtask.id.clone(); - let border_color = priority_border_color(subtask.priority); - let is_expanded = move || is_open.get(); - - view! { -
- // Header: CopyableId + Title (left) | Badges (right: Priority → Status) -
- // Left side: CopyableId + Title -
-
- -
-
- {move || { - let title = &subtask.title; - let truncated = !is_expanded() && title.len() > 60; - if truncated { - format!("{}...", &title[..60]) - } else { - title.clone() - } - }} -
-
- - // Right side: Priority → Status badges -
- {subtask.priority.map(|p| { - view! { - - "P"{p} - - } - })} - - {status_badge_label(&subtask.status)} - -
-
- - // Description (only when expanded, with separator) - {move || { - (is_expanded() && subtask.description.is_some()).then(|| { - view! { -
-
- -
-
- } - }) - }} - - // Metadata section (only when expanded) - {move || is_expanded().then(|| { - view! { -
- // Timestamps (right-aligned) -
- {subtask.created_at.clone().map(|created| { - view! { -
- "Created: " - {created} -
- } - })} - - {subtask.updated_at.clone().map(|updated| { - view! { -
- "Updated: " - {updated} -
- } - })} -
- - // Tags (below, left-aligned) - {(!subtask.tags.is_empty()).then(|| { - view! { -
- {subtask.tags.iter().map(|tag| { - view! { - - {tag.clone()} - - } - }).collect::>()} -
- } - })} -
- } - })} -
- } -} - #[component] pub fn TaskCard( task: Task, @@ -778,43 +698,9 @@ pub fn MiniParentCard( } } -/// TaskDetailContent component - reusable task detail content (used in both drawer and split view) +/// TaskDetailContent component - renders one task's detail pane; it does not own subtask navigation #[component] -pub fn TaskDetailContent( - task: Task, - #[prop(optional)] initial_open_subtask_id: Option, -) -> impl IntoView { - // Fetch subtasks - let (subtasks, set_subtasks) = signal(Vec::::new()); - let task_id_for_fetch = task.id.clone(); - let list_id_for_fetch = task.list_id.clone(); - - Effect::new(move || { - let task_id = task_id_for_fetch.clone(); - let list_id = list_id_for_fetch.clone(); - spawn_local(async move { - match tasks::list_for_task_list( - &list_id, - None, - None, - None, - Some("priority"), - Some("asc"), - Some(&task_id), - None, // task_type - we want subtasks here - ) - .await - { - Ok(paginated) => { - set_subtasks.set(paginated.items); - } - Err(_) => { - set_subtasks.set(Vec::new()); - } - } - }); - }); - +pub fn TaskDetailContent(task: Task) -> impl IntoView { view! {
// Sticky header - pinned while the body scrolls @@ -844,7 +730,7 @@ pub fn TaskDetailContent(
- // Full-width body: description, tags, timestamps, refs, subtasks + // Full-width body: description, tags, timestamps, refs
// Markdown description {task.description.as_ref().map(|desc| { @@ -869,7 +755,7 @@ pub fn TaskDetailContent( } })} - // Timestamps, external refs, and subtasks + // Timestamps and external refs
{task.created_at.clone().map(|created| { view! { @@ -902,62 +788,13 @@ pub fn TaskDetailContent(
} })} - - // SubtaskStack - custom collapsible stack (no accordion arrow, no duplicate content) - {move || { - let tasks_list = subtasks.get(); - if !tasks_list.is_empty() { - // Track which subtask is currently open (only one at a time) - let open_subtask_id = RwSignal::new(initial_open_subtask_id.clone()); - - let handle_click = move |id: String| { - open_subtask_id.update(|current| { - if current.as_ref() == Some(&id) { - *current = None; // Close if already open - } else { - *current = Some(id); // Open clicked item - } - }); - }; - - Some(view! { -
-

- {format!("Subtasks ({})", tasks_list.len())} -

-
- - } - } - /> -
-
- }) - } else { - None - } - }}
} } -/// TaskDetailDialog component - shows full task details in a centered modal dialog -/// Fetches fresh data from API using task_id +/// TaskDetailDialog component - two-pane task viewer modeled on the note stack view +/// The left pane pins the entry task above its direct children; activating a card moves the selection. #[component] pub fn TaskDetailDialog( task_id: ReadSignal, @@ -966,54 +803,227 @@ pub fn TaskDetailDialog( Option, >, ) -> impl IntoView { - let task_resource = LocalResource::new(move || { - let id = task_id.get(); - async move { - if id.is_empty() { - Err(crate::api::ApiClientError::Network( - "No task selected".to_string(), - )) - } else { - tasks::get(&id).await + // Active selection rendered in the right pane; the left pane always anchors on the entry task. + let selected_task_id = RwSignal::new(String::new()); + let (entry_task, set_entry_task) = signal(None::>); + let (children, set_children) = signal(Vec::::new()); + let (entry_loading, set_entry_loading) = signal(true); + let (selected_task, set_selected_task) = signal(None::>); + + // Re-initialize the selection whenever the dialog opens or the entry task changes. + Effect::new(move || { + let is_open = open.get(); + let entry_id = task_id.get(); + let initial_subtask_id = initial_open_subtask_id.get(); + + if !is_open { + selected_task_id.set(String::new()); + return; + } + + let start_id = initial_subtask_id + .filter(|id| !id.is_empty()) + .unwrap_or(entry_id); + selected_task_id.set(start_id); + }); + + // Anchor the left pane on the entry task and load its direct children. + Effect::new(move || { + let is_open = open.get(); + let entry_id = task_id.get(); + + if !is_open { + set_entry_task.set(None); + set_children.set(Vec::new()); + return; + } + + if entry_id.is_empty() { + set_entry_task.set(None); + set_children.set(Vec::new()); + set_entry_loading.set(false); + return; + } + + set_entry_loading.set(true); + set_entry_task.set(None); + set_children.set(Vec::new()); + + spawn_local(async move { + match tasks::get(&entry_id).await { + Ok(entry) => { + let list_id = entry.list_id.clone(); + let parent_id = entry.id.clone(); + let items = tasks::list_for_task_list( + &list_id, + None, + None, + None, + Some("priority"), + Some("asc"), + Some(&parent_id), + None, + ) + .await + .map(|paginated| paginated.items) + .unwrap_or_default(); + set_entry_task.set(Some(Ok(entry))); + set_children.set(items); + } + Err(err) => { + set_entry_task.set(Some(Err(err))); + set_children.set(Vec::new()); + } } + set_entry_loading.set(false); + }); + }); + + // Fetch the selected task for the right pane. + Effect::new(move || { + let id = selected_task_id.get(); + + if id.is_empty() { + set_selected_task.set(None); + return; } + + set_selected_task.set(None); + + spawn_local(async move { + set_selected_task.set(Some(tasks::get(&id).await)); + }); }); view! { - + - - "Loading task..."

} - }> +
+
{move || { - task_resource - .get() - .map(|result| { - match result { - Ok(task) => { - match initial_open_subtask_id.get() { - Some(id) => view! { - - }.into_any(), - None => view! { - - }.into_any(), - } + if entry_loading.get() { + return view! { +

"Loading task..."

+ } + .into_any(); + } + + let Some(result) = entry_task.get() else { + return view! { +

"No task selected"

+ } + .into_any(); + }; + + let entry = match result { + Ok(entry) => entry, + Err(err) => { + return view! { +
+

+ "Error loading task" +

+

+ {err.to_string()} +

+
+ } + .into_any(); + } + }; + + let entry_id = entry.id.clone(); + let entry_id_for_selected = entry_id.clone(); + + view! { +
+ +
+ + {move || { + if children.get().is_empty() { + view! { +

"No subtasks"

} - Err(e) => { - view! { -
- "Error loading task: " {e.to_string()} -
- }.into_any() + .into_any() + } else { + view! { + + +
+ } + } + /> } + .into_any() } - }) + }} + } + .into_any() + }} +
+ +
+ {move || { + match selected_task.get() { + None => { + view! {

"Loading..."

} + .into_any() + } + Some(Err(err)) => { + view! { +
+

+ "Error loading task" +

+

+ {err.to_string()} +

+
+ } + .into_any() + } + Some(Ok(task)) => { + view! { }.into_any() + } + } }} - - +
+

@@ -1192,6 +1202,15 @@ pub fn TaskListCard( pub fn TaskListContent(task_list: Signal) -> impl IntoView { let (stats_data, set_stats_data) = signal(None::>); + // At most one kanban column is expanded at a time + let expanded_status = RwSignal::new(None::<&'static str>); + + // Inline custom property that drives the expanded grid template + let board_style = move || match expanded_status.get() { + Some(status) => format!("--kanban-grid-cols: {}", kanban_grid_template(status)), + None => String::new(), + }; + // WebSocket updates - refetch trigger for stats let (stats_refetch_trigger, set_stats_refetch_trigger) = signal(0u32); let ws_updates = crate::websocket::use_websocket_updates(); @@ -1228,15 +1247,6 @@ pub fn TaskListContent(task_list: Signal) -> impl IntoView { }); }); - let statuses = vec![ - ("backlog", "Backlog"), - ("todo", "Todo"), - ("in_progress", "In Progress"), - ("review", "Review"), - ("done", "Done"), - ("cancelled", "Cancelled"), - ]; - view! { "Loading task list..."

} @@ -1286,9 +1296,11 @@ pub fn TaskListContent(task_list: Signal) -> impl IntoView { } })} -
- {statuses - .clone() +
+ {KANBAN_STATUSES .into_iter() .map(|(status, label)| { // Get total count for this status from stats @@ -1302,12 +1314,26 @@ pub fn TaskListContent(task_list: Signal) -> impl IntoView { _ => 0, }; + let is_expanded = + Signal::derive(move || expanded_status.get() == Some(status)); + let on_toggle = Callback::new(move |_: ()| { + expanded_status.update(|current| { + *current = if *current == Some(status) { + None + } else { + Some(status) + }; + }); + }); + view! { } }) diff --git a/crates/context-frontend/src/public/style.css b/crates/context-frontend/src/public/style.css index 515b9207..415a3d45 100644 --- a/crates/context-frontend/src/public/style.css +++ b/crates/context-frontend/src/public/style.css @@ -260,6 +260,9 @@ max-width: 96rem; } } + .m-3 { + margin: calc(var(--spacing) * 3); + } .mx-auto { margin-inline: auto; } @@ -390,12 +393,6 @@ .h-full { height: 100%; } - .max-h-\[40vh\] { - max-height: 40vh; - } - .max-h-\[90vh\] { - max-height: 90vh; - } .min-h-0 { min-height: 0px; } @@ -506,9 +503,6 @@ .items-center { align-items: center; } - .items-end { - align-items: flex-end; - } .items-start { align-items: flex-start; } @@ -857,12 +851,6 @@ .py-12 { padding-block: calc(var(--spacing) * 12); } - .pt-2 { - padding-top: calc(var(--spacing) * 2); - } - .pt-3 { - padding-top: calc(var(--spacing) * 3); - } .pt-6 { padding-top: calc(var(--spacing) * 6); } @@ -1039,6 +1027,13 @@ --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor); box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); } + .ring-1 { + --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor); + box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); + } + .ring-ctp-blue { + --tw-ring-color: var(--ctp-blue); + } .outline { outline-style: var(--tw-outline-style); outline-width: 1px; @@ -1118,14 +1113,6 @@ .hover\:bg-ctp-overlay0:hover { background-color: var(--ctp-overlay0); } - .hover\:bg-ctp-surface0\/80:hover { - background-color: var(--ctp-surface0); - } - @supports (color: color-mix(in lab, red, red)) { - .hover\:bg-ctp-surface0\/80:hover { - background-color: color-mix(in oklab, var(--ctp-surface0) 80%, transparent); - } - } .hover\:bg-ctp-surface1:hover { background-color: var(--ctp-surface1); } @@ -1199,6 +1186,9 @@ } } @media (width >= 80rem) { + .xl\:inline-flex { + display: inline-flex; + } .xl\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } @@ -1339,9 +1329,9 @@ body { margin-bottom: 2em; } .task-detail-dialog-surface { - width: 90vw !important; - max-width: 90vw !important; - max-height: 90vh !important; + width: 95vw !important; + max-width: 95vw !important; + height: 90vh !important; overflow: hidden !important; } .task-detail-dialog-surface.thaw-dialog-surface { @@ -1356,10 +1346,35 @@ body { flex-direction: column !important; max-height: none !important; } -.task-detail-dialog-surface .thaw-dialog-content { - flex: 1 !important; - min-height: 0 !important; - overflow-y: auto !important; +.task-detail-split { + display: flex; + flex-direction: row; + flex: 1; + min-height: 0; + overflow: hidden; +} +.task-detail-split-side { + width: 360px; + flex-shrink: 0; + border-right: 1px solid var(--ctp-surface1); + overflow-y: auto; +} +.task-detail-split-main { + flex: 1; + min-width: 0; + min-height: 0; + overflow-y: auto; +} +@media (max-width: 1023px) { + .task-detail-split { + flex-direction: column; + } + .task-detail-split-side { + width: 100%; + height: 40vh; + border-right: none; + border-bottom: 1px solid var(--ctp-surface1); + } } .note-detail-drawer { width: 85vw !important; @@ -1524,6 +1539,21 @@ body { background-color: var(--ctp-surface1); border: 2px solid var(--ctp-blue); } +.task-stack-card { + background-color: var(--ctp-surface0); + border: 1px solid var(--ctp-surface1); + outline: none; + -webkit-tap-highlight-color: transparent; + overflow-anchor: none; +} +.task-stack-card:hover { + background-color: var(--ctp-surface0); + opacity: 0.8; +} +.task-stack-card[data-selected="true"] { + background-color: var(--ctp-surface1); + border: 2px solid var(--ctp-blue); +} .prose pre { background: var(--ctp-mantle); border: 1px solid var(--ctp-surface1); @@ -1800,6 +1830,11 @@ body { margin: 1in; } } +@media (min-width: 1280px) { + .kanban-board-grid { + grid-template-columns: var(--kanban-grid-cols, repeat(6, minmax(0, 1fr))); + } +} @property --tw-translate-x { syntax: "*"; inherits: false; diff --git a/crates/context-frontend/src/tailwind/input.css b/crates/context-frontend/src/tailwind/input.css index 3f7302ca..95bcb4ec 100644 --- a/crates/context-frontend/src/tailwind/input.css +++ b/crates/context-frontend/src/tailwind/input.css @@ -186,9 +186,9 @@ body { /* Task detail dialog - override thaw's max-width: 600px */ .task-detail-dialog-surface { - width: 90vw !important; - max-width: 90vw !important; - max-height: 90vh !important; + width: 95vw !important; + max-width: 95vw !important; + height: 90vh !important; overflow: hidden !important; } @@ -198,8 +198,7 @@ body { flex-direction: column; } -/* Body fills remaining space inside the surface (after 48px padding). - No max-height needed — the surface's max-height: 85vh constrains it via flex. */ +/* Body fills the fixed surface height (90vh minus the 24px surface padding on each side). */ .task-detail-dialog-surface .thaw-dialog-body { flex: 1 !important; min-height: 0 !important; @@ -209,11 +208,40 @@ body { max-height: none !important; } -/* Content scrolls within the body */ -.task-detail-dialog-surface .thaw-dialog-content { - flex: 1 !important; - min-height: 0 !important; - overflow-y: auto !important; +/* Two-pane task detail: children left, task detail right */ +.task-detail-split { + display: flex; + flex-direction: row; + flex: 1; + min-height: 0; + overflow: hidden; +} + +.task-detail-split-side { + width: 360px; + flex-shrink: 0; + border-right: 1px solid var(--ctp-surface1); + overflow-y: auto; +} + +.task-detail-split-main { + flex: 1; + min-width: 0; + min-height: 0; + overflow-y: auto; +} + +@media (max-width: 1023px) { + .task-detail-split { + flex-direction: column; + } + + .task-detail-split-side { + width: 100%; + height: 40vh; + border-right: none; + border-bottom: 1px solid var(--ctp-surface1); + } } /* Thaw UI OverlayDrawer custom styling */ @@ -443,6 +471,25 @@ body { border: 2px solid var(--ctp-blue); } +/* Task stack card selection - mirrors .note-stack-card */ +.task-stack-card { + background-color: var(--ctp-surface0); + border: 1px solid var(--ctp-surface1); + outline: none; + -webkit-tap-highlight-color: transparent; + overflow-anchor: none; +} + +.task-stack-card:hover { + background-color: var(--ctp-surface0); + opacity: 0.8; +} + +.task-stack-card[data-selected="true"] { + background-color: var(--ctp-surface1); + border: 2px solid var(--ctp-blue); +} + /* === Markdown code blocks (syntect-highlighted) === */ .prose pre { background: var(--ctp-mantle); @@ -781,3 +828,12 @@ body { margin: 1in; } } + +/* Kanban board column expansion. + --kanban-grid-cols is set inline by TaskListContent while one column is expanded. + The fallback matches Tailwind's xl:grid-cols-6 exactly, so the default render is unchanged. */ +@media (min-width: 1280px) { + .kanban-board-grid { + grid-template-columns: var(--kanban-grid-cols, repeat(6, minmax(0, 1fr))); + } +} diff --git a/flake.nix b/flake.nix index 5968a386..09f376af 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,11 @@ perSystem = {system, ...}: let overlays = [ inputs.rustnix.lib.rust.overlays.fenix + ( + final: _prev: { + trunk = final.callPackage ./nix/trunk.nix {}; + } + ) ]; pkgs = import inputs.nixpkgs {inherit system overlays;}; diff --git a/nix/trunk.nix b/nix/trunk.nix new file mode 100644 index 00000000..06a1913d --- /dev/null +++ b/nix/trunk.nix @@ -0,0 +1,37 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + openssl, +}: let + pname = "trunk"; + version = "0.22.1"; +in + rustPlatform.buildRustPackage { + inherit pname version; + + src = fetchFromGitHub { + owner = "trunk-rs"; + repo = "trunk"; + rev = "v${version}"; + hash = "sha256-GXwFLOjmNZL2qNgFLG18pM+jXLvR4u80SUyjH9dsnJM="; + }; + + nativeBuildInputs = [pkg-config]; + + buildInputs = [openssl]; + + # requires network + checkFlags = ["--skip=tools::tests::download_and_install_binaries"]; + + cargoHash = "sha256-k4yQrT3gxjLPL5hI+1LtU0Nrd2a0ksGSAmI2I2AUZn0="; + + meta = { + homepage = "https://github.com/trunk-rs/trunk"; + description = "Build, bundle & ship your Rust WASM application to the web"; + mainProgram = "trunk"; + maintainers = with lib.maintainers; [ctron]; + license = lib.licenses.asl20; + }; + }