1use std::{ops::Range, time::Duration};
2
3use editor::{EditorSettings, ShowScrollbar, scroll::ScrollbarAutoHide};
4use gpui::{
5 AppContext, Axis, Context, Entity, FocusHandle, FontWeight, Length,
6 ListHorizontalSizingBehavior, ListSizingBehavior, MouseButton, Stateful, Task,
7 UniformListScrollHandle, WeakEntity, uniform_list,
8};
9use settings::Settings as _;
10use ui::{
11 ActiveTheme as _, AnyElement, App, Button, ButtonCommon as _, ButtonStyle, Color, Component,
12 ComponentScope, Div, ElementId, FixedWidth as _, FluentBuilder as _, Indicator,
13 InteractiveElement as _, IntoElement, ParentElement, Pixels, RegisterComponent, RenderOnce,
14 Scrollbar, ScrollbarState, StatefulInteractiveElement as _, Styled, StyledExt as _,
15 StyledTypography, Window, div, example_group_with_title, h_flex, px, single_example, v_flex,
16};
17
18struct UniformListData<const COLS: usize> {
19 render_item_fn: Box<dyn Fn(Range<usize>, &mut Window, &mut App) -> Vec<[AnyElement; COLS]>>,
20 element_id: ElementId,
21 row_count: usize,
22}
23
24enum TableContents<const COLS: usize> {
25 Vec(Vec<[AnyElement; COLS]>),
26 UniformList(UniformListData<COLS>),
27}
28
29impl<const COLS: usize> TableContents<COLS> {
30 fn rows_mut(&mut self) -> Option<&mut Vec<[AnyElement; COLS]>> {
31 match self {
32 TableContents::Vec(rows) => Some(rows),
33 TableContents::UniformList(_) => None,
34 }
35 }
36
37 fn len(&self) -> usize {
38 match self {
39 TableContents::Vec(rows) => rows.len(),
40 TableContents::UniformList(data) => data.row_count,
41 }
42 }
43}
44
45pub struct TableInteractionState {
46 pub focus_handle: FocusHandle,
47 pub scroll_handle: UniformListScrollHandle,
48 pub horizontal_scrollbar: ScrollbarProperties,
49 pub vertical_scrollbar: ScrollbarProperties,
50}
51
52impl TableInteractionState {
53 pub fn new(window: &mut Window, cx: &mut App) -> Entity<Self> {
54 cx.new(|cx| {
55 let focus_handle = cx.focus_handle();
56
57 cx.on_focus_out(&focus_handle, window, |this: &mut Self, _, window, cx| {
58 this.hide_scrollbars(window, cx);
59 })
60 .detach();
61
62 let scroll_handle = UniformListScrollHandle::new();
63 let vertical_scrollbar = ScrollbarProperties {
64 axis: Axis::Vertical,
65 state: ScrollbarState::new(scroll_handle.clone()).parent_entity(&cx.entity()),
66 show_scrollbar: false,
67 show_track: false,
68 auto_hide: false,
69 hide_task: None,
70 };
71
72 let horizontal_scrollbar = ScrollbarProperties {
73 axis: Axis::Horizontal,
74 state: ScrollbarState::new(scroll_handle.clone()).parent_entity(&cx.entity()),
75 show_scrollbar: false,
76 show_track: false,
77 auto_hide: false,
78 hide_task: None,
79 };
80
81 let mut this = Self {
82 focus_handle,
83 scroll_handle,
84 horizontal_scrollbar,
85 vertical_scrollbar,
86 };
87
88 this.update_scrollbar_visibility(cx);
89 this
90 })
91 }
92
93 fn update_scrollbar_visibility(&mut self, cx: &mut Context<Self>) {
94 let show_setting = EditorSettings::get_global(cx).scrollbar.show;
95
96 let scroll_handle = self.scroll_handle.0.borrow();
97
98 let autohide = |show: ShowScrollbar, cx: &mut Context<Self>| match show {
99 ShowScrollbar::Auto => true,
100 ShowScrollbar::System => cx
101 .try_global::<ScrollbarAutoHide>()
102 .map_or_else(|| cx.should_auto_hide_scrollbars(), |autohide| autohide.0),
103 ShowScrollbar::Always => false,
104 ShowScrollbar::Never => false,
105 };
106
107 let longest_item_width = scroll_handle.last_item_size.and_then(|size| {
108 (size.contents.width > size.item.width).then_some(size.contents.width)
109 });
110
111 // is there an item long enough that we should show a horizontal scrollbar?
112 let item_wider_than_container = if let Some(longest_item_width) = longest_item_width {
113 longest_item_width > px(scroll_handle.base_handle.bounds().size.width.0)
114 } else {
115 true
116 };
117
118 let show_scrollbar = match show_setting {
119 ShowScrollbar::Auto | ShowScrollbar::System | ShowScrollbar::Always => true,
120 ShowScrollbar::Never => false,
121 };
122 let show_vertical = show_scrollbar;
123
124 let show_horizontal = item_wider_than_container && show_scrollbar;
125
126 let show_horizontal_track =
127 show_horizontal && matches!(show_setting, ShowScrollbar::Always);
128
129 // TODO: we probably should hide the scroll track when the list doesn't need to scroll
130 let show_vertical_track = show_vertical && matches!(show_setting, ShowScrollbar::Always);
131
132 self.vertical_scrollbar = ScrollbarProperties {
133 axis: self.vertical_scrollbar.axis,
134 state: self.vertical_scrollbar.state.clone(),
135 show_scrollbar: show_vertical,
136 show_track: show_vertical_track,
137 auto_hide: autohide(show_setting, cx),
138 hide_task: None,
139 };
140
141 self.horizontal_scrollbar = ScrollbarProperties {
142 axis: self.horizontal_scrollbar.axis,
143 state: self.horizontal_scrollbar.state.clone(),
144 show_scrollbar: show_horizontal,
145 show_track: show_horizontal_track,
146 auto_hide: autohide(show_setting, cx),
147 hide_task: None,
148 };
149
150 cx.notify();
151 }
152
153 fn hide_scrollbars(&mut self, window: &mut Window, cx: &mut Context<Self>) {
154 self.horizontal_scrollbar.hide(window, cx);
155 self.vertical_scrollbar.hide(window, cx);
156 }
157
158 // fn listener(this: Entity<Self>, fn: F) ->
159
160 pub fn listener<E: ?Sized>(
161 this: &Entity<Self>,
162 f: impl Fn(&mut Self, &E, &mut Window, &mut Context<Self>) + 'static,
163 ) -> impl Fn(&E, &mut Window, &mut App) + 'static {
164 let view = this.downgrade();
165 move |e: &E, window: &mut Window, cx: &mut App| {
166 view.update(cx, |view, cx| f(view, e, window, cx)).ok();
167 }
168 }
169
170 fn render_vertical_scrollbar_track(
171 this: &Entity<Self>,
172 parent: Div,
173 scroll_track_size: Pixels,
174 cx: &mut App,
175 ) -> Div {
176 if !this.read(cx).vertical_scrollbar.show_track {
177 return parent;
178 }
179 let child = v_flex()
180 .h_full()
181 .flex_none()
182 .w(scroll_track_size)
183 .bg(cx.theme().colors().background)
184 .child(
185 div()
186 .size_full()
187 .flex_1()
188 .border_l_1()
189 .border_color(cx.theme().colors().border),
190 );
191 parent.child(child)
192 }
193
194 fn render_vertical_scrollbar(this: &Entity<Self>, parent: Div, cx: &mut App) -> Div {
195 if !this.read(cx).vertical_scrollbar.show_scrollbar {
196 return parent;
197 }
198 let child = div()
199 .id("keymap-editor-vertical-scroll")
200 .occlude()
201 .flex_none()
202 .h_full()
203 .cursor_default()
204 .absolute()
205 .right_0()
206 .top_0()
207 .bottom_0()
208 .w(px(12.))
209 .on_mouse_move(Self::listener(this, |_, _, _, cx| {
210 cx.notify();
211 cx.stop_propagation()
212 }))
213 .on_hover(|_, _, cx| {
214 cx.stop_propagation();
215 })
216 .on_mouse_up(
217 MouseButton::Left,
218 Self::listener(this, |this, _, window, cx| {
219 if !this.vertical_scrollbar.state.is_dragging()
220 && !this.focus_handle.contains_focused(window, cx)
221 {
222 this.vertical_scrollbar.hide(window, cx);
223 cx.notify();
224 }
225
226 cx.stop_propagation();
227 }),
228 )
229 .on_any_mouse_down(|_, _, cx| {
230 cx.stop_propagation();
231 })
232 .on_scroll_wheel(Self::listener(&this, |_, _, _, cx| {
233 cx.notify();
234 }))
235 .children(Scrollbar::vertical(
236 this.read(cx).vertical_scrollbar.state.clone(),
237 ));
238 parent.child(child)
239 }
240
241 /// Renders the horizontal scrollbar.
242 ///
243 /// The right offset is used to determine how far to the right the
244 /// scrollbar should extend to, useful for ensuring it doesn't collide
245 /// with the vertical scrollbar when visible.
246 fn render_horizontal_scrollbar(
247 this: &Entity<Self>,
248 parent: Stateful<Div>,
249 right_offset: Pixels,
250 cx: &mut App,
251 ) -> Stateful<Div> {
252 if !this.read(cx).horizontal_scrollbar.show_scrollbar {
253 return parent;
254 }
255 let child = div()
256 .id("keymap-editor-horizontal-scroll")
257 .occlude()
258 .flex_none()
259 .w_full()
260 .cursor_default()
261 .absolute()
262 .bottom_neg_px()
263 .left_0()
264 .right_0()
265 .pr(right_offset)
266 .on_mouse_move(Self::listener(this, |_, _, _, cx| {
267 cx.notify();
268 cx.stop_propagation()
269 }))
270 .on_hover(|_, _, cx| {
271 cx.stop_propagation();
272 })
273 .on_any_mouse_down(|_, _, cx| {
274 cx.stop_propagation();
275 })
276 .on_mouse_up(
277 MouseButton::Left,
278 Self::listener(this, |this, _, window, cx| {
279 if !this.horizontal_scrollbar.state.is_dragging()
280 && !this.focus_handle.contains_focused(window, cx)
281 {
282 this.horizontal_scrollbar.hide(window, cx);
283 cx.notify();
284 }
285
286 cx.stop_propagation();
287 }),
288 )
289 .on_scroll_wheel(Self::listener(this, |_, _, _, cx| {
290 cx.notify();
291 }))
292 .children(Scrollbar::horizontal(
293 // percentage as f32..end_offset as f32,
294 this.read(cx).horizontal_scrollbar.state.clone(),
295 ));
296 parent.child(child)
297 }
298
299 fn render_horizantal_scrollbar_track(
300 this: &Entity<Self>,
301 parent: Stateful<Div>,
302 scroll_track_size: Pixels,
303 cx: &mut App,
304 ) -> Stateful<Div> {
305 if !this.read(cx).horizontal_scrollbar.show_track {
306 return parent;
307 }
308 let child = h_flex()
309 .w_full()
310 .h(scroll_track_size)
311 .flex_none()
312 .relative()
313 .child(
314 div()
315 .w_full()
316 .flex_1()
317 // for some reason the horizontal scrollbar is 1px
318 // taller than the vertical scrollbar??
319 .h(scroll_track_size - px(1.))
320 .bg(cx.theme().colors().background)
321 .border_t_1()
322 .border_color(cx.theme().colors().border),
323 )
324 .when(this.read(cx).vertical_scrollbar.show_track, |parent| {
325 parent
326 .child(
327 div()
328 .flex_none()
329 // -1px prevents a missing pixel between the two container borders
330 .w(scroll_track_size - px(1.))
331 .h_full(),
332 )
333 .child(
334 // HACK: Fill the missing 1px 🥲
335 div()
336 .absolute()
337 .right(scroll_track_size - px(1.))
338 .bottom(scroll_track_size - px(1.))
339 .size_px()
340 .bg(cx.theme().colors().border),
341 )
342 });
343
344 parent.child(child)
345 }
346}
347
348/// A table component
349#[derive(RegisterComponent, IntoElement)]
350pub struct Table<const COLS: usize = 3> {
351 striped: bool,
352 width: Length,
353 headers: Option<[AnyElement; COLS]>,
354 rows: TableContents<COLS>,
355 interaction_state: Option<WeakEntity<TableInteractionState>>,
356 column_widths: Option<[Length; COLS]>,
357}
358
359impl<const COLS: usize> Table<COLS> {
360 /// number of headers provided.
361 pub fn new() -> Self {
362 Table {
363 striped: false,
364 width: Length::Auto,
365 headers: None,
366 rows: TableContents::Vec(Vec::new()),
367 interaction_state: None,
368 column_widths: None,
369 }
370 }
371
372 /// Enables uniform list rendering.
373 /// The provided function will be passed directly to the `uniform_list` element.
374 /// Therefore, if this method is called, any calls to [`Table::row`] before or after
375 /// this method is called will be ignored.
376 pub fn uniform_list(
377 mut self,
378 id: impl Into<ElementId>,
379 row_count: usize,
380 render_item_fn: impl Fn(Range<usize>, &mut Window, &mut App) -> Vec<[AnyElement; COLS]>
381 + 'static,
382 ) -> Self {
383 self.rows = TableContents::UniformList(UniformListData {
384 element_id: id.into(),
385 row_count: row_count,
386 render_item_fn: Box::new(render_item_fn),
387 });
388 self
389 }
390
391 /// Enables row striping.
392 pub fn striped(mut self) -> Self {
393 self.striped = true;
394 self
395 }
396
397 /// Sets the width of the table.
398 pub fn width(mut self, width: impl Into<Length>) -> Self {
399 self.width = width.into();
400 self
401 }
402
403 pub fn interactable(mut self, interaction_state: &Entity<TableInteractionState>) -> Self {
404 self.interaction_state = Some(interaction_state.downgrade());
405 self
406 }
407
408 pub fn header(mut self, headers: [impl IntoElement; COLS]) -> Self {
409 self.headers = Some(headers.map(IntoElement::into_any_element));
410 self
411 }
412
413 pub fn row(mut self, items: [impl IntoElement; COLS]) -> Self {
414 if let Some(rows) = self.rows.rows_mut() {
415 rows.push(items.map(IntoElement::into_any_element));
416 }
417 self
418 }
419
420 pub fn column_widths(mut self, widths: [impl Into<Length>; COLS]) -> Self {
421 self.column_widths = Some(widths.map(Into::into));
422 self
423 }
424}
425
426fn base_cell_style(width: Option<Length>, cx: &App) -> Div {
427 div()
428 .px_1p5()
429 .when_some(width, |this, width| this.w(width))
430 .when(width.is_none(), |this| this.flex_1())
431 .justify_start()
432 .text_ui(cx)
433 .whitespace_nowrap()
434 .text_ellipsis()
435 .overflow_hidden()
436}
437
438pub fn render_row<const COLS: usize>(
439 row_index: usize,
440 items: [impl IntoElement; COLS],
441 table_context: TableRenderContext<COLS>,
442 cx: &App,
443) -> AnyElement {
444 let is_last = row_index == table_context.total_row_count - 1;
445 let bg = if row_index % 2 == 1 && table_context.striped {
446 Some(cx.theme().colors().text.opacity(0.05))
447 } else {
448 None
449 };
450 let column_widths = table_context
451 .column_widths
452 .map_or([None; COLS], |widths| widths.map(|width| Some(width)));
453 div()
454 .w_full()
455 .flex()
456 .flex_row()
457 .items_center()
458 .justify_between()
459 .px_1p5()
460 .py_1()
461 .when_some(bg, |row, bg| row.bg(bg))
462 .when(!is_last, |row| {
463 row.border_b_1().border_color(cx.theme().colors().border)
464 })
465 .children(
466 items
467 .map(IntoElement::into_any_element)
468 .into_iter()
469 .zip(column_widths)
470 .map(|(cell, width)| base_cell_style(width, cx).child(cell)),
471 )
472 .into_any_element()
473}
474
475pub fn render_header<const COLS: usize>(
476 headers: [impl IntoElement; COLS],
477 table_context: TableRenderContext<COLS>,
478 cx: &mut App,
479) -> impl IntoElement {
480 let column_widths = table_context
481 .column_widths
482 .map_or([None; COLS], |widths| widths.map(|width| Some(width)));
483 div()
484 .flex()
485 .flex_row()
486 .items_center()
487 .justify_between()
488 .w_full()
489 .p_2()
490 .border_b_1()
491 .border_color(cx.theme().colors().border)
492 .children(headers.into_iter().zip(column_widths).map(|(h, width)| {
493 base_cell_style(width, cx)
494 .font_weight(FontWeight::SEMIBOLD)
495 .child(h)
496 }))
497}
498
499#[derive(Clone, Copy)]
500pub struct TableRenderContext<const COLS: usize> {
501 pub striped: bool,
502 pub total_row_count: usize,
503 pub column_widths: Option<[Length; COLS]>,
504}
505
506impl<const COLS: usize> TableRenderContext<COLS> {
507 fn new(table: &Table<COLS>) -> Self {
508 Self {
509 striped: table.striped,
510 total_row_count: table.rows.len(),
511 column_widths: table.column_widths,
512 }
513 }
514}
515
516impl<const COLS: usize> RenderOnce for Table<COLS> {
517 fn render(mut self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
518 // match self.ro
519 let table_context = TableRenderContext::new(&self);
520 let interaction_state = self.interaction_state.and_then(|state| state.upgrade());
521
522 let scroll_track_size = px(16.);
523 let h_scroll_offset = if interaction_state
524 .as_ref()
525 .is_some_and(|state| state.read(cx).vertical_scrollbar.show_scrollbar)
526 {
527 // magic number
528 px(3.)
529 } else {
530 px(0.)
531 };
532
533 div()
534 .id("todo! how to have id")
535 .w(self.width)
536 .h_full()
537 .v_flex()
538 .when_some(interaction_state.as_ref(), |this, interaction_state| {
539 this.track_focus(&interaction_state.read(cx).focus_handle)
540 .on_hover({
541 let interaction_state = interaction_state.downgrade();
542 move |hovered, window, cx| {
543 interaction_state
544 .update(cx, |interaction_state, cx| {
545 if *hovered {
546 interaction_state.horizontal_scrollbar.show(cx);
547 interaction_state.vertical_scrollbar.show(cx);
548 cx.notify();
549 } else if !interaction_state
550 .focus_handle
551 .contains_focused(window, cx)
552 {
553 interaction_state.hide_scrollbars(window, cx);
554 }
555 })
556 .ok(); // todo! handle error?
557 }
558 })
559 })
560 .when_some(self.headers.take(), |this, headers| {
561 this.child(render_header(headers, table_context, cx))
562 })
563 .child(
564 div()
565 .flex_grow()
566 .w_full()
567 .relative()
568 .overflow_hidden()
569 .map(|parent| match self.rows {
570 TableContents::Vec(items) => parent.children(
571 items
572 .into_iter()
573 .enumerate()
574 .map(|(index, row)| render_row(index, row, table_context, cx)),
575 ),
576 TableContents::UniformList(uniform_list_data) => parent.child(
577 uniform_list(
578 uniform_list_data.element_id,
579 uniform_list_data.row_count,
580 {
581 let render_item_fn = uniform_list_data.render_item_fn;
582 move |range: Range<usize>, window, cx| {
583 let elements = render_item_fn(range.clone(), window, cx);
584 elements
585 .into_iter()
586 .zip(range)
587 .map(|(row, row_index)| {
588 render_row(row_index, row, table_context, cx)
589 })
590 .collect()
591 }
592 },
593 )
594 .size_full()
595 .flex_grow()
596 .with_sizing_behavior(ListSizingBehavior::Auto)
597 .with_horizontal_sizing_behavior(
598 ListHorizontalSizingBehavior::Unconstrained,
599 )
600 .when_some(
601 interaction_state.as_ref(),
602 |this, state| {
603 this.track_scroll(
604 state.read_with(cx, |s, _| s.scroll_handle.clone()),
605 )
606 },
607 ),
608 ),
609 })
610 .when_some(interaction_state.as_ref(), |this, interaction_state| {
611 this.map(|this| {
612 TableInteractionState::render_vertical_scrollbar_track(
613 interaction_state,
614 this,
615 scroll_track_size,
616 cx,
617 )
618 })
619 .map(|this| {
620 TableInteractionState::render_vertical_scrollbar(
621 interaction_state,
622 this,
623 cx,
624 )
625 })
626 }),
627 )
628 .when_some(interaction_state.as_ref(), |this, interaction_state| {
629 this.map(|this| {
630 TableInteractionState::render_horizantal_scrollbar_track(
631 interaction_state,
632 this,
633 scroll_track_size,
634 cx,
635 )
636 })
637 .map(|this| {
638 TableInteractionState::render_horizontal_scrollbar(
639 interaction_state,
640 this,
641 h_scroll_offset,
642 cx,
643 )
644 })
645 })
646 }
647}
648
649// computed state related to how to render scrollbars
650// one per axis
651// on render we just read this off the keymap editor
652// we update it when
653// - settings change
654// - on focus in, on focus out, on hover, etc.
655#[derive(Debug)]
656pub struct ScrollbarProperties {
657 axis: Axis,
658 show_scrollbar: bool,
659 show_track: bool,
660 auto_hide: bool,
661 hide_task: Option<Task<()>>,
662 state: ScrollbarState,
663}
664
665impl ScrollbarProperties {
666 // Shows the scrollbar and cancels any pending hide task
667 fn show(&mut self, cx: &mut Context<TableInteractionState>) {
668 if !self.auto_hide {
669 return;
670 }
671 self.show_scrollbar = true;
672 self.hide_task.take();
673 cx.notify();
674 }
675
676 fn hide(&mut self, window: &mut Window, cx: &mut Context<TableInteractionState>) {
677 const SCROLLBAR_SHOW_INTERVAL: Duration = Duration::from_secs(1);
678
679 if !self.auto_hide {
680 return;
681 }
682
683 let axis = self.axis;
684 self.hide_task = Some(cx.spawn_in(window, async move |keymap_editor, cx| {
685 cx.background_executor()
686 .timer(SCROLLBAR_SHOW_INTERVAL)
687 .await;
688
689 if let Some(keymap_editor) = keymap_editor.upgrade() {
690 keymap_editor
691 .update(cx, |keymap_editor, cx| {
692 match axis {
693 Axis::Vertical => {
694 keymap_editor.vertical_scrollbar.show_scrollbar = false
695 }
696 Axis::Horizontal => {
697 keymap_editor.horizontal_scrollbar.show_scrollbar = false
698 }
699 }
700 cx.notify();
701 })
702 .ok();
703 }
704 }));
705 }
706}
707
708impl Component for Table<3> {
709 fn scope() -> ComponentScope {
710 ComponentScope::Layout
711 }
712
713 fn description() -> Option<&'static str> {
714 Some("A table component for displaying data in rows and columns with optional styling.")
715 }
716
717 fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
718 Some(
719 v_flex()
720 .gap_6()
721 .children(vec![
722 example_group_with_title(
723 "Basic Tables",
724 vec![
725 single_example(
726 "Simple Table",
727 Table::new()
728 .width(px(400.))
729 .header(["Name", "Age", "City"])
730 .row(["Alice", "28", "New York"])
731 .row(["Bob", "32", "San Francisco"])
732 .row(["Charlie", "25", "London"])
733 .into_any_element(),
734 ),
735 single_example(
736 "Two Column Table",
737 Table::new()
738 .header(["Category", "Value"])
739 .width(px(300.))
740 .row(["Revenue", "$100,000"])
741 .row(["Expenses", "$75,000"])
742 .row(["Profit", "$25,000"])
743 .into_any_element(),
744 ),
745 ],
746 ),
747 example_group_with_title(
748 "Styled Tables",
749 vec![
750 single_example(
751 "Default",
752 Table::new()
753 .width(px(400.))
754 .header(["Product", "Price", "Stock"])
755 .row(["Laptop", "$999", "In Stock"])
756 .row(["Phone", "$599", "Low Stock"])
757 .row(["Tablet", "$399", "Out of Stock"])
758 .into_any_element(),
759 ),
760 single_example(
761 "Striped",
762 Table::new()
763 .width(px(400.))
764 .striped()
765 .header(["Product", "Price", "Stock"])
766 .row(["Laptop", "$999", "In Stock"])
767 .row(["Phone", "$599", "Low Stock"])
768 .row(["Tablet", "$399", "Out of Stock"])
769 .row(["Headphones", "$199", "In Stock"])
770 .into_any_element(),
771 ),
772 ],
773 ),
774 example_group_with_title(
775 "Mixed Content Table",
776 vec![single_example(
777 "Table with Elements",
778 Table::new()
779 .width(px(840.))
780 .header(["Status", "Name", "Priority", "Deadline", "Action"])
781 .row([
782 Indicator::dot().color(Color::Success).into_any_element(),
783 "Project A".into_any_element(),
784 "High".into_any_element(),
785 "2023-12-31".into_any_element(),
786 Button::new("view_a", "View")
787 .style(ButtonStyle::Filled)
788 .full_width()
789 .into_any_element(),
790 ])
791 .row([
792 Indicator::dot().color(Color::Warning).into_any_element(),
793 "Project B".into_any_element(),
794 "Medium".into_any_element(),
795 "2024-03-15".into_any_element(),
796 Button::new("view_b", "View")
797 .style(ButtonStyle::Filled)
798 .full_width()
799 .into_any_element(),
800 ])
801 .row([
802 Indicator::dot().color(Color::Error).into_any_element(),
803 "Project C".into_any_element(),
804 "Low".into_any_element(),
805 "2024-06-30".into_any_element(),
806 Button::new("view_c", "View")
807 .style(ButtonStyle::Filled)
808 .full_width()
809 .into_any_element(),
810 ])
811 .into_any_element(),
812 )],
813 ),
814 ])
815 .into_any_element(),
816 )
817 }
818}