use leptos::prelude::*; use leptos_ui::void; use tw_merge::*; // Removed unused fake components /* ========================================================== */ /* ✨ COMPONENTS ✨ */ /* ========================================================== */ #[component] pub fn ScrollArea(children: Children, #[prop(into, optional)] class: String) -> impl IntoView { let merged_class = tw_merge!("relative overflow-hidden", class); view! {
{children()}
} } #[component] pub fn ScrollAreaViewport(children: Children, #[prop(into, optional)] class: String) -> impl IntoView { let merged_class = tw_merge!( "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 overflow-auto", class ); view! {
{children()}
} } /* ========================================================== */ /* 🧬 ENUMS 🧬 */ /* ========================================================== */ // Real scrollbars are now utilized in the viewport directly. /* ========================================================== */ /* 🧬 STRUCT 🧬 */ /* ========================================================== */ #[component] pub fn SnapScrollArea( #[prop(into, default = SnapAreaVariant::default())] variant: SnapAreaVariant, #[prop(into, optional)] class: String, children: Children, ) -> impl IntoView { let snap_item = SnapAreaClass { variant }; let merged_class = snap_item.with_class(class); view! {
{children()}
} } #[derive(TwClass, Default)] #[tw(class = "")] pub struct SnapAreaClass { variant: SnapAreaVariant, } #[derive(TwVariant)] pub enum SnapAreaVariant { // * snap-x by default #[tw(default, class = "overflow-x-auto snap-x")] Center, } /* ========================================================== */ /* 🧬 STRUCT 🧬 */ /* ========================================================== */ #[component] pub fn SnapItem( #[prop(into, default = SnapVariant::default())] variant: SnapVariant, #[prop(into, optional)] class: String, children: Children, ) -> impl IntoView { let snap_item = SnapItemClass { variant }; let merged_class = snap_item.with_class(class); view! {
{children()}
} } #[derive(TwClass, Default)] #[tw(class = "shrink-0")] pub struct SnapItemClass { variant: SnapVariant, } #[derive(TwVariant)] pub enum SnapVariant { // * snap-center by default #[tw(default, class = "snap-center")] Center, }