62 lines
1.6 KiB
Rust
62 lines
1.6 KiB
Rust
|
|
use dioxus::prelude::*;
|
||
|
|
use dioxus_primitives::dioxus_attributes::attributes;
|
||
|
|
use dioxus_primitives::merge_attributes;
|
||
|
|
use dioxus_primitives::tooltip::{self, TooltipContentProps, TooltipProps, TooltipTriggerProps};
|
||
|
|
|
||
|
|
#[css_module("/src/components/tooltip/style.css")]
|
||
|
|
struct Styles;
|
||
|
|
|
||
|
|
#[component]
|
||
|
|
pub fn Tooltip(props: TooltipProps) -> Element {
|
||
|
|
let base = attributes!(div {
|
||
|
|
class: Styles::dx_tooltip,
|
||
|
|
});
|
||
|
|
let merged = merge_attributes(vec![base, props.attributes]);
|
||
|
|
|
||
|
|
rsx! {
|
||
|
|
tooltip::Tooltip {
|
||
|
|
disabled: props.disabled,
|
||
|
|
open: props.open,
|
||
|
|
default_open: props.default_open,
|
||
|
|
on_open_change: props.on_open_change,
|
||
|
|
attributes: merged,
|
||
|
|
{props.children}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[component]
|
||
|
|
pub fn TooltipTrigger(props: TooltipTriggerProps) -> Element {
|
||
|
|
let base = attributes!(button {
|
||
|
|
class: Styles::dx_tooltip_trigger,
|
||
|
|
});
|
||
|
|
let merged = merge_attributes(vec![base, props.attributes]);
|
||
|
|
|
||
|
|
rsx! {
|
||
|
|
tooltip::TooltipTrigger {
|
||
|
|
id: props.id,
|
||
|
|
as: props.r#as,
|
||
|
|
attributes: merged,
|
||
|
|
{props.children}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[component]
|
||
|
|
pub fn TooltipContent(props: TooltipContentProps) -> Element {
|
||
|
|
let base = attributes!(div {
|
||
|
|
class: Styles::dx_tooltip_content,
|
||
|
|
});
|
||
|
|
let merged = merge_attributes(vec![base, props.attributes]);
|
||
|
|
|
||
|
|
rsx! {
|
||
|
|
tooltip::TooltipContent {
|
||
|
|
id: props.id,
|
||
|
|
side: props.side,
|
||
|
|
align: props.align,
|
||
|
|
attributes: merged,
|
||
|
|
{props.children}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|