dioxus_nox_timer/lib.rs
1//! # dioxus-nox-timer
2//!
3//! **⚠️ Disclaimer:** This crate was entirely generated by AI (Claude) as part of a
4//! personal learning project. It has not been battle-tested in production and may
5//! contain bugs or unsound abstractions. Use at your own risk and exercise extreme
6//! caution before depending on it in anything that matters.
7//!
8//! Headless timer primitives for Dioxus applications: countdown and stopwatch hooks.
9//!
10//! ## Features
11//!
12//! - **Wall-clock based** — survives browser tab backgrounding (no `setInterval` drift)
13//! - **Cross-platform** — works on web (wasm32), desktop, iOS, and Android
14//! - **Headless** — no rendered components, just hooks and state machines
15//!
16//! ## Quick start
17//!
18//! ```rust,ignore
19//! use dioxus::prelude::*;
20//! use dioxus_nox_timer::*;
21//!
22//! #[component]
23//! fn RestTimer() -> Element {
24//! let (remaining, state, controls) = use_countdown(None);
25//!
26//! rsx! {
27//! div {
28//! // Recommended ARIA attributes for consumers:
29//! role: "timer",
30//! aria_live: "polite",
31//! "data-timer-state": match *state.read() {
32//! TimerState::Idle => "idle",
33//! TimerState::Running => "running",
34//! TimerState::Paused => "paused",
35//! TimerState::Complete => "complete",
36//! },
37//! p { "{format_duration(*remaining.read())}" }
38//! button { onclick: move |_| controls.start.call(90), "Start 90s" }
39//! button { onclick: move |_| controls.pause.call(()), "Pause" }
40//! button { onclick: move |_| controls.resume.call(()), "Resume" }
41//! }
42//! }
43//! }
44//! ```
45
46mod countdown;
47mod format;
48mod stopwatch;
49pub(crate) mod time;
50mod types;
51
52#[cfg(test)]
53mod tests;
54
55pub use countdown::use_countdown;
56pub use format::format_duration;
57pub use stopwatch::use_stopwatch;
58pub use types::{CountdownControls, TimerState};