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: coloring for ZettelList

+14 -7
+14 -7
src/tui/components/zk/zettel_list.rs
··· 1 1 use egui_graphs::{Node, petgraph::graph::NodeIndex}; 2 2 use ratatui::{ 3 - style::{Color, Modifier, Style}, 3 + style::{Color, Modifier, Style, Stylize}, 4 4 text::{Line, Span, Text}, 5 5 widgets::{List, ListState}, 6 6 }; ··· 24 24 impl From<&Zettel> for ZettelListItem<'_> { 25 25 fn from(value: &Zettel) -> Self { 26 26 Self { 27 - title: Span::from(value.title.clone()), 27 + title: Span::from(value.title.clone()) 28 + .style(Style::new().cyan()) 29 + .add_modifier(Modifier::BOLD), 28 30 tags: value 29 31 .tags 30 32 .iter() 31 33 .map(|t| { 32 34 Span::from(format!("{} ", t.name)) 33 35 .style(Style::new().fg(t.color.into()).italic()) 36 + .add_modifier(Modifier::DIM) 34 37 }) 35 38 .collect(), 36 - date: Span::from(value.created_at()), 39 + date: Span::from(value.created_at()).style(Style::new().add_modifier(Modifier::DIM)), 37 40 width: 0, 38 41 } 39 42 } ··· 46 49 fn from(value: ZettelListItem<'item>) -> Self { 47 50 let title_width: usize = value.title.width(); 48 51 let tags_width: usize = value.tags.iter().map(Span::width).sum(); 49 - let date_width: usize = value.date.width(); 52 + let date_width: usize = value.date.width() + 2; 50 53 51 54 // tags start 2 tabs after the title 52 55 let gap_after_title = 2; 53 56 let used = title_width + gap_after_title + tags_width + date_width; 54 57 let padding = (value.width as usize).saturating_sub(used); 55 58 56 - let line = std::iter::once(value.title) 59 + let mut spans: Vec<Span> = std::iter::once(value.title) 57 60 .chain(std::iter::once(Span::raw(" "))) 58 61 .chain(value.tags) 59 62 .chain(std::iter::once(Span::raw(" ".repeat(padding)))) 60 - .chain(std::iter::once(value.date)) 61 - .collect::<Line>(); 63 + .collect(); 62 64 65 + if tags_width + title_width + date_width <= value.width as usize { 66 + spans.push(value.date); 67 + } 68 + 69 + let line = Line::from(spans); 63 70 line.into() 64 71 } 65 72 }