Files
frontend-svelte/src/shared/ui/SearchBar/SearchBar.svelte

76 lines
2.0 KiB
Svelte
Raw Normal View History

<!-- Component: SearchBar -->
<script lang="ts">
import { Input } from '$shared/shadcn/ui/input';
import AsteriskIcon from '@lucide/svelte/icons/asterisk';
interface Props {
/**
* Unique identifier for the input element
*/
id?: string;
/**
* Current search value (bindable)
*/
value: string;
/**
* Additional CSS classes for the container
*/
class?: string;
/**
* Placeholder text for the input
*/
placeholder?: string;
/**
* Optional label displayed above the input
*/
label?: string;
}
let {
id = 'search-bar',
value = $bindable(''),
class: className,
placeholder,
}: Props = $props();
function handleKeyDown(event: KeyboardEvent) {
if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {
event.preventDefault();
}
}
</script>
<div class="relative w-full">
2026-02-06 14:48:44 +03:00
<div class="absolute left-4 sm:left-5 top-1/2 -translate-y-1/2 pointer-events-none z-10">
<AsteriskIcon class="size-3 sm:size-4 stroke-gray-400 stroke-[1.5]" />
</div>
<Input
id={id}
placeholder={placeholder}
bind:value={value}
onkeydown={handleKeyDown}
class="
2026-02-06 14:48:44 +03:00
h-12 sm:h-14 md:h-16 w-full text-sm sm:text-base
backdrop-blur-md bg-white/80
border border-gray-300/50
shadow-[0_1px_3px_rgba(0,0,0,0.04)]
focus-visible:border-gray-400/60
focus-visible:outline-none
focus-visible:ring-1
focus-visible:ring-gray-400/30
focus-visible:bg-white/90
hover:bg-white/90
hover:border-gray-400/60
text-gray-900
placeholder:text-gray-400
placeholder:font-mono
2026-02-06 14:48:44 +03:00
placeholder:text-xs sm:placeholder:text-sm
placeholder:tracking-wide
2026-02-06 14:48:44 +03:00
pl-11 sm:pl-14 pr-4 sm:pr-6
rounded-xl
transition-all duration-200
font-medium
"
/>
</div>