From 2cac8c729c8ee175f01f677f285382349a7f9f62 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Wed, 11 Jun 2025 09:52:05 +0100 Subject: feat: prettier scrollbars --- src/components/chats_list.rs | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'src/components/chats_list.rs') diff --git a/src/components/chats_list.rs b/src/components/chats_list.rs index 43ee53e..027de64 100644 --- a/src/components/chats_list.rs +++ b/src/components/chats_list.rs @@ -1,7 +1,9 @@ use chats_list_item::ChatsListItem; use indexmap::IndexMap; use jid::BareJID; -use leptos::prelude::*; +use js_sys::{wasm_bindgen::UnwrapThrowExt, Object, Reflect, JSON}; +use leptos::{html::Div, prelude::*}; +use overlay_scrollbars::OverlayScrollbars; use tracing::debug; use crate::{ @@ -86,6 +88,30 @@ pub fn ChatsList() -> impl IntoView { } }); + let chats_list: NodeRef
= NodeRef::new(); + let chats_list_viewport: NodeRef
= NodeRef::new(); + + let _scrollbars = Effect::new(move |_| { + if let Some(buffer) = chats_list.get() { + if let Some(viewport) = chats_list_viewport.get() { + let scrollbars_obj = Object::new(); + // Reflect::set(&scrollbars_obj, &"theme".into(), &"os-macaw".into()).unwrap_throw(); + // Reflect::set(&scrollbars_obj, &"autoHide".into(), &"leave".into()).unwrap_throw(); + let options_obj = Object::new(); + // Reflect::set(&options_obj, &"scrollbars".into(), &scrollbars_obj).unwrap_throw(); + + let elements_obj = Object::new(); + Reflect::set(&elements_obj, &"viewport".into(), &viewport.into()).unwrap_throw(); + let element_obj = Object::new(); + Reflect::set(&elements_obj, &"elements".into(), &elements_obj).unwrap_throw(); + Reflect::set(&element_obj, &"target".into(), &buffer.into()).unwrap_throw(); + // let element = Object::define_property(&Object::define_property(&Object::new(), &"target".into(), &buffer.into()), &"elements".into(), &Object::define_property(&Object::new(), &"viewport".into(), &viewport.into())); + debug!("scrollable element: {}", JSON::stringify(&element_obj.clone().into()).unwrap_throw()); + OverlayScrollbars(element_obj, options_obj); + } + } + }); + view! {
// TODO: update icon, tooltip on hover. @@ -110,10 +136,16 @@ pub fn ChatsList() -> impl IntoView { }}
-
- - - +
+
+ + + +
} -- cgit