Rust UI component that displays an expandable search input.
use leptos::prelude::*; use crate::components::{ extensions::expandable_search::{ExpandableSearch, ExpandableSearchButton, ExpandableSearchInput}, icons::others::search::SearchIcon, }; #[component] pub fn DemoExpandableSearch() -> impl IntoView { view! { <ExpandableSearch> <ExpandableSearchInput placeholder="Search..." /> <ExpandableSearchButton r#type="submit"> <SearchIcon class="size-4 text-neutral-500" /> </ExpandableSearchButton> </ExpandableSearch> } }
use leptos::prelude::*; #[component] pub fn DemoExpandableSearchJs() -> impl IntoView { view! { <script src="/components/expandable_search.js" /> <div class="flex items-center justify-center h-[300px] bg-white w-full"> <div class="relative w-32 transition-all"> <input type="text" placeholder="Arama.." id="searchInput" class="w-full py-2 pl-10 pr-4 text-gray-700 transition-all bg-white border border-gray-300 rounded-full outline-hidden" /> <div class="absolute inset-y-0 left-0 flex items-center pl-3"> <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-gray-400 transition-all" fill="none" viewBox="0 0 24 24" stroke="currentColor" > <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /> </svg> </div> </div> </div> } }
# cargo install ui-cli --forceui add demo_expandable_searchui add expandable_search
components/ui/expandable_search.rs
use leptos::prelude::*; use leptos_ui::{button, clx}; use crate::components::ui::input::Input; mod components { use super::*; clx! {ExpandableSearch, div, "relative"} button! {ExpandableSearchButton, "absolute top-0 right-0 mt-3 mr-4"} } pub use components::*; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ✨ FUNCTIONS ✨ */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ #[component] pub fn ExpandableSearchInput(#[prop(optional, into)] placeholder: &'static str) -> impl IntoView { view! { <Input class="w-12 px-5 pr-10 transition-all duration-300 ease-in-out rounded-full focus:w-64 focus:outline-hidden" placeholder=placeholder onfocus="this.classList.remove('w-12'); this.classList.add('w-64');" onblur="if(this.value === '') { this.classList.remove('w-64'); this.classList.add('w-12'); }" /> } }
// Coming soon 🦀
use leptos::prelude::*; use crate::components::{ extensions::expandable_search::{ExpandableSearch, ExpandableSearchButton, ExpandableSearchInput}, icons::others::search::SearchIcon, }; #[component] pub fn DemoExpandableSearch() -> impl IntoView { view! { <ExpandableSearch> <ExpandableSearchInput placeholder="Search..." /> <ExpandableSearchButton r#type="submit"> <SearchIcon class="size-4 text-neutral-500" /> </ExpandableSearchButton> </ExpandableSearch> } }
use leptos::prelude::*; #[component] pub fn DemoExpandableSearchJs() -> impl IntoView { view! { <script src="/components/expandable_search.js" /> <div class="flex items-center justify-center h-[300px] bg-white w-full"> <div class="relative w-32 transition-all"> <input type="text" placeholder="Arama.." id="searchInput" class="w-full py-2 pl-10 pr-4 text-gray-700 transition-all bg-white border border-gray-300 rounded-full outline-hidden" /> <div class="absolute inset-y-0 left-0 flex items-center pl-3"> <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-gray-400 transition-all" fill="none" viewBox="0 0 24 24" stroke="currentColor" > <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /> </svg> </div> </div> </div> } }
# cargo install ui-cli --forceui add demo_expandable_searchui add expandable_search
components/ui/expandable_search.rs
use leptos::prelude::*; use leptos_ui::{button, clx}; use crate::components::ui::input::Input; mod components { use super::*; clx! {ExpandableSearch, div, "relative"} button! {ExpandableSearchButton, "absolute top-0 right-0 mt-3 mr-4"} } pub use components::*; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ✨ FUNCTIONS ✨ */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ #[component] pub fn ExpandableSearchInput(#[prop(optional, into)] placeholder: &'static str) -> impl IntoView { view! { <Input class="w-12 px-5 pr-10 transition-all duration-300 ease-in-out rounded-full focus:w-64 focus:outline-hidden" placeholder=placeholder onfocus="this.classList.remove('w-12'); this.classList.add('w-64');" onblur="if(this.value === '') { this.classList.remove('w-64'); this.classList.add('w-12'); }" /> } }
// Coming soon 🦀