All files / src/components RecipeSearchFilter.tsx

33.33% Statements 1/3
50% Branches 4/8
33.33% Functions 1/3
33.33% Lines 1/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                              2x                                                          
import { Search, X } from 'lucide-react'
 
interface RecipeSearchFilterProps {
  searchQuery: string
  onSearchChange: (query: string) => void
  totalCount: number
  filteredCount: number
}
 
export default function RecipeSearchFilter({
  searchQuery,
  onSearchChange,
  totalCount,
  filteredCount,
}: RecipeSearchFilterProps) {
  return (
    <>
      <div className="relative mb-4">
        <Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
        <input
          type="text"
          value={searchQuery}
          onChange={(e) => onSearchChange(e.target.value)}
          placeholder="Filter recipes..."
          className="w-full rounded-lg border border-border bg-input-background py-2 pl-10 pr-10 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
        />
        {searchQuery && (
          <button
            onClick={() => onSearchChange('')}
            className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
          >
            <X className="h-4 w-4" />
          </button>
        )}
      </div>
 
      <p className="mb-4 text-sm text-muted-foreground">
        {searchQuery
          ? `${filteredCount} of ${totalCount} recipe${totalCount !== 1 ? 's' : ''}`
          : `${totalCount} recipe${totalCount !== 1 ? 's' : ''}`}
      </p>
    </>
  )
}
 
← Back to Dashboard