patternfly_dioxus/
tooltip.rs1use dioxus::{prelude::*};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum Orientation {
5 Top,
6 Bottom,
7 Left,
8 Right,
9}
10
11#[allow(non_snake_case,dead_code)]
12#[inline_props]
13pub fn PfTooltip<'a>(
14 cx: Scope,
15 children: Element<'a>,
16 content: &'a str,
17 orientation: Option<Orientation>,
18) -> Element {
19 let is_close = use_state(&cx, || true);
20 let orientation = orientation.unwrap_or(Orientation::Top);
21 let css = match orientation {
22 Orientation::Top => "pf-c-tooltip pf-m-top",
23 Orientation::Bottom => "pf-c-tooltip pf-m-bottom",
24 Orientation::Left => "pf-c-tooltip pf-m-left",
25 Orientation::Right => "pf-c-tooltip pf-m-right",
26 };
27 cx.render(rsx! {
28 div { onmouseover: move |_| { is_close.set(false); }, onmouseout: move |_| { is_close.set(true); },
29 div { class: "{css}", role: "tooltip",hidden: "{is_close}",
30 div { class: "pf-c-tooltip__arrow", },
31 div { class: "pf-c-tooltip__content",
32 "{content}",
33 }
34 }
35 ,children
36 }
37 })
38}