feature/comparison-slider #19

Merged
ilia merged 129 commits from feature/comparison-slider into main 2026-02-02 09:23:46 +00:00
2 changed files with 6 additions and 39 deletions
Showing only changes of commit 072690270f - Show all commits

View File

@@ -45,11 +45,7 @@ let noChildrenValue = $state('');
placeholder: 'Type here...',
}}
>
<SearchBar bind:value={defaultSearchValue} placeholder="Type here...">
Here will be the search result
<br />
Popover closes only when the user clicks outside the search bar or presses the Escape key.
</SearchBar>
<SearchBar bind:value={defaultSearchValue} placeholder="Type here..."> </SearchBar>
</Story>
<Story
@@ -60,11 +56,7 @@ let noChildrenValue = $state('');
label: 'Search',
}}
>
<SearchBar bind:value={withLabelValue} placeholder="Search products..." label="Search">
<div class="p-4">
<p class="text-sm text-muted-foreground">No results found</p>
</div>
</SearchBar>
<SearchBar bind:value={withLabelValue} placeholder="Search products..." label="Search"> </SearchBar>
</Story>
<Story
@@ -74,9 +66,5 @@ let noChildrenValue = $state('');
placeholder: 'Quick search...',
}}
>
<SearchBar bind:value={noChildrenValue} placeholder="Quick search...">
<div class="p-4 text-center text-sm text-muted-foreground">
Start typing to see results
</div>
</SearchBar>
<SearchBar bind:value={noChildrenValue} placeholder="Quick search..."> </SearchBar>
</Story>

View File

@@ -1,14 +1,7 @@
<!--
Component: SearchBar
Search input with popover dropdown for results/suggestions
- Features keyboard navigation (ArrowDown/Up/Enter) and auto-focus prevention on popover open.
- The input field serves as the popover trigger.
-->
<!-- Component: SearchBar -->
<script lang="ts">
import { Input } from '$shared/shadcn/ui/input';
import ScanSearchIcon from '@lucide/svelte/icons/scan-search';
import { useId } from 'bits-ui';
import AsteriskIcon from '@lucide/svelte/icons/asterisk';
interface Props {
/**
@@ -19,10 +12,6 @@ interface Props {
* Current search value (bindable)
*/
value: string;
/**
* Whether popover is open (bindable)
*/
isOpen?: boolean;
/**
* Additional CSS classes for the container
*/
@@ -40,36 +29,26 @@ interface Props {
let {
id = 'search-bar',
value = $bindable(''),
isOpen = $bindable(false),
class: className,
placeholder,
}: Props = $props();
let triggerRef = $state<HTMLInputElement>(null!);
// svelte-ignore state_referenced_locally
const contentId = useId(id);
function handleKeyDown(event: KeyboardEvent) {
if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {
event.preventDefault();
}
}
function handleInputClick() {
isOpen = true;
}
</script>
<div class="relative w-full">
<div class="absolute left-5 top-1/2 -translate-y-1/2 pointer-events-none z-10">
<ScanSearchIcon class="size-4 stroke-gray-400 stroke-[1.5]" />
<AsteriskIcon class="size-4 stroke-gray-400 stroke-[1.5]" />
</div>
<Input
id={id}
placeholder={placeholder}
bind:value={value}
onkeydown={handleKeyDown}
onclick={handleInputClick}
class="
h-16 w-full text-base
backdrop-blur-md bg-white/80