MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / NavigationLayout

Function NavigationLayout

preview/src/main.rs:237–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

235
236#[component]
237fn NavigationLayout() -> Element {
238 // Send the route to the parent window if in an iframe
239 let mut initial_route = use_hook(|| CopyValue::new(true));
240 use_effect(move || {
241 let route: Route = router().current();
242
243 // Only send route changes, not the initial route
244 if initial_route() || !Route::in_iframe().unwrap_or_default() {
245 initial_route.set(false);
246 return;
247 }
248
249 let eval = document::eval(
250 "let route = await dioxus.recv();
251 window.top.postMessage({ 'route': route }, '*');",
252 );
253 let _ = eval.send(route.to_string());
254 });
255
256 rsx! {
257 document::Link { rel: "stylesheet", href: asset!("/assets/main.css") }
258 document::Link {
259 rel: "stylesheet",
260 href: asset!("/assets/dx-components-theme.css"),
261 }
262 document::Link { rel: "stylesheet", href: asset!("/assets/hero.css") }
263 Navbar {}
264 Outlet::<Route> {}
265 Footer {}
266 }
267}
268
269#[component]
270fn Navbar() -> Element {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected