Skip to content

Commit ef3e50d

Browse files
committed
chore: clippy and cleanup
1 parent 6f9d1c4 commit ef3e50d

4 files changed

Lines changed: 37 additions & 27 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repository = "https://github.com/Synphonyte/leptos-struct-table"
1313

1414
[dependencies]
1515
leptos = { version = "0.7.0" }
16-
leptos-struct-table-macro = { version = "0.13.0-beta1", path = "../leptos-struct-table-macro" }
16+
leptos-struct-table-macro = { version = "0.13.0-beta2", path = "../leptos-struct-table-macro" }
1717
leptos-use = { version = "0.15.2" }
1818
rust_decimal = { version = "1.35", optional = true }
1919
chrono = { version = "0.4", optional = true }

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ for a working project with SSR.
9191

9292
## Data Providers
9393

94-
As shown in the inital usage example, when you add `#[table(impl_vec_data_provider)]` to your struct,
94+
As shown in the initial usage example, when you add `#[table(impl_vec_data_provider)]` to your struct,
9595
the table will automatically generate a data provider for you. You can then directly pass a `Vec<T>` to the `rows` prop.
9696
Internally this implements the trait [`TableDataProvider`] for `Vec<T>`.
9797

@@ -114,33 +114,33 @@ The `#[table(...)]` attribute can be used to customize the generated component.
114114
These attributes can be applied to the struct itself.
115115

116116
- **`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control sorting.
117-
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
118-
- `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
119-
- `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
117+
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
118+
- `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
119+
- `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
120120

121-
See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
122-
[selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
121+
See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
122+
[selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
123123
- **`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.
124-
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
124+
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
125125
- **`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering of header cells. Defaults to [`DefaultTableHeaderRenderer`]. See the [custom_renderers_svg example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs) for more information.
126126
- **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
127-
for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
127+
for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
128128
- **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs) for more information.
129129
- **`i18n`** - Allows to specify the i18n scope for all fields of the struct as well as the `i18n` module path which defaults to `crate::i18n`. See [I18n](#i18n) for more information.
130130

131131
### Field attributes
132132

133133
These attributes can be applied to any field in the struct.
134134

135-
- **`class`** - Specifies the classes that are applied to each cell (head and body) in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
136-
- **`head_class`** - Specifies the classes that are applied to the header cell in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
137-
- **`cell_class`** - Specifies the classes that are applied to the body cells in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
135+
- **`class`** - Specifies the classes that are applied to each cell (head and body) in the field's column. Can be used in conjunction with `classes_provider` to customize the classes.
136+
- **`head_class`** - Specifies the classes that are applied to the header cell in the field's column. Can be used in conjunction with `classes_provider` to customize the classes.
137+
- **`cell_class`** - Specifies the classes that are applied to the body cells in the field's column. Can be used in conjunction with `classes_provider` to customize the classes.
138138
- **`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the table.
139139
- **`skip_sort`** - Only applies if `sortable` is set on the struct. Specifies that the field should not be used for sorting. Clicking it's header will not do anything.
140140
- **`skip_header`** - Makes the title of the field not be displayed in the head row.
141141
- **`title`** - Specifies the title that is displayed in the header cell. Defaults to the field name converted to title case (`this_field` becomes `"This Field"`).
142142
- **`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
143-
Defaults to [`DefaultTableCellRenderer`].
143+
Defaults to [`DefaultTableCellRenderer`].
144144
- **`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
145145
- **`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
146146
- **`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
@@ -165,7 +165,7 @@ See:
165165
## Classes Customization
166166

167167
Classes can be easily customized by using the `classes_provider` attribute on the struct.
168-
You can specify any type that implementats the trait [`TableClassesProvider`]. Please see the documentation for that trait for more information.
168+
You can specify any type that implements the trait [`TableClassesProvider`]. Please see the documentation for that trait for more information.
169169
You can also look at [`TailwindClassesPreset`] for an example how this can be implemented.
170170

171171
Example:
@@ -228,7 +228,7 @@ impl Book {
228228
### When to use `FieldGetter` vs `getter` attribute
229229

230230
A field of type `FieldGetter<T>` is a virtual field that doesn't really exist on the struct.
231-
Internally `FieldGetter` is just a new-typed `PhatomData` and thus is removed during compilation.
231+
Internally `FieldGetter` is just a new-typed `PhantomData` and thus is removed during compilation.
232232
Hence it doesn't increase memory usage. That means you should use it for purely derived data.
233233

234234
The `getter` attribute should be used on a field that actually exists on the struct but whose
@@ -242,7 +242,7 @@ To implement a custom renderer please have a look at the default renderers liste
242242

243243
On the struct level you can use this attribute:
244244
- **`thead_cell_renderer`** - Defaults to [`DefaultTableHeaderCellRenderer`] which renders `<th><span>Title</span></th>`
245-
together with sorting functionality (if enabled).
245+
together with sorting functionality (if enabled).
246246

247247
As props of the [`TableContent`] component you can use the following:
248248
- **`thead_renderer`** - Defaults to [`DefaultTableHeadRenderer`] which just renders the tag `thead`.
@@ -366,4 +366,4 @@ and at the sections [Struct attributes](#struct-attributes) and
366366

367367
All contributions are welcome. Please open an issue or a pull request if you have any ideas or problems.
368368

369-
<!-- cargo-rdme end --> |
369+
<!-- cargo-rdme end -->

src/components/table_content.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ where
433433

434434
if let Some(chunk_size) = DataP::CHUNK_SIZE {
435435
start = (start / chunk_size) * chunk_size;
436-
end = ((end + chunk_size - 1) / chunk_size) * chunk_size; // Round end *up* to nearest chunk size
436+
end = end.div_ceil(chunk_size) * chunk_size; // Round end *up* to nearest chunk size
437437
}
438438

439439
let range = start..end;

src/lib.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
//! }
4646
//! ```
4747
//!
48+
//! # Leptos Compatibility
49+
//!
50+
//! | Crate version | Compatible Leptos version |
51+
//! |---------------|---------------------------|
52+
//! | <= 0.2 | 0.3 |
53+
//! | 0.3 | 0.4 |
54+
//! | 0.4, 0.5, 0.6 | 0.5 |
55+
//! | 0.7 – 0.12 | 0.6 |
56+
//! | 0.14.0-beta2 | 0.7 |
57+
//!
4858
//! # Server-Side Rendering
4959
//!
5060
//! To use this with Leptos' server-side rendering, you can have to add `leptos-use` as a dependency to your `Cargo.toml` and
@@ -95,17 +105,17 @@
95105
//! These attributes can be applied to the struct itself.
96106
//!
97107
//! - **`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control sorting.
98-
//! You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
99-
//! - `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
100-
//! - `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
108+
//! You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
109+
//! - `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
110+
//! - `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
101111
//!
102-
//! See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
103-
//! [selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
112+
//! See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
113+
//! [selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
104114
//! - **`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.
105-
//! For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
115+
//! For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
106116
//! - **`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering of header cells. Defaults to [`DefaultTableHeaderRenderer`]. See the [custom_renderers_svg example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs) for more information.
107117
//! - **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
108-
//! for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
118+
//! for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
109119
//! - **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs) for more information.
110120
//! - **`i18n`** - Allows to specify the i18n scope for all fields of the struct as well as the `i18n` module path which defaults to `crate::i18n`. See [I18n](#i18n) for more information.
111121
//!
@@ -121,7 +131,7 @@
121131
//! - **`skip_header`** - Makes the title of the field not be displayed in the head row.
122132
//! - **`title`** - Specifies the title that is displayed in the header cell. Defaults to the field name converted to title case (`this_field` becomes `"This Field"`).
123133
//! - **`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
124-
//! Defaults to [`DefaultTableCellRenderer`].
134+
//! Defaults to [`DefaultTableCellRenderer`].
125135
//! - **`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
126136
//! - **`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
127137
//! - **`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
@@ -259,7 +269,7 @@ pub struct TemperatureMeasurement {
259269
//!
260270
//! On the struct level you can use this attribute:
261271
//! - **`thead_cell_renderer`** - Defaults to [`DefaultTableHeaderCellRenderer`] which renders `<th><span>Title</span></th>`
262-
//! together with sorting functionality (if enabled).
272+
//! together with sorting functionality (if enabled).
263273
//!
264274
//! As props of the [`TableContent`] component you can use the following:
265275
//! - **`thead_renderer`** - Defaults to [`DefaultTableHeadRenderer`] which just renders the tag `thead`.

0 commit comments

Comments
 (0)