My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: zettel view impl

+74 -57
+11 -11
flake.lock
··· 8 8 "rust-analyzer-src": "rust-analyzer-src" 9 9 }, 10 10 "locked": { 11 - "lastModified": 1774887814, 12 - "narHash": "sha256-8bsvr2SgW9t70nFxUdMVQg4RSU+E/y9+Je4urivtOYE=", 11 + "lastModified": 1775115015, 12 + "narHash": "sha256-XO7jmyFupI82Sr1M2tLfsSxslIJwUOjzhFqeffaWyNw=", 13 13 "owner": "nix-community", 14 14 "repo": "fenix", 15 - "rev": "9b6c1cb49eff1346e1f5d2430994a0ba0fa02910", 15 + "rev": "45f82ed61800d52e27390b70823426045d982c84", 16 16 "type": "github" 17 17 }, 18 18 "original": { ··· 23 23 }, 24 24 "nixpkgs": { 25 25 "locked": { 26 - "lastModified": 1774709303, 27 - "narHash": "sha256-D3Q07BbIA2KnTcSXIqqu9P586uWxN74zNoCH3h2ESHg=", 28 - "rev": "8110df5ad7abf5d4c0f6fb0f8f978390e77f9685", 29 - "revCount": 971119, 26 + "lastModified": 1775036866, 27 + "narHash": "sha256-ZojAnPuCdy657PbTq5V0Y+AHKhZAIwSIT2cb8UgAz/U=", 28 + "rev": "6201e203d09599479a3b3450ed24fa81537ebc4e", 29 + "revCount": 972949, 30 30 "type": "tarball", 31 - "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.971119%2Brev-8110df5ad7abf5d4c0f6fb0f8f978390e77f9685/019d3c72-3e5d-7d8e-a4fc-0fe67ed1554b/source.tar.gz" 31 + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.972949%2Brev-6201e203d09599479a3b3450ed24fa81537ebc4e/019d4b63-29c4-7e95-9524-45503c792ef3/source.tar.gz" 32 32 }, 33 33 "original": { 34 34 "type": "tarball", ··· 44 44 "rust-analyzer-src": { 45 45 "flake": false, 46 46 "locked": { 47 - "lastModified": 1774787924, 48 - "narHash": "sha256-Cbpmf0+1pqi/zbpub2vkp5lTPx3QdVtDkkagDwQzHHg=", 47 + "lastModified": 1775045117, 48 + "narHash": "sha256-PLZYhcg3HUZ+lUMUV+JbXs9ExOAYpZC0PAtOVHCgYss=", 49 49 "owner": "rust-lang", 50 50 "repo": "rust-analyzer", 51 - "rev": "f1297b21119565c626320c1ffc248965fffb2527", 51 + "rev": "e599ad4fc8861e0401906e4d730f74bfcc530e07", 52 52 "type": "github" 53 53 }, 54 54 "original": {
+6 -8
src/tui/components/zk/mod.rs
··· 48 48 Constraint::Percentage(10), 49 49 Constraint::Percentage(90), 50 50 ]), 51 - z_preview: Layout::vertical(vec![ 52 - Constraint::Percentage(20), 53 - Constraint::Percentage(80), 54 - ]), 51 + z_preview: Layout::vertical(vec![Constraint::Max(6), Constraint::Percentage(80)]), 55 52 } 56 53 } 57 54 } ··· 221 218 .get_node_by_zettel_id(id) 222 219 .expect("Invariant broken, this must exist."); 223 220 224 - //TODO: we would actually want to create the new zettel_list_item 225 - // and insert it into the list where the selected id is there, that 226 - // is what makes the most sense imo 221 + // actually this is the only way to do it with the list thing, 222 + // the ratatui api doesnt expose a swap function to the inner render 223 + // list. 227 224 self.zettel_list = ZettelList::new( 228 - // ideally we dont want to do this right? 229 225 kh.graph.nodes_iter().collect::<Vec<_>>().as_slice(), 230 226 self.zettel_list.state, 231 227 self.zettel_list.width, 232 228 ); 229 + 233 230 self.zettel_view = ZettelView::from(node.payload()); 234 231 self.preview = Preview::from(node.payload().content(&kh.ws).await?); 235 232 drop(kh); ··· 267 264 268 265 frame.render_widget(self.zettel_view.clone(), zettel_layout); 269 266 frame.render_widget(self.preview.clone(), preview_layout); 267 + // frame.render_widget(Block::new().bg(Color::Red), preview_layout); 270 268 271 269 Ok(()) 272 270 }
+2 -2
src/tui/components/zk/preview.rs
··· 1 - use ratatui::{text::Text, widgets::Widget}; 1 + use ratatui::{style::Style, text::Text, widgets::Widget}; 2 2 3 3 #[derive(Debug, Clone)] 4 4 pub struct Preview<'text> { ··· 18 18 where 19 19 Self: Sized, 20 20 { 21 - self.content.render(area, buf); 21 + self.content.style(Style::new()).render(area, buf); 22 22 } 23 23 }
+55 -36
src/tui/components/zk/zettel_view.rs
··· 1 1 use ratatui::{ 2 2 layout::{Constraint, Layout}, 3 - text::Text, 4 - widgets::Widget, 3 + style::Style, 4 + text::{Line, Span}, 5 + widgets::{Block, BorderType, Borders, Paragraph, Widget}, 5 6 }; 6 7 7 8 use crate::types::Zettel; ··· 9 10 /// A `Widget` that represents a `Zettel` 10 11 #[derive(Debug, Clone)] 11 12 pub struct ZettelView<'text> { 12 - title: Text<'text>, 13 - tags: Text<'text>, 14 - created_at: Text<'text>, 15 - modified_at: Text<'text>, 16 - id: Text<'text>, 13 + // title: Text<'text>, 14 + title: Paragraph<'text>, 15 + tags: Paragraph<'text>, 16 + created_at: Paragraph<'text>, 17 + zettel_id: Paragraph<'text>, 17 18 layouts: Layouts, 18 19 } 19 20 20 21 impl From<&Zettel> for ZettelView<'_> { 21 22 fn from(value: &Zettel) -> Self { 22 23 Self { 23 - title: Text::from(value.title.clone()), 24 - tags: Text::from( 24 + title: Paragraph::new(value.title.clone()).block( 25 + Block::default() 26 + .title("Title") 27 + .borders(Borders::all()) 28 + .border_style(Style::new()) 29 + .border_type(BorderType::Plain), 30 + ), 31 + tags: Paragraph::new( 25 32 value 26 33 .tags 27 34 .iter() 28 - .fold(" ".to_owned(), |acc, t| format!("{acc} {}", t.name)), 35 + .map(|t| { 36 + Span::from(format!("{} ", t.name)).style(Style::new().fg(t.color.into())) 37 + }) 38 + .collect::<Line>(), 39 + ) 40 + .block( 41 + Block::default() 42 + .title("Tags") 43 + .borders(Borders::all()) 44 + .border_style(Style::new()) 45 + .border_type(BorderType::Plain), 46 + ), 47 + created_at: Paragraph::new(value.created_at()).block( 48 + Block::default() 49 + .title("Created At") 50 + .borders(Borders::all()) 51 + .border_style(Style::new()) 52 + .border_type(BorderType::Plain), 53 + ), 54 + zettel_id: Paragraph::new(value.id.to_string()).block( 55 + Block::default() 56 + .title("Id") 57 + .borders(Borders::all()) 58 + .border_style(Style::new()) 59 + .border_type(BorderType::Plain), 29 60 ), 30 - created_at: Text::from(value.created_at()), 31 - modified_at: Text::from(value.modified_at()), 32 - id: Text::from(value.id.to_string()), 61 + 33 62 layouts: Layouts::default(), 34 63 } 35 64 } ··· 37 66 38 67 #[derive(Debug, Clone)] 39 68 struct Layouts { 40 - left_right: Layout, 41 - title_tags: Layout, 42 - cr_mod_id: Layout, 69 + top_bottom: Layout, 70 + title_created: Layout, 71 + tags_id: Layout, 43 72 } 44 73 45 74 impl Default for Layouts { 46 75 fn default() -> Self { 47 76 Self { 48 - left_right: Layout::horizontal(vec![ 49 - Constraint::Percentage(70), 50 - Constraint::Percentage(30), 51 - ]), 77 + top_bottom: Layout::vertical(vec![Constraint::Max(3), Constraint::Max(3)]), 78 + 79 + title_created: Layout::horizontal(vec![Constraint::Fill(80), Constraint::Min(24)]), 52 80 53 - title_tags: Layout::vertical(vec![ 54 - Constraint::Percentage(50), 55 - Constraint::Percentage(50), 56 - ]), 57 - cr_mod_id: Layout::vertical(vec![ 58 - Constraint::Percentage(33), 59 - Constraint::Percentage(33), 60 - Constraint::Percentage(33), 61 - ]), 81 + tags_id: Layout::horizontal(vec![Constraint::Fill(95), Constraint::Min(8)]), 62 82 } 63 83 } 64 84 } ··· 68 88 where 69 89 Self: Sized, 70 90 { 71 - let (title_rect, tags_rect, created_rect, modified_rect, id_rect) = { 72 - let rects = self.layouts.left_right.split(area); 91 + let (title_rect, created_rect, tags_rect, modified_rect) = { 92 + let rects = self.layouts.top_bottom.split(area); 73 93 74 94 let (left, right) = (rects[0], rects[1]); 75 95 76 - let l_rects = self.layouts.title_tags.split(left); 96 + let t_rects = self.layouts.title_created.split(left); 77 97 78 - let r_rects = self.layouts.cr_mod_id.split(right); 98 + let b_rects = self.layouts.tags_id.split(right); 79 99 80 - (l_rects[0], l_rects[1], r_rects[0], r_rects[1], r_rects[2]) 100 + (t_rects[0], t_rects[1], b_rects[0], b_rects[1]) 81 101 }; 82 102 83 103 self.title.render(title_rect, buf); 84 104 self.tags.render(tags_rect, buf); 85 105 self.created_at.render(created_rect, buf); 86 - self.modified_at.render(modified_rect, buf); 87 - self.id.render(id_rect, buf); 106 + self.zettel_id.render(modified_rect, buf); 88 107 } 89 108 }