(#[props(extends=GlobalAttributes)] attributes: Vec<Attribute>)
| 437 | |
| 438 | #[component] |
| 439 | fn CopyButton(#[props(extends=GlobalAttributes)] attributes: Vec<Attribute>) -> Element { |
| 440 | let mut copied = use_signal(|| false); |
| 441 | |
| 442 | rsx! { |
| 443 | button { |
| 444 | class: "dx-copy-button", |
| 445 | r#type: "button", |
| 446 | aria_label: "Copy code", |
| 447 | "data-copied": copied, |
| 448 | "onclick": "const visiblePre = Array.from(this.parentNode.querySelectorAll('pre')).find((pre) => pre.offsetParent !== null); navigator.clipboard.writeText(visiblePre ? visiblePre.innerText : Array.from(this.parentNode.childNodes).filter((node) => node !== this).map((node) => node.textContent).join('').trim());", |
| 449 | onclick: move |_| copied.set(true), |
| 450 | ..attributes, |
| 451 | if copied() { |
| 452 | CheckIcon {} |
| 453 | } else { |
| 454 | CopyIcon {} |
| 455 | } |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | #[component] |
| 461 | fn CopyIcon() -> Element { |
nothing calls this directly
no outgoing calls
no test coverage detected