ConceptPortal-public/rsconcept/frontend/src/components/ui/SearchBar.tsx

34 lines
911 B
TypeScript
Raw Normal View History

2024-05-02 17:04:18 +03:00
import { IconSearch } from '../Icons';
import { CProps } from '../props';
2023-12-08 19:24:08 +03:00
import Overlay from './Overlay';
2023-11-06 02:20:16 +03:00
import TextInput from './TextInput';
interface SearchBarProps extends CProps.Styling {
2023-12-28 14:04:44 +03:00
value: string;
id?: string;
2023-12-28 14:04:44 +03:00
onChange?: (newValue: string) => void;
noBorder?: boolean;
2023-11-06 02:20:16 +03:00
}
function SearchBar({ id, value, onChange, noBorder, ...restProps }: SearchBarProps) {
2023-11-06 02:20:16 +03:00
return (
2023-12-28 14:04:44 +03:00
<div {...restProps}>
<Overlay position='top-[-0.125rem] left-3 translate-y-1/2' className='pointer-events-none clr-text-controls'>
2024-05-02 17:04:18 +03:00
<IconSearch size='1.25rem' />
2023-12-28 14:04:44 +03:00
</Overlay>
<TextInput
id={id}
2023-12-28 14:04:44 +03:00
noOutline
placeholder='Поиск'
type='search'
2023-12-30 19:43:24 +03:00
className='w-full pl-10'
2023-12-28 14:04:44 +03:00
noBorder={noBorder}
value={value}
onChange={event => (onChange ? onChange(event.target.value) : undefined)}
/>
</div>
);
2023-11-06 02:20:16 +03:00
}
export default SearchBar;