1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use dioxus::prelude::*;
use freya_elements::elements as dioxus_elements;
use freya_elements::events::MouseEvent;
use freya_hooks::use_get_theme;

#[derive(Props)]
pub struct ScrollThumbProps<'a> {
    onmousedown: EventHandler<'a, MouseEvent>,
    #[props(into)]
    width: String,
    #[props(into)]
    height: String,
}

#[allow(non_snake_case)]
pub fn ScrollThumb<'a>(cx: Scope<'a, ScrollThumbProps<'a>>) -> Element<'a> {
    let theme = use_get_theme(cx);
    let scrollbar_theme = &theme.scrollbar;
    render!(
        rect {
            onmousedown: |e| {
                cx.props.onmousedown.call(e);
            },
            width: "{cx.props.width}",
            height: "{cx.props.height}",
            padding: "2",
            rect {
                width: "100%",
                height: "100%",
                corner_radius: "8",
                background: "{scrollbar_theme.thumb_background}",
            }
        }
    )
}