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

40 lines
1.1 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
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;
noIcon?: boolean;
id?: string;
placeholder?: 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, noIcon, onChange, noBorder, placeholder = 'Поиск', ...restProps }: SearchBarProps) {
2023-11-06 02:20:16 +03:00
return (
2023-12-28 14:04:44 +03:00
<div {...restProps}>
{!noIcon ? (
<Overlay position='top-[-0.125rem] left-3 translate-y-1/2' className='pointer-events-none clr-text-controls'>
<IconSearch size='1.25rem' />
</Overlay>
) : null}
2023-12-28 14:04:44 +03:00
<TextInput
id={id}
2023-12-28 14:04:44 +03:00
noOutline
placeholder={placeholder}
type='search'
2024-09-21 20:04:07 +03:00
className={clsx('outline-none bg-transparent', !noIcon && '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;