|
1 | | -use leptos::{html::*, *}; |
| 1 | +use leptos::*; |
2 | 2 | use leptos_icons::*; |
3 | 3 |
|
4 | 4 | use crate::{enums::QueryTableLayout, store::active_project::ActiveProjectStore}; |
5 | 5 |
|
6 | | -pub fn component() -> impl IntoView { |
| 6 | +#[component] |
| 7 | +pub fn Footer() -> impl IntoView { |
7 | 8 | let table_view = use_context::<RwSignal<QueryTableLayout>>().unwrap(); |
8 | 9 | let acitve_project = use_context::<ActiveProjectStore>().unwrap(); |
9 | 10 | let sql_timer = use_context::<RwSignal<f32>>().unwrap(); |
10 | 11 | let formatted_timer = create_memo(move |_| format!("Query complete: {}ms", sql_timer.get())); |
11 | 12 |
|
12 | | - footer() |
13 | | - .classes("flex flex-row justify-between items-center h-10 bg-gray-50 px-4") |
14 | | - .child( |
15 | | - div() |
16 | | - .classes("flex flex-row gap-2 text-xs") |
17 | | - .child(Show(ShowProps { |
18 | | - children: ChildrenFn::to_children(move || { |
19 | | - Fragment::new(vec![div() |
20 | | - .classes("flex flex-row items-center gap-1") |
21 | | - .child(p().child("Selected project:")) |
22 | | - .child( |
23 | | - p() |
24 | | - .classes("font-semibold") |
25 | | - .child(move || acitve_project.0.get()), |
26 | | - ) |
27 | | - .into_view()]) |
28 | | - }), |
29 | | - when: move || acitve_project.0.get().is_some(), |
30 | | - fallback: ViewFn::from(div), |
31 | | - })), |
32 | | - ) |
33 | | - .child( |
34 | | - div() |
35 | | - .classes("flex flex-row gap-1 items-center text-xs") |
36 | | - .child(p().child(formatted_timer)) |
37 | | - .child( |
38 | | - button() |
39 | | - .classes("p-1 hover:bg-gray-300 rounded-full") |
40 | | - .class("bg-gray-300", move || { |
41 | | - table_view() == QueryTableLayout::Records |
42 | | - }) |
43 | | - .on(ev::click, move |_| { |
44 | | - table_view.set(QueryTableLayout::Records) |
45 | | - }) |
46 | | - .child(Icon(IconProps { |
47 | | - icon: MaybeSignal::Static(icondata::HiBars4OutlineLg), |
48 | | - width: MaybeProp::from(String::from("16")), |
49 | | - height: MaybeProp::from(String::from("16")), |
50 | | - class: MaybeProp::default(), |
51 | | - style: MaybeProp::default(), |
52 | | - })), |
53 | | - ) |
54 | | - .child( |
55 | | - button() |
56 | | - .classes("p-1 hover:bg-gray-300 rounded-full") |
57 | | - .class("bg-gray-300", move || { |
58 | | - table_view() == QueryTableLayout::Grid |
59 | | - }) |
60 | | - .on(ev::click, move |_| table_view.set(QueryTableLayout::Grid)) |
61 | | - .child(Icon(IconProps { |
62 | | - icon: MaybeSignal::Static(icondata::HiTableCellsOutlineLg), |
63 | | - width: MaybeProp::from(String::from("16")), |
64 | | - height: MaybeProp::from(String::from("16")), |
65 | | - class: MaybeProp::default(), |
66 | | - style: MaybeProp::default(), |
67 | | - })), |
68 | | - ), |
69 | | - ) |
| 13 | + view! { |
| 14 | + <footer class="flex flex-row justify-between items-center h-10 bg-gray-50 px-4"> |
| 15 | + <div class="flex flex-row gap-2 text-xs"> |
| 16 | + <Show when=move || acitve_project.0.get().is_some() fallback=|| view! { <div></div> }> |
| 17 | + <div class="flex flex-row items-center gap-1"> |
| 18 | + <p>Selected project:</p> |
| 19 | + <p class="font-semibold">{move || acitve_project.0.get()}</p> |
| 20 | + </div> |
| 21 | + </Show> |
| 22 | + </div> |
| 23 | + <div class="flex flex-row gap-1 items-center text-xs"> |
| 24 | + <p>{formatted_timer}</p> |
| 25 | + <button |
| 26 | + class=if table_view() == QueryTableLayout::Records { |
| 27 | + "p-1 hover:bg-gray-300 rounded-full bg-gray-300" |
| 28 | + } else { |
| 29 | + "p-1 hover:bg-gray-300 rounded-full" |
| 30 | + } |
| 31 | + |
| 32 | + on:click=move |_| table_view.set(QueryTableLayout::Records) |
| 33 | + > |
| 34 | + |
| 35 | + <Icon icon=icondata::HiBars4OutlineLg width="16" height="16"/> |
| 36 | + </button> |
| 37 | + <button |
| 38 | + class=if table_view() == QueryTableLayout::Grid { |
| 39 | + "p-1 hover:bg-gray-300 rounded-full bg-gray-300" |
| 40 | + } else { |
| 41 | + "p-1 hover:bg-gray-300 rounded-full" |
| 42 | + } |
| 43 | + |
| 44 | + on:click=move |_| table_view.set(QueryTableLayout::Grid) |
| 45 | + > |
| 46 | + <Icon icon=icondata::HiTableCellsOutlineLg width="16" height="16"/> |
| 47 | + </button> |
| 48 | + </div> |
| 49 | + </footer> |
| 50 | + } |
70 | 51 | } |
| 52 | + |
0 commit comments