spoti-search/src/components/Search.tsx

33 lines
717 B
TypeScript

import React from 'react';
import { Box, TextInput } from 'grommet';
import { FormSearch } from 'grommet-icons';
export const Search = ({
inputValue,
handleChange,
suggestions,
handleSelect,
}: {
inputValue: string;
handleChange: (value: string) => void;
suggestions: string[];
handleSelect: (suggestion: string) => void;
}) => (
<Box
as='section'
direction='row'
justify='center'
margin={{ vertical: 'large' }}
>
<TextInput
value={inputValue}
onChange={e => handleChange(e.target.value)}
onSelect={(target) => handleSelect(target.suggestion)}
placeholder='Type an artist name'
icon={<FormSearch color='plain' />}
dropHeight='large'
suggestions={suggestions}
/>
</Box>
);