1 unstable release
0.1.0 | Apr 24, 2024 |
---|
#4 in #sycamore
6KB
69 lines
🍫 Fracter
Fragment hash based router, for Sycamore
Fracter
trait will be default implemented for Isomorphism
+ Default
+ PartialEq
implemented enum type.
Supports Sycamore version 0.9.0 or later.
Ex
use sycamore::prelude::*;
use fracter::{Fracter, Isomorphism};
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Isomorphism)]
#[isomorphism(list=[Index, Notice, Contact])]
pub enum Fragment {
#[default] Index,
Notice,
Contact
}
#[component]
pub fn App<G: Html>() -> View<G> {
// `init` will handle everything: captures hash change, updates history, etc.
let fragment = Fragment::init();
view! {
main() {
// Use fragment as if router
(match fragment.get() {
Fragment::Notice => view! { "📢 Notice" },
Fragment::Contact => view! { "🔭 Contact" },
_ => view! { "✅ Index" },
})
}
}
}
Dependencies
~13MB
~231K SLoC