Skip to content

naranyala/rigorstd-leptos-wasm-bindgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rigorstd-leptos-wasm-bindgen

A frontend standard library designed for Rust applications using Leptos and wasm-bindgen. This library provides ergonomic, type-safe abstractions over the verbose web-sys API, reducing boilerplate and improving developer experience.

Core Modules

JS Interop

Provides simple wrappers for global browser objects and logging.

  • log, warn, error: Generic logging that works with any Debug type.
  • window, document: Convenient access to global objects.

Storage

Type-safe wrapper around LocalStorage and SessionStorage using Serde.

  • StorageManager: Handles automatic serialization and deserialization.
  • local_storage, session_storage: Quick access functions.

DOM Utilities

Imperative helpers for DOM manipulation that are often needed alongside declarative frameworks.

  • set_focus: Sets focus on an element.
  • add_class, remove_class, toggle_class: Simplified CSS class management.
  • query_selector: Easy access to DOM elements.

HTTP Client

Async wrappers for HTTP requests using gloo-net.

  • get, post: Typed functions that handle JSON deserialization.

Browser APIs

High-level access to modern browser features.

  • Clipboard: Async copy and paste functionality.
  • URL Management: Get and set query parameters without page reloads.
  • Notifications: Simplified permission request and display logic.

Event Management

RAII-based event handling to prevent memory leaks.

  • EventListener: Automatically removes the listener from the target when dropped.
  • on_window: Quick registration for global window events.

Observers

Simplified wrappers for browser observation APIs.

  • IntersectionObserverHandle: Clean interface for lazy-loading and visibility tracking.

State Integration

Bridges between Leptos signals and browser persistence.

  • create_persistent_signal: A signal that automatically syncs its value with LocalStorage.

Utilities

General purpose frontend helpers.

  • debounce: Prevents rapid function execution.
  • truncate, capitalize: String manipulation utilities.

Usage

Add the library to your dependencies and use the prelude for immediate access to all utilities.

use rigorstd_leptos_wasm_bindgen::prelude::*;

// Example: Persistent state
let (name, set_name) = create_persistent_signal("user_name", "Guest".to_string());

// Example: Imperative DOM
if let Some(el) = query_selector("#input-field") {
    set_focus(&el);
}

About

A frontend standard library designed for Rust applications using Leptos and wasm-bindgen. This library provides ergonomic, type-safe abstractions over the verbose web-sys API, reducing boilerplate and improving developer experience.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages