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

Function ComponentBlockDemo

preview/src/main.rs:1108–1140  ·  view source on GitHub ↗
(name: String, variant: Option<String>, dark_mode: Option<bool>)

Source from the content-addressed store, hash-verified

1106
1107#[component]
1108fn ComponentBlockDemo(name: String, variant: Option<String>, dark_mode: Option<bool>) -> Element {
1109 let Some(demo) = components::DEMOS.iter().find(|d| d.name == name).cloned() else {
1110 return rsx! {
1111 div { "Block component not found" }
1112 };
1113 };
1114
1115 let variant = match variant.as_deref() {
1116 Some(wanted) => match demo.variants.iter().find(|v| v.name == wanted) {
1117 Some(v) => v,
1118 None => {
1119 return rsx! {
1120 div {
1121 style: "min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem;",
1122 "Variant content not found: {wanted}"
1123 }
1124 };
1125 }
1126 },
1127 None => &demo.variants[0],
1128 };
1129
1130 let Comp = variant.component;
1131
1132 rsx! {
1133 document::Link { rel: "stylesheet", href: asset!("/assets/main.css") }
1134 document::Link {
1135 rel: "stylesheet",
1136 href: asset!("/assets/dx-components-theme.css"),
1137 }
1138 div { style: "min-height: 100vh;", Comp {} }
1139 }
1140}
1141
1142#[component]
1143fn Home(iframe: Option<bool>, dark_mode: Option<bool>) -> Element {

Callers

nothing calls this directly

Calls 1

iterMethod · 0.80

Tested by

no test coverage detected