2023-06-10 19:43:51 +01:00
< br / >
2023-05-26 12:16:47 +01:00
< p align = "center" >
2023-05-31 00:00:41 +01:00
< a href = "https://github.com/synphonyte/leptos-use" >
2023-06-07 18:43:51 +01:00
< img src = "https://raw.githubusercontent.com/synphonyte/leptos-use/main/docs/logo.svg" alt = "Leptos-Use – Collection of essential Leptos utilities" width = "150" / >
2023-05-26 12:16:47 +01:00
< / a >
< / p >
2023-06-07 18:31:46 +01:00
< h4 align = "center" > Collection of essential Leptos utilities< / h4 >
2024-09-25 19:57:07 +01:00
< p align = "center" > Inspired by React-Use / VueUse< / p >
2023-05-26 12:16:47 +01:00
< p align = "center" >
2023-06-10 04:41:24 +01:00
< a href = "https://crates.io/crates/leptos-use" > < img src = "https://img.shields.io/crates/v/leptos-use.svg?label=&color=%232C1275" alt = "Crates.io" / > < / a >
2023-07-14 22:43:19 +01:00
< a href = "https://leptos-use.rs/server_side_rendering.html" > < img src = "https://img.shields.io/badge/-SSR-%236a214b" alt = "SSR" > < / a >
2023-06-10 04:41:24 +01:00
< a href = "https://leptos-use.rs" > < img src = "https://img.shields.io/badge/-docs%20%26%20demos-%239A233F" alt = "Docs & Demos" > < / a >
2024-09-15 20:41:51 +02:00
< a href = "https://leptos-use.rs" > < img src = "https://img.shields.io/badge/-87%20functions-%23EF3939" alt = "87 Functions" / > < / a >
2023-05-26 12:16:47 +01:00
< / p >
2023-06-10 04:41:24 +01:00
< br / >
< br / >
< br / >
2023-06-10 19:15:41 +01:00
## Usage
2023-05-13 23:05:08 +01:00
[![Docs ](https://docs.rs/leptos-use/badge.svg )](https://docs.rs/leptos-use/)
[![MIT/Apache 2.0 ](https://img.shields.io/badge/license-MIT%2FApache-blue.svg )](https://github.com/synphonyte/leptos-use#license )
2024-07-27 19:45:42 +01:00
[![Build Status ](https://github.com/synphonyte/leptos-use/actions/workflows/cd.yml/badge.svg )](https://github.com/synphonyte/leptos-use/actions/workflows/cd.yml)
2023-08-15 16:59:56 +01:00
[![Discord ](https://img.shields.io/discord/1031524867910148188?color=%237289DA&label=discord )](https://discord.com/channels/1031524867910148188/1121154537709895783)
2023-05-13 23:05:08 +01:00
2023-06-10 19:15:41 +01:00
```rust
use leptos::*;
use leptos_use::{use_mouse, UseMouseReturn};
#[component]
2023-07-27 18:06:36 +01:00
fn Demo() -> impl IntoView {
let UseMouseReturn { x, y, .. } = use_mouse();
2023-06-10 19:15:41 +01:00
view! { cx,
{x} " x " {y}
}
}
```
2023-06-09 23:10:33 +01:00
Missing a function? Open a ticket or PR!
## Development
To run all tests run
```shell
cargo test --all-features
```
2023-07-15 16:48:29 +01:00
### Book
2023-06-09 23:10:33 +01:00
First you need to install
```shell
2023-07-11 19:23:43 +02:00
cargo install mdbook mdbook-cmdrun trunk
2023-06-09 23:10:33 +01:00
```
To build the book go in your terminal into the docs/book folder
and run
```shell
mdbook serve
```
2023-06-10 03:19:00 +01:00
2023-06-09 23:10:33 +01:00
This builds the html version of the book and runs a local dev server.
To also add in the examples open another shell and run
```shell
python3 post_build.py
2023-06-10 03:19:00 +01:00
```
If you only want to add the example for one function you can run for example
```shell
2023-07-15 01:14:13 +01:00
python3 post_build.py use_storage
2023-06-16 20:25:01 +01:00
```
### New Function Template
2023-09-30 18:24:06 +01:00
To scaffold a new function quickly you can run `template/createfn.sh` . It requires that [`ffizer` ](https://ffizer.github.io/ ) and Python 3 is installed.
This will create the function file in the src directory, scaffold an example directory and an entry in the book.
2023-07-02 20:52:19 +02:00
## Leptos compatibility
2024-08-28 02:57:26 +01:00
| Crate version | Compatible Leptos version |
|---------------|---------------------------|
| < = 0.3 | 0.3 |
| 0.4, 0.5, 0.6 | 0.4 |
| 0.7, 0.8, 0.9 | 0.5 |
| 0.10 – 0.13 | 0.6 |