diff --git a/frontend/src/components/torrent/table.rs b/frontend/src/components/torrent/table.rs index a9f7a7b..26aec13 100644 --- a/frontend/src/components/torrent/table.rs +++ b/frontend/src/components/torrent/table.rs @@ -5,7 +5,7 @@ use crate::api; use shared::NotificationLevel; use crate::components::context_menu::TorrentContextMenu; use crate::components::ui::card::{Card, CardHeader, CardTitle, CardContent as CardBody}; -use crate::components::ui::table::*; +use crate::components::ui::data_table::*; fn format_bytes(bytes: i64) -> String { const UNITS: [&str; 6] = ["B", "KB", "MB", "GB", "TB", "PB"]; @@ -136,38 +136,38 @@ pub fn TorrentTable() -> impl IntoView {
// --- DESKTOP VIEW --- // --- MOBILE VIEW --- @@ -232,41 +232,41 @@ fn TorrentRow( view! { - - + {t_name_for_content} - - + + {format_bytes(t.size)} - - + +
{format!("{:.1}%", t.percent_complete)}
-
- + + {format!("{:?}", t.status)} - - + + {format_speed(t.down_rate)} - - + + {format_speed(t.up_rate)} - - + + {format_duration(t.eta)} - - + + {format_date(t.added_date)} - -
+ +
}.into_any() } @@ -342,4 +342,4 @@ fn TorrentCard( } }.into_any() -} +} \ No newline at end of file diff --git a/frontend/src/components/ui/data_table.rs b/frontend/src/components/ui/data_table.rs new file mode 100644 index 0000000..25a6407 --- /dev/null +++ b/frontend/src/components/ui/data_table.rs @@ -0,0 +1,6 @@ +// * Reuse @table.rs +pub use crate::components::ui::table::{ + Table as DataTable, TableBody as DataTableBody, TableCaption as DataTableCaption, TableCell as DataTableCell, + TableFooter as DataTableFooter, TableHead as DataTableHead, TableHeader as DataTableHeader, + TableRow as DataTableRow, TableWrapper as DataTableWrapper, +}; \ No newline at end of file diff --git a/frontend/src/components/ui/mod.rs b/frontend/src/components/ui/mod.rs index 567ef02..0c95971 100644 --- a/frontend/src/components/ui/mod.rs +++ b/frontend/src/components/ui/mod.rs @@ -5,4 +5,6 @@ pub mod toast; pub mod context_menu; pub mod theme_toggle; pub mod svg_icon; -pub mod table; \ No newline at end of file +pub mod table; +pub mod data_table; +pub mod sonner; \ No newline at end of file diff --git a/frontend/src/components/ui/table.rs b/frontend/src/components/ui/table.rs index 9a874ee..92a5beb 100644 --- a/frontend/src/components/ui/table.rs +++ b/frontend/src/components/ui/table.rs @@ -3,19 +3,25 @@ use tw_merge::tw_merge; #[component] pub fn TableWrapper(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { - let class = tw_merge!("overflow-hidden rounded-md border", class); + let class = tw_merge!("overflow-hidden rounded-md border w-full", class); view! {
{children()}
} } #[component] pub fn Table(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { - let class = tw_merge!("w-full text-sm caption-bottom", class); + let class = tw_merge!("w-full text-sm border-collapse", class); view! { {children()}
} } +#[component] +pub fn TableCaption(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { + let class = tw_merge!("mt-4 text-sm text-muted-foreground", class); + view! { {children()} } +} + #[component] pub fn TableHeader(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { - let class = tw_merge!("[&_tr]:border-b", class); + let class = tw_merge!("[&_tr]:border-b bg-muted/50", class); view! { {children()} } } @@ -27,7 +33,7 @@ pub fn TableRow(children: Children, #[prop(optional, into)] class: String) -> im #[component] pub fn TableHead(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { - let class = tw_merge!("h-10 px-2 text-left align-middle font-medium text-muted-foreground", class); + let class = tw_merge!("h-10 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap", class); view! { {children()} } } @@ -39,6 +45,12 @@ pub fn TableBody(children: Children, #[prop(optional, into)] class: String) -> i #[component] pub fn TableCell(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { - let class = tw_merge!("p-2 align-middle", class); + let class = tw_merge!("p-2 px-4 align-middle", class); view! { {children()} } } + +#[component] +pub fn TableFooter(children: Children, #[prop(optional, into)] class: String) -> impl IntoView { + let class = tw_merge!("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", class); + view! { {children()} } +}