-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathmain.rs
More file actions
67 lines (62 loc) · 2.07 KB
/
main.rs
File metadata and controls
67 lines (62 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
mod tailwind;
use chrono::NaiveDate;
use leptos::prelude::*;
use leptos_struct_table::{ColumnSort, TableContent, TableDataProvider, TableRow};
use tailwind::TailwindClassesPreset;
// This generates the component BookTable
#[derive(TableRow, Clone)]
#[table(
sortable,
classes_provider = "TailwindClassesPreset",
impl_vec_data_provider,
column_index_type = "enum"
)]
pub struct Book {
pub id: u32,
pub title: String,
pub author: String,
#[table(
cell_class = "text-red-600 dark:text-red-400",
head_class = "text-red-700 dark:text-red-300"
)]
pub publish_date: NaiveDate,
}
fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| {
let rows = vec![
Book {
id: 1,
title: "The Great Gatsby".to_string(),
author: "F. Scott Fitzgerald".to_string(),
publish_date: NaiveDate::from_ymd_opt(1925, 4, 10).unwrap(),
},
Book {
id: 2,
title: "The Grapes of Wrath".to_string(),
author: "John Steinbeck".to_string(),
publish_date: NaiveDate::from_ymd_opt(1939, 4, 14).unwrap(),
},
Book {
id: 3,
title: "Nineteen Eighty-Four".to_string(),
author: "George Orwell".to_string(),
publish_date: NaiveDate::from_ymd_opt(1949, 6, 8).unwrap(),
},
Book {
id: 4,
title: "Ulysses".to_string(),
author: "James Joyce".to_string(),
publish_date: NaiveDate::from_ymd_opt(1922, 2, 2).unwrap(),
},
];
view! {
<div class="float-left m-10 rounded-md border border-gray-300 dark:border-gray-700 overflow-clip">
<table class="text-sm text-left text-gray-500 dark:text-gray-400 -mb-px">
<TableContent rows=rows scroll_container="" />
</table>
</div>
}
})
}