| 358 | /// ``` |
| 359 | #[component] |
| 360 | pub fn PopoverTrigger(props: PopoverTriggerProps) -> Element { |
| 361 | let ctx: PopoverCtx = use_context(); |
| 362 | let mut id = ctx.labelledby; |
| 363 | let id_attribute = props |
| 364 | .attributes |
| 365 | .iter() |
| 366 | .find(|attr| attr.name == "id") |
| 367 | .cloned(); |
| 368 | use_effect(use_reactive!(|id_attribute| { |
| 369 | if let Some(id_attribute) = id_attribute { |
| 370 | match &id_attribute.value { |
| 371 | dioxus_core::AttributeValue::Text(val) => id.set(val.to_string()), |
| 372 | dioxus_core::AttributeValue::Float(val) => id.set(val.to_string()), |
| 373 | dioxus_core::AttributeValue::Int(val) => id.set(val.to_string()), |
| 374 | dioxus_core::AttributeValue::Bool(val) => id.set(val.to_string()), |
| 375 | _ => {} |
| 376 | } |
| 377 | } |
| 378 | })); |
| 379 | |
| 380 | rsx! { |
| 381 | button { |
| 382 | id, |
| 383 | type: "button", |
| 384 | onclick: move |e| { |
| 385 | e.stop_propagation(); |
| 386 | ctx.set_open.call(!(ctx.open)()); |
| 387 | }, |
| 388 | ..props.attributes, |
| 389 | {props.children} |
| 390 | } |
| 391 | } |
| 392 | } |