spaceBelow) {{
select.setAttribute('data-position', 'Above');
}} else {{
select.setAttribute('data-position', 'Below');
}}
- // Set min-width to match trigger
select.style.minWidth = `${{triggerRect.width}}px`;
}};
const openSelect = () => {{
isOpen = true;
-
- // Lock scrolling
- window.ScrollLock.lock();
-
- // Update position and open
+ if (window.ScrollLock) window.ScrollLock.lock();
updatePosition();
select.setAttribute('data-state', 'open');
select.style.pointerEvents = 'auto';
-
- // Trigger scroll event to update indicators
select.dispatchEvent(new Event('scroll'));
-
- // Close on click outside
setTimeout(() => {{
document.addEventListener('click', handleClickOutside);
}}, 0);
@@ -279,9 +268,8 @@ pub fn SelectContent(
select.setAttribute('data-state', 'closed');
select.style.pointerEvents = 'none';
document.removeEventListener('click', handleClickOutside);
-
- // Unlock scrolling after animation
- window.ScrollLock.unlock(200);
+ select.dispatchEvent(new CustomEvent('selectclose', {{ bubbles: false }}));
+ if (window.ScrollLock) window.ScrollLock.unlock(200);
}};
const handleClickOutside = (e) => {{
@@ -290,25 +278,16 @@ pub fn SelectContent(
}}
}};
- // Toggle select when trigger is clicked
trigger.addEventListener('click', (e) => {{
e.stopPropagation();
- if (isOpen) {{
- closeSelect();
- }} else {{
- openSelect();
- }}
+ if (isOpen) closeSelect(); else openSelect();
}});
- // Close when option is selected
const options = select.querySelectorAll('[data-select-option]');
options.forEach(option => {{
- option.addEventListener('click', () => {{
- closeSelect();
- }});
+ option.addEventListener('click', () => closeSelect());
}});
- // Handle ESC key to close
document.addEventListener('keydown', (e) => {{
if (e.key === 'Escape' && isOpen) {{
e.preventDefault();
@@ -328,5 +307,5 @@ pub fn SelectContent(
target_id_for_script,
)}
- }
-}
\ No newline at end of file
+ }.into_any()
+}
diff --git a/frontend/src/components/ui/separator.rs b/frontend/src/components/ui/separator.rs
new file mode 100644
index 0000000..0809cdc
--- /dev/null
+++ b/frontend/src/components/ui/separator.rs
@@ -0,0 +1,35 @@
+use leptos::prelude::*;
+use tw_merge::*;
+
+#[component]
+pub fn Separator(
+ #[prop(into, optional)] orientation: Signal
,
+ #[prop(into, optional)] class: String,
+ // children: Children,
+) -> impl IntoView {
+ let merged_class = Memo::new(move |_| {
+ let orientation = orientation.get();
+ let separator = SeparatorClass { orientation };
+ separator.with_class(class.clone())
+ });
+
+ view! { }
+}
+
+/* ========================================================== */
+/* 🧬 STRUCT 🧬 */
+/* ========================================================== */
+
+#[derive(TwClass, Default)]
+#[tw(class = "shrink-0 bg-border")]
+pub struct SeparatorClass {
+ orientation: SeparatorOrientation,
+}
+
+#[derive(TwVariant)]
+pub enum SeparatorOrientation {
+ #[tw(default, class = "w-full h-[1px]")]
+ Default,
+ #[tw(class = "h-full w-[1px]")]
+ Vertical,
+}
\ No newline at end of file