movie-web/src/components/SearchBar.tsx

40 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-06-30 12:20:01 +02:00
import { MWQuery } from "@/backend/metadata/types/mw";
2023-01-07 21:36:18 +01:00
import { Icon, Icons } from "./Icon";
2022-02-25 21:23:16 +01:00
import { TextInputControl } from "./text-inputs/TextInputControl";
2022-02-07 23:22:35 +01:00
export interface SearchBarProps {
2022-02-10 23:45:17 +01:00
placeholder?: string;
2022-05-03 20:58:34 +02:00
onChange: (value: MWQuery, force: boolean) => void;
onUnFocus: () => void;
value: MWQuery;
2022-02-07 23:22:35 +01:00
}
export function SearchBarInput(props: SearchBarProps) {
function setSearch(value: string) {
2022-05-03 20:58:34 +02:00
props.onChange(
{
...props.value,
searchQuery: value,
},
false
);
}
2022-02-13 18:49:03 +01:00
2022-02-07 23:22:35 +01:00
return (
2023-01-07 23:44:46 +01:00
<div className="relative flex flex-col rounded-[28px] bg-denim-400 transition-colors focus-within:bg-denim-400 hover:bg-denim-500 sm:flex-row sm:items-center">
2023-04-27 20:54:36 +02:00
<div className="pointer-events-none absolute bottom-0 left-5 top-0 flex max-h-14 items-center">
2023-01-07 21:36:18 +01:00
<Icon icon={Icons.SEARCH} />
</div>
2022-02-10 23:45:17 +01:00
<TextInputControl
2022-05-03 20:58:34 +02:00
onUnFocus={props.onUnFocus}
onChange={(val) => setSearch(val)}
value={props.value.searchQuery}
2023-01-07 21:36:18 +01:00
className="w-full flex-1 bg-transparent px-4 py-4 pl-12 text-white placeholder-denim-700 focus:outline-none sm:py-4 sm:pr-2"
2022-02-10 23:45:17 +01:00
placeholder={props.placeholder}
/>
2022-02-07 23:22:35 +01:00
</div>
2022-02-10 23:45:17 +01:00
);
2022-02-07 23:22:35 +01:00
}