1- use async_trait:: async_trait;
21use chrono:: NaiveDate ;
32use leptos:: * ;
43use leptos_struct_table:: * ;
5- use serde:: { Deserialize , Serialize } ;
64
75// This generates the component BookTable
8- #[ derive( TableComponent , Serialize , Deserialize , Debug , Clone , Default , PartialEq ) ]
9- #[ table( sortable, classes_provider = "BootstrapClassesPreset" ) ]
6+ #[ derive( TableRow , Clone ) ]
7+ #[ table(
8+ sortable,
9+ classes_provider = "BootstrapClassesPreset" ,
10+ impl_vec_data_provider
11+ ) ]
1012pub struct Book {
11- #[ table( key) ]
1213 pub id : u32 ,
1314 pub title : String ,
1415 pub author : String ,
15- // TODO:
16- // #[table(
17- // cell_class = "text-red-600 dark:text-red-400",
18- // head_class = "text-red-700 dark:text-red-300"
19- // )]
2016 pub publish_date : NaiveDate ,
2117}
2218
@@ -25,7 +21,7 @@ fn main() {
2521 console_error_panic_hook:: set_once ( ) ;
2622
2723 mount_to_body ( || {
28- let items = create_rw_signal ( vec ! [
24+ let rows = vec ! [
2925 Book {
3026 id: 1 ,
3127 title: "The Great Gatsby" . to_string( ) ,
@@ -50,11 +46,13 @@ fn main() {
5046 author: "James Joyce" . to_string( ) ,
5147 publish_date: NaiveDate :: from_ymd_opt( 1922 , 2 , 2 ) . unwrap( ) ,
5248 } ,
53- ] ) ;
49+ ] ;
5450
5551 view ! {
5652 <div class="container" . to_string( ) >
57- <BookTable class="table-hover" . to_string( ) items=items />
53+ <table class="table-hover" >
54+ <TableContent rows />
55+ </table>
5856 </div>
5957 }
6058 } )
0 commit comments