(props: ScrollAreaProps)
| 85 | /// - `data-scroll-direction`: Indicates the scroll direction. Values are `vertical`, `horizontal`, or `both`. |
| 86 | #[component] |
| 87 | pub fn ScrollArea(props: ScrollAreaProps) -> Element { |
| 88 | let direction = props.direction; |
| 89 | let scroll_type = props.scroll_type; |
| 90 | let always_show = props.always_show_scrollbars; |
| 91 | |
| 92 | let (overflow_x, overflow_y, scrollbar_width) = match scroll_type() { |
| 93 | ScrollType::Auto => match direction() { |
| 94 | ScrollDirection::Vertical => (Some("hidden"), Some("auto"), None), |
| 95 | ScrollDirection::Horizontal => (Some("auto"), Some("hidden"), None), |
| 96 | ScrollDirection::Both => (Some("auto"), Some("auto"), None), |
| 97 | }, |
| 98 | ScrollType::Always => match direction() { |
| 99 | ScrollDirection::Vertical => (Some("hidden"), Some("scroll"), None), |
| 100 | ScrollDirection::Horizontal => (Some("scroll"), Some("hidden"), None), |
| 101 | ScrollDirection::Both => (Some("scroll"), Some("scroll"), None), |
| 102 | }, |
| 103 | ScrollType::Hidden => match direction() { |
| 104 | ScrollDirection::Vertical => (Some("hidden"), Some("scroll"), Some("none")), |
| 105 | ScrollDirection::Horizontal => (Some("scroll"), Some("hidden"), Some("none")), |
| 106 | ScrollDirection::Both => (Some("scroll"), Some("scroll"), Some("none")), |
| 107 | }, |
| 108 | }; |
| 109 | |
| 110 | let visibility_class = use_memo(move || { |
| 111 | if always_show() { |
| 112 | "dx-scroll-area-always-show" |
| 113 | } else { |
| 114 | "dx-scroll-area-auto-hide" |
| 115 | } |
| 116 | }); |
| 117 | |
| 118 | rsx! { |
| 119 | div { |
| 120 | class: "{visibility_class}", |
| 121 | overflow_x, |
| 122 | overflow_y, |
| 123 | "scrollbar-width": scrollbar_width, |
| 124 | "data-scroll-direction": match direction() { |
| 125 | ScrollDirection::Vertical => "vertical", |
| 126 | ScrollDirection::Horizontal => "horizontal", |
| 127 | ScrollDirection::Both => "both", |
| 128 | }, |
| 129 | ..props.attributes, |
| 130 | |
| 131 | {props.children} |
| 132 | } |
| 133 | } |
| 134 | } |
nothing calls this directly
no outgoing calls
no test coverage detected