Impulse UI Kit
Frontend framework with shadcn-styled components, based on Leptos v0.8.
Usage
Just include it into your Cargo.toml:
[]
= { = "https://github.com/impulse-sw/impulse-kit.git", = "1.1.0" }
Components and its usage
See the components README.md.
Simple application entrypoint
This is all you need to start Leptos application:
setup_app
setup_app will automatically install given log level, set the panic error hook and initialize logs at console.
[!NOTE] If your project is built at debug mode, logs will be set to
DEBUGlevel automatically.
Automated light/dark theme switch
UI Kit supports automated dark Tailwind class switching and also automated Thaw components styling.
To use automated light/dark theme switch, ensure to build your app on top of this index.html example:
Your title
Router utils
UI Kit exposes impulse_ui_kit::router::endpoint to construct full URL of the backend, if this backend provided your frontend also.
// Let assume that your backend is located at `127.0.0.1:8080` with HTTP schema
endpoint // equals to "http://127.0.0.1:8080/some/api/route"
If you need to go on any other page, use impulse_ui_kit::router::redirect:
redirect
WebSocket and WebTransport
UI Kit ships optional reactive wrappers around the browser WebSocket and WebTransport APIs. They are pulled in via Cargo features and are designed to mirror their server-side counterparts in impulse-server-kit.
WebSocket
Enable the websocket feature:
[]
= { = "https://github.com/impulse-sw/impulse-kit.git", = "1.1.0", = ["websocket"] }
Open a connection and observe state/messages reactively:
use ;
use *;
let ws = use_websocket?;
new;
new;
The connection is closed and event listeners are detached when the last WebSocketHandle clone is dropped.
WebTransport
Enable the webtransport feature:
[]
= { = "https://github.com/impulse-sw/impulse-kit.git", = "1.1.0", = ["webtransport"] }
The browser WebTransport API is gated by web-sys behind --cfg=web_sys_unstable_apis. Add this to your downstream .cargo/config.toml:
[]
= ["--cfg=web_sys_unstable_apis"]
Then:
use ;
use *;
let wt = use_webtransport?;
let datagrams = wt.datagram_signal?;
new;
new;
WebTransportHandle also exposes open_bidirectional_stream() and open_unidirectional_stream() for application-level framing on top of QUIC streams. See wt.rs for the full API.
Some other utils
See utils.rs file.