fix CI
This commit is contained in:
1 parent
577f99e68c
commit
a9307e57e6
23 files changed
+160
-164
No files matched your search
@@ -29,9 +29,9 @@ fn app(cx: Scope) -> Element {
|
|||||||
render! {
|
render! {
|
||||||
Router {
|
Router {
|
||||||
config: || RouterConfig::default().on_update(|state|{
|
config: || RouterConfig::default().on_update(|state|{
|
||||||
(state.current() == Route::Index {}).then(|| {
|
(state.current() == Route::Index {}).then_some(
|
||||||
NavigationTarget::Internal(Route::Home {})
|
NavigationTarget::Internal(Route::Home {})
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-32
@@ -1,8 +1,5 @@
|
|||||||
//! Tiny CRM: A port of the Yew CRM example to Dioxus.
|
//! Tiny CRM: A port of the Yew CRM example to Dioxus.
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
|
|
||||||
@@ -10,6 +7,17 @@ fn main() {
|
|||||||
dioxus_desktop::launch(App);
|
dioxus_desktop::launch(App);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Routable, Clone)]
|
||||||
|
#[rustfmt::skip]
|
||||||
|
enum Route {
|
||||||
|
#[route("/")]
|
||||||
|
ClientList {},
|
||||||
|
#[route("/new")]
|
||||||
|
ClientAdd {},
|
||||||
|
#[route("/settings")]
|
||||||
|
Settings {},
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
pub first_name: String,
|
pub first_name: String,
|
||||||
@@ -17,22 +25,10 @@ pub struct Client {
|
|||||||
pub description: String,
|
pub description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientContext = Arc<Mutex<Vec<Client>>>;
|
type ClientContext = Vec<Client>;
|
||||||
|
|
||||||
fn App(cx: Scope) -> Element {
|
fn App(cx: Scope) -> Element {
|
||||||
use_router(cx, &RouterConfiguration::default, &|| {
|
use_shared_state_provider::<ClientContext>(cx, Default::default);
|
||||||
Segment::content(comp(ClientList))
|
|
||||||
.fixed(
|
|
||||||
"new",
|
|
||||||
Route::content(comp(ClientAdd)).name::<ClientAddName>(),
|
|
||||||
)
|
|
||||||
.fixed(
|
|
||||||
"settings",
|
|
||||||
Route::content(comp(Settings)).name::<SettingsName>(),
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
use_context_provider::<ClientContext>(cx, Default::default);
|
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
link {
|
link {
|
||||||
@@ -50,28 +46,29 @@ fn App(cx: Scope) -> Element {
|
|||||||
|
|
||||||
h1 { "Dioxus CRM Example" }
|
h1 { "Dioxus CRM Example" }
|
||||||
|
|
||||||
Outlet { }
|
Router {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn ClientList(cx: Scope) -> Element {
|
fn ClientList(cx: Scope) -> Element {
|
||||||
let clients = use_context::<ClientContext>(cx).unwrap();
|
let clients = use_shared_state::<ClientContext>(cx).unwrap();
|
||||||
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
h2 { "List of Clients" }
|
h2 { "List of Clients" }
|
||||||
|
|
||||||
Link {
|
Link {
|
||||||
target: named::<ClientAddName>(),
|
target: Route::ClientAdd {},
|
||||||
class: "pure-button pure-button-primary",
|
class: "pure-button pure-button-primary",
|
||||||
"Add Client"
|
"Add Client"
|
||||||
}
|
}
|
||||||
Link {
|
Link {
|
||||||
target: named::<SettingsName>(),
|
target: Route::Settings {},
|
||||||
class: "pure-button",
|
class: "pure-button",
|
||||||
"Settings"
|
"Settings"
|
||||||
}
|
}
|
||||||
|
|
||||||
clients.lock().unwrap().iter().map(|client| rsx! {
|
clients.read().iter().map(|client| rsx! {
|
||||||
div {
|
div {
|
||||||
class: "client",
|
class: "client",
|
||||||
style: "margin-bottom: 50px",
|
style: "margin-bottom: 50px",
|
||||||
@@ -83,14 +80,14 @@ fn ClientList(cx: Scope) -> Element {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ClientAddName;
|
#[inline_props]
|
||||||
fn ClientAdd(cx: Scope) -> Element {
|
fn ClientAdd(cx: Scope) -> Element {
|
||||||
let clients = use_context::<ClientContext>(cx).unwrap();
|
let clients = use_shared_state::<ClientContext>(cx).unwrap();
|
||||||
let first_name = use_state(cx, String::new);
|
let first_name = use_state(cx, String::new);
|
||||||
let last_name = use_state(cx, String::new);
|
let last_name = use_state(cx, String::new);
|
||||||
let description = use_state(cx, String::new);
|
let description = use_state(cx, String::new);
|
||||||
|
|
||||||
let navigator = use_navigate(cx).unwrap();
|
let navigator = use_navigator(cx);
|
||||||
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
h2 { "Add new Client" }
|
h2 { "Add new Client" }
|
||||||
@@ -98,7 +95,7 @@ fn ClientAdd(cx: Scope) -> Element {
|
|||||||
form {
|
form {
|
||||||
class: "pure-form pure-form-aligned",
|
class: "pure-form pure-form-aligned",
|
||||||
onsubmit: move |_| {
|
onsubmit: move |_| {
|
||||||
let mut clients = clients.lock().unwrap();
|
let mut clients = clients.write();
|
||||||
|
|
||||||
clients.push(Client {
|
clients.push(Client {
|
||||||
first_name: first_name.to_string(),
|
first_name: first_name.to_string(),
|
||||||
@@ -106,7 +103,7 @@ fn ClientAdd(cx: Scope) -> Element {
|
|||||||
description: description.to_string(),
|
description: description.to_string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
navigator.push(named::<RootIndex>());
|
navigator.push(Route::ClientList {});
|
||||||
},
|
},
|
||||||
|
|
||||||
fieldset {
|
fieldset {
|
||||||
@@ -164,7 +161,7 @@ fn ClientAdd(cx: Scope) -> Element {
|
|||||||
"Save"
|
"Save"
|
||||||
}
|
}
|
||||||
Link {
|
Link {
|
||||||
target: named::<RootIndex>(),
|
target: Route::ClientList {},
|
||||||
class: "pure-button pure-button-primary red",
|
class: "pure-button pure-button-primary red",
|
||||||
"Cancel"
|
"Cancel"
|
||||||
}
|
}
|
||||||
@@ -176,9 +173,9 @@ fn ClientAdd(cx: Scope) -> Element {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SettingsName;
|
#[inline_props]
|
||||||
fn Settings(cx: Scope) -> Element {
|
fn Settings(cx: Scope) -> Element {
|
||||||
let clients = use_context::<ClientContext>(cx).unwrap();
|
let clients = use_shared_state::<ClientContext>(cx).unwrap();
|
||||||
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
h2 { "Settings" }
|
h2 { "Settings" }
|
||||||
@@ -186,14 +183,14 @@ fn Settings(cx: Scope) -> Element {
|
|||||||
button {
|
button {
|
||||||
class: "pure-button pure-button-primary red",
|
class: "pure-button pure-button-primary red",
|
||||||
onclick: move |_| {
|
onclick: move |_| {
|
||||||
let mut clients = clients.lock().unwrap();
|
let mut clients = clients.write();
|
||||||
clients.clear();
|
clients.clear();
|
||||||
},
|
},
|
||||||
"Remove all Clients"
|
"Remove all Clients"
|
||||||
}
|
}
|
||||||
|
|
||||||
Link {
|
Link {
|
||||||
target: named::<RootIndex>(),
|
target: Route::ClientList {},
|
||||||
class: "pure-button",
|
class: "pure-button",
|
||||||
"Go back"
|
"Go back"
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-10
@@ -17,13 +17,27 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
use_router(cx, &RouterConfiguration::default, &|| {
|
render! {
|
||||||
Segment::content(comp(Home))
|
Router {}
|
||||||
.fixed("games", comp(Games))
|
}
|
||||||
.fixed("play", comp(Play))
|
}
|
||||||
.fixed("settings", comp(Settings))
|
|
||||||
});
|
|
||||||
|
|
||||||
|
#[derive(Routable, Clone)]
|
||||||
|
#[rustfmt::skip]
|
||||||
|
enum Route {
|
||||||
|
#[layout(Footer)]
|
||||||
|
#[route("/")]
|
||||||
|
Home {},
|
||||||
|
#[route("/games")]
|
||||||
|
Games {},
|
||||||
|
#[route("/play")]
|
||||||
|
Play {},
|
||||||
|
#[route("/settings")]
|
||||||
|
Settings {},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
|
fn Footer(cx: Scope) -> Element {
|
||||||
render! {
|
render! {
|
||||||
div {
|
div {
|
||||||
Outlet { }
|
Outlet { }
|
||||||
@@ -34,28 +48,32 @@ fn app(cx: Scope) -> Element {
|
|||||||
|
|
||||||
nav {
|
nav {
|
||||||
ul {
|
ul {
|
||||||
li { Link { target: "/", "Home" } }
|
li { Link { target: Route::Home {}, "Home" } }
|
||||||
li { Link { target: "/games", "Games" } }
|
li { Link { target: Route::Games {}, "Games" } }
|
||||||
li { Link { target: "/play", "Play" } }
|
li { Link { target: Route::Play {}, "Play" } }
|
||||||
li { Link { target: "/settings", "Settings" } }
|
li { Link { target: Route::Settings {}, "Settings" } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Home(cx: Scope) -> Element {
|
fn Home(cx: Scope) -> Element {
|
||||||
render!("Home")
|
render!("Home")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Games(cx: Scope) -> Element {
|
fn Games(cx: Scope) -> Element {
|
||||||
render!("Games")
|
render!("Games")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Play(cx: Scope) -> Element {
|
fn Play(cx: Scope) -> Element {
|
||||||
render!("Play")
|
render!("Play")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Settings(cx: Scope) -> Element {
|
fn Settings(cx: Scope) -> Element {
|
||||||
render!("Settings")
|
render!("Settings")
|
||||||
}
|
}
|
||||||
+25
-10
@@ -8,10 +8,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
use_router(cx, &RouterConfiguration::default, &|| {
|
|
||||||
Segment::content(comp(Home)).fixed("settings", comp(Settings))
|
|
||||||
});
|
|
||||||
|
|
||||||
cx.render(rsx! (
|
cx.render(rsx! (
|
||||||
div {
|
div {
|
||||||
p {
|
p {
|
||||||
@@ -27,20 +23,39 @@ fn app(cx: Scope) -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
div {
|
div {
|
||||||
Outlet { }
|
Router {}
|
||||||
p { "----"}
|
|
||||||
ul {
|
|
||||||
Link { target: "/", li { "Router link to home" } },
|
|
||||||
Link { target: "/settings", li { "Router link to settings" } },
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Routable, Clone)]
|
||||||
|
#[rustfmt::skip]
|
||||||
|
enum Route {
|
||||||
|
#[layout(Header)]
|
||||||
|
#[route("/")]
|
||||||
|
Home {},
|
||||||
|
#[route("/settings")]
|
||||||
|
Settings {},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
|
fn Header(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h1 { "Your app here" }
|
||||||
|
ul {
|
||||||
|
li { Link { target: Route::Home {}, "home" } }
|
||||||
|
li { Link { target: Route::Settings {}, "settings" } }
|
||||||
|
}
|
||||||
|
Outlet {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Home(cx: Scope) -> Element {
|
fn Home(cx: Scope) -> Element {
|
||||||
render!(h1 { "Home" })
|
render!(h1 { "Home" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Settings(cx: Scope) -> Element {
|
fn Settings(cx: Scope) -> Element {
|
||||||
render!(h1 { "Settings" })
|
render!(h1 { "Settings" })
|
||||||
}
|
}
|
||||||
+42
-32
@@ -6,7 +6,6 @@ use dioxus_router::prelude::*;
|
|||||||
fn main() {
|
fn main() {
|
||||||
simple_logger::SimpleLogger::new()
|
simple_logger::SimpleLogger::new()
|
||||||
.with_level(log::LevelFilter::Debug)
|
.with_level(log::LevelFilter::Debug)
|
||||||
.with_module_level("dioxus_router", log::LevelFilter::Trace)
|
|
||||||
.with_module_level("dioxus", log::LevelFilter::Trace)
|
.with_module_level("dioxus", log::LevelFilter::Trace)
|
||||||
.init()
|
.init()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -14,58 +13,69 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
use_router(cx, &RouterConfiguration::default, &|| {
|
|
||||||
Segment::content(comp(Home))
|
|
||||||
.fixed(
|
|
||||||
"blog",
|
|
||||||
Route::empty().nested(
|
|
||||||
Segment::content(comp(BlogList)).catch_all((comp(BlogPost), PostId {})),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.fixed("oranges", comp(Oranges))
|
|
||||||
.fixed("apples", "/oranges")
|
|
||||||
});
|
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
h1 { "Your app here" }
|
Router {}
|
||||||
ul {
|
|
||||||
li { Link { target: "/", "home" } }
|
|
||||||
li { Link { target: "/blog", "blog" } }
|
|
||||||
li { Link { target: "/blog/tim", "tims' blog" } }
|
|
||||||
li { Link { target: "/blog/bill", "bills' blog" } }
|
|
||||||
li { Link { target: "/blog/james", "james amazing' blog" } }
|
|
||||||
li { Link { target: "/apples", "go to apples" } }
|
|
||||||
}
|
|
||||||
Outlet { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Routable, Clone)]
|
||||||
|
#[rustfmt::skip]
|
||||||
|
enum Route {
|
||||||
|
#[layout(NavBar)]
|
||||||
|
#[route("/")]
|
||||||
|
Home {},
|
||||||
|
#[nest("/new")]
|
||||||
|
#[route("/")]
|
||||||
|
BlogList {},
|
||||||
|
#[route("/:post")]
|
||||||
|
BlogPost {
|
||||||
|
post: String,
|
||||||
|
},
|
||||||
|
#[end_nest]
|
||||||
|
#[route("/oranges")]
|
||||||
|
Oranges {},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
|
fn NavBar(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h1 { "Your app here" }
|
||||||
|
ul {
|
||||||
|
li { Link { target: Route::Home {}, "home" } }
|
||||||
|
li { Link { target: Route::BlogList {}, "blog" } }
|
||||||
|
li { Link { target: Route::BlogPost { post: "tim".into() }, "tims' blog" } }
|
||||||
|
li { Link { target: Route::BlogPost { post: "bill".into() }, "bills' blog" } }
|
||||||
|
li { Link { target: Route::BlogPost { post: "james".into() }, "james amazing' blog" } }
|
||||||
|
}
|
||||||
|
Outlet {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Home(cx: Scope) -> Element {
|
fn Home(cx: Scope) -> Element {
|
||||||
log::debug!("rendering home {:?}", cx.scope_id());
|
log::debug!("rendering home {:?}", cx.scope_id());
|
||||||
render! { h1 { "Home" } }
|
render! { h1 { "Home" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn BlogList(cx: Scope) -> Element {
|
fn BlogList(cx: Scope) -> Element {
|
||||||
log::debug!("rendering blog list {:?}", cx.scope_id());
|
log::debug!("rendering blog list {:?}", cx.scope_id());
|
||||||
render! { div { "Blog List" } }
|
render! { div { "Blog List" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PostId;
|
#[inline_props]
|
||||||
fn BlogPost(cx: Scope) -> Element {
|
fn BlogPost(cx: Scope, post: String) -> Element {
|
||||||
let Some(id) = use_route(cx)?.parameter::<PostId>() else {
|
log::debug!("rendering blog post {}", post);
|
||||||
return render!(div { "No blog post id" });
|
|
||||||
};
|
|
||||||
|
|
||||||
log::debug!("rendering blog post {}", id);
|
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
div {
|
div {
|
||||||
h3 { "blog post: {id:?}" }
|
h3 { "blog post: {post}" }
|
||||||
Link { target: "/blog/", "back to blog list" }
|
Link { target: Route::BlogList {}, "back to blog list" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline_props]
|
||||||
fn Oranges(cx: Scope) -> Element {
|
fn Oranges(cx: Scope) -> Element {
|
||||||
render!("Oranges are not apples!")
|
render!("Oranges are not apples!")
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ fn formatting_compiles() {
|
|||||||
// function calls in formatings work
|
// function calls in formatings work
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format_args_f!("{x.borrow():?}").to_string(),
|
format_args_f!("{x.borrow():?}").to_string(),
|
||||||
format!("{:?}", x.borrow())
|
format!("{:?}", x)
|
||||||
);
|
);
|
||||||
|
|
||||||
// allows duplicate format args
|
// allows duplicate format args
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ static REGISTERED_SERVER_FUNCTIONS: once_cell::sync::Lazy<
|
|||||||
/// The registry of all Dioxus server functions.
|
/// The registry of all Dioxus server functions.
|
||||||
pub struct DioxusServerFnRegistry;
|
pub struct DioxusServerFnRegistry;
|
||||||
|
|
||||||
#[cfg(any(feature = "ssr"))]
|
#[cfg(feature = "ssr")]
|
||||||
impl server_fn::ServerFunctionRegistry<DioxusServerContext> for DioxusServerFnRegistry {
|
impl server_fn::ServerFunctionRegistry<DioxusServerContext> for DioxusServerFnRegistry {
|
||||||
type Error = ServerRegistrationFnError;
|
type Error = ServerRegistrationFnError;
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,9 @@ use std::{
|
|||||||
};
|
};
|
||||||
use std::{rc::Rc, sync::RwLock};
|
use std::{rc::Rc, sync::RwLock};
|
||||||
use style_attributes::StyleModifier;
|
use style_attributes::StyleModifier;
|
||||||
use taffy::Taffy;
|
|
||||||
pub use taffy::{geometry::Point, prelude::*};
|
pub use taffy::{geometry::Point, prelude::*};
|
||||||
use tokio::select;
|
use tokio::select;
|
||||||
use tui::{backend::CrosstermBackend, layout::Rect, Terminal};
|
use tui::{backend::CrosstermBackend, Terminal};
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod focus;
|
mod focus;
|
||||||
@@ -160,8 +159,8 @@ pub fn render<R: Driver>(
|
|||||||
|
|
||||||
if !to_rerender.is_empty() || updated {
|
if !to_rerender.is_empty() || updated {
|
||||||
updated = false;
|
updated = false;
|
||||||
fn resize(dims: Rect, taffy: &mut Taffy, rdom: &RealDom) {
|
fn resize(dims: tui::layout::Rect, taffy: &mut Taffy, rdom: &RealDom) {
|
||||||
let width = screen_to_layout_space(dims.width);
|
let width: f32 = screen_to_layout_space(dims.width);
|
||||||
let height = screen_to_layout_space(dims.height);
|
let height = screen_to_layout_space(dims.height);
|
||||||
let root_node = rdom
|
let root_node = rdom
|
||||||
.get(rdom.root_id())
|
.get(rdom.root_id())
|
||||||
@@ -202,7 +201,7 @@ pub fn render<R: Driver>(
|
|||||||
} else {
|
} else {
|
||||||
let rdom = rdom.read().unwrap();
|
let rdom = rdom.read().unwrap();
|
||||||
resize(
|
resize(
|
||||||
Rect {
|
tui::layout::Rect {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: 1000,
|
width: 1000,
|
||||||
|
|||||||
@@ -30,11 +30,10 @@ expressiveness.
|
|||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Routable)]
|
#[derive(Clone, Debug, PartialEq, Routable)]
|
||||||
enum Route {
|
enum Route {
|
||||||
#[nest("/blog")]
|
#[nest("/blog")]
|
||||||
#[layout(Blog)]
|
#[layout(Blog)]
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ pub struct GenericHistoryButtonProps<'a> {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
/// #[derive(Clone, Routable)]
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -98,8 +97,7 @@ pub fn GenericGoBackButton<'a, R: Routable>(
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
/// #[derive(Clone, Routable)]
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
|
|||||||
@@ -83,9 +83,8 @@ impl<R: Routable> Debug for GenericLinkProps<'_, R> {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
///
|
///
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
/// #[derive(Clone, Routable)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ use dioxus::prelude::*;
|
|||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
/// #[derive(Clone, Routable)]
|
||||||
/// #[rustfmt::skip]
|
/// #[rustfmt::skip]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[nest("/wrap")]
|
/// #[nest("/wrap")]
|
||||||
@@ -59,10 +58,7 @@ use dioxus::prelude::*;
|
|||||||
/// # fn App(cx: Scope) -> Element {
|
/// # fn App(cx: Scope) -> Element {
|
||||||
/// # render! {
|
/// # render! {
|
||||||
/// # Router {
|
/// # Router {
|
||||||
/// # config: RouterConfiguration {
|
/// # config: || RouterConfig::default().history(MemoryHistory::with_initial_path(Route::Child {}))
|
||||||
/// # history: Box::new(MemoryHistory::with_initial_path("/wrap").unwrap()),
|
|
||||||
/// # ..Default::default()
|
|
||||||
/// # }
|
|
||||||
/// # }
|
/// # }
|
||||||
/// # }
|
/// # }
|
||||||
/// # }
|
/// # }
|
||||||
|
|||||||
@@ -22,17 +22,6 @@ struct MutableRouterState<R>
|
|||||||
where
|
where
|
||||||
R: Routable,
|
R: Routable,
|
||||||
{
|
{
|
||||||
/// Whether there is a previous page to navigate back to.
|
|
||||||
///
|
|
||||||
/// Even if this is [`true`], there might not be a previous page. However, it is nonetheless
|
|
||||||
/// safe to tell the router to go back.
|
|
||||||
can_go_back: bool,
|
|
||||||
/// Whether there is a future page to navigate forward to.
|
|
||||||
///
|
|
||||||
/// Even if this is [`true`], there might not be a future page. However, it is nonetheless safe
|
|
||||||
/// to tell the router to go forward.
|
|
||||||
can_go_forward: bool,
|
|
||||||
|
|
||||||
/// The current prefix.
|
/// The current prefix.
|
||||||
prefix: Option<String>,
|
prefix: Option<String>,
|
||||||
|
|
||||||
@@ -76,8 +65,6 @@ where
|
|||||||
R: Clone,
|
R: Clone,
|
||||||
{
|
{
|
||||||
let state = Arc::new(RwLock::new(MutableRouterState {
|
let state = Arc::new(RwLock::new(MutableRouterState {
|
||||||
can_go_back: false,
|
|
||||||
can_go_forward: false,
|
|
||||||
prefix: Default::default(),
|
prefix: Default::default(),
|
||||||
history: cfg.history,
|
history: cfg.history,
|
||||||
unresolved_error: None,
|
unresolved_error: None,
|
||||||
@@ -112,13 +99,13 @@ where
|
|||||||
/// Check whether there is a previous page to navigate back to.
|
/// Check whether there is a previous page to navigate back to.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn can_go_back(&self) -> bool {
|
pub fn can_go_back(&self) -> bool {
|
||||||
self.state.read().unwrap().can_go_back
|
self.state.read().unwrap().history.can_go_back()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether there is a future page to navigate forward to.
|
/// Check whether there is a future page to navigate forward to.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn can_go_forward(&self) -> bool {
|
pub fn can_go_forward(&self) -> bool {
|
||||||
self.state.read().unwrap().can_go_forward
|
self.state.read().unwrap().history.can_go_forward()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Go back to the previous location.
|
/// Go back to the previous location.
|
||||||
|
|||||||
@@ -19,13 +19,12 @@ where
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -33,7 +32,7 @@ where
|
|||||||
/// OtherPage {},
|
/// OtherPage {},
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// let mut history = MemoryHistory::<Route>::with_initial_path(Route::Index {}).unwrap();
|
/// let mut history = MemoryHistory::<Route>::with_initial_path(Route::Index {});
|
||||||
/// assert_eq!(history.current_route(), Route::Index {});
|
/// assert_eq!(history.current_route(), Route::Index {});
|
||||||
/// assert_eq!(history.can_go_back(), false);
|
/// assert_eq!(history.can_go_back(), false);
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
@@ -47,13 +47,12 @@ pub trait HistoryProvider<R: Routable> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -86,11 +85,10 @@ pub trait HistoryProvider<R: Routable> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -113,13 +111,12 @@ pub trait HistoryProvider<R: Routable> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -146,13 +143,12 @@ pub trait HistoryProvider<R: Routable> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -180,13 +176,12 @@ pub trait HistoryProvider<R: Routable> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -214,13 +209,12 @@ pub trait HistoryProvider<R: Routable> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -244,13 +238,12 @@ pub trait HistoryProvider<R: Routable> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ use crate::{
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
/// #[derive(Clone, Routable)]
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
|
|||||||
@@ -17,10 +17,9 @@ use crate::utils::use_router_internal::use_router_internal;
|
|||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus_router::{prelude::*};
|
/// # use dioxus_router::{prelude::*};
|
||||||
///
|
///
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
/// #[derive(Clone, Routable)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
|
|||||||
@@ -19,12 +19,11 @@ pub enum NavigationTarget<R: Routable> {
|
|||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use dioxus_router::navigation::NavigationTarget;
|
/// # use dioxus_router::navigation::NavigationTarget;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element {
|
/// # fn Index(cx: Scope) -> Element {
|
||||||
/// # todo!()
|
/// # todo!()
|
||||||
/// # }
|
/// # }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, PartialEq, Debug)]
|
/// #[derive(Clone, Routable, PartialEq, Debug)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
@@ -40,12 +39,11 @@ pub enum NavigationTarget<R: Routable> {
|
|||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use dioxus_router::navigation::NavigationTarget;
|
/// # use dioxus_router::navigation::NavigationTarget;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element {
|
/// # fn Index(cx: Scope) -> Element {
|
||||||
/// # todo!()
|
/// # todo!()
|
||||||
/// # }
|
/// # }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable, PartialEq, Debug)]
|
/// #[derive(Clone, Routable, PartialEq, Debug)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
|
|||||||
@@ -12,18 +12,17 @@ use crate::prelude::*;
|
|||||||
/// This implements [`Default`] and follows the builder pattern, so you can use it like this:
|
/// This implements [`Default`] and follows the builder pattern, so you can use it like this:
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use dioxus_router::prelude::*;
|
/// # use dioxus_router::prelude::*;
|
||||||
/// # use serde::{Deserialize, Serialize};
|
|
||||||
/// # use dioxus::prelude::*;
|
/// # use dioxus::prelude::*;
|
||||||
/// # #[inline_props]
|
/// # #[inline_props]
|
||||||
/// # fn Index(cx: Scope) -> Element {
|
/// # fn Index(cx: Scope) -> Element {
|
||||||
/// # todo!()
|
/// # todo!()
|
||||||
/// # }
|
/// # }
|
||||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
/// #[derive(Clone, Routable)]
|
||||||
/// enum Route {
|
/// enum Route {
|
||||||
/// #[route("/")]
|
/// #[route("/")]
|
||||||
/// Index {},
|
/// Index {},
|
||||||
/// }
|
/// }
|
||||||
/// let cfg = RouterConfig::default().history(WebHistory<Route>::default());
|
/// let cfg = RouterConfig::default().history(WebHistory::<Route>::default());
|
||||||
/// ```
|
/// ```
|
||||||
pub struct RouterConfig<R: Routable> {
|
pub struct RouterConfig<R: Routable> {
|
||||||
pub(crate) failure_external_navigation: fn(Scope) -> Element,
|
pub(crate) failure_external_navigation: fn(Scope) -> Element,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ where
|
|||||||
render! {
|
render! {
|
||||||
h1 { "App" }
|
h1 { "App" }
|
||||||
GenericRouter::<R> {
|
GenericRouter::<R> {
|
||||||
config: || RouterConfiguration::default().history(MemoryHistory::default())
|
config: || RouterConfig::default().history(MemoryHistory::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ fn prepare(path: impl Into<String>) -> VirtualDom {
|
|||||||
h1 { "App" }
|
h1 { "App" }
|
||||||
Router {
|
Router {
|
||||||
config: {
|
config: {
|
||||||
let path = cx.props.path.clone();
|
let path = cx.props.path.parse().unwrap();
|
||||||
move || RouterConfiguration::default().history(MemoryHistory::with_initial_path(path).unwrap())
|
move || RouterConfig::default().history(MemoryHistory::with_initial_path(path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
#![cfg(feature = "wasm_test")]
|
#![cfg(feature = "wasm_test")]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_router::prelude::*;
|
use dioxus_router::prelude::*;
|
||||||
use gloo::utils::document;
|
use gloo::utils::document;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::str::FromStr;
|
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
wasm_bindgen_test_configure!(run_in_browser);
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Routable)]
|
#[derive(Clone, Debug, PartialEq, Routable)]
|
||||||
enum Route {
|
enum Route {
|
||||||
#[route("/")]
|
#[route("/")]
|
||||||
Home {},
|
Home {},
|
||||||
@@ -25,12 +21,7 @@ enum Route {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn App(cx: Scope) -> Element {
|
fn App(cx: Scope) -> Element {
|
||||||
render!(Router {
|
render!(Router {})
|
||||||
config: RouterConfiguration {
|
|
||||||
history: Box::<WebHistory<Route>>::default(),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline_props]
|
#[inline_props]
|
||||||
|
|||||||
Reference in new issue
Block a user