mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-09-13 22:32:26 +03:00
extract emoji search component
This commit is contained in:
parent
7f40605bfe
commit
6cfe9d19e3
1 changed files with 51 additions and 0 deletions
51
src/app/components/emoji-board/components/SearchInput.tsx
Normal file
51
src/app/components/emoji-board/components/SearchInput.tsx
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import React, { ChangeEventHandler, useRef } from 'react';
|
||||||
|
import { Input, Chip, Icon, Icons, Text } from 'folds';
|
||||||
|
import { mobileOrTablet } from '../../../utils/user-agent';
|
||||||
|
|
||||||
|
type SearchInputProps = {
|
||||||
|
query?: string;
|
||||||
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
||||||
|
allowTextCustomEmoji?: boolean;
|
||||||
|
onTextCustomEmojiSelect?: (text: string) => void;
|
||||||
|
};
|
||||||
|
export function SearchInput({
|
||||||
|
query,
|
||||||
|
onChange,
|
||||||
|
allowTextCustomEmoji,
|
||||||
|
onTextCustomEmojiSelect,
|
||||||
|
}: SearchInputProps) {
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
const handleReact = () => {
|
||||||
|
const textEmoji = inputRef.current?.value.trim();
|
||||||
|
if (!textEmoji) return;
|
||||||
|
onTextCustomEmojiSelect?.(textEmoji);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
ref={inputRef}
|
||||||
|
variant="SurfaceVariant"
|
||||||
|
size="400"
|
||||||
|
placeholder={allowTextCustomEmoji ? 'Search or Text Reaction ' : 'Search'}
|
||||||
|
maxLength={50}
|
||||||
|
after={
|
||||||
|
allowTextCustomEmoji && query ? (
|
||||||
|
<Chip
|
||||||
|
variant="Primary"
|
||||||
|
radii="Pill"
|
||||||
|
after={<Icon src={Icons.ArrowRight} size="50" />}
|
||||||
|
outlined
|
||||||
|
onClick={handleReact}
|
||||||
|
>
|
||||||
|
<Text size="L400">React</Text>
|
||||||
|
</Chip>
|
||||||
|
) : (
|
||||||
|
<Icon src={Icons.Search} size="50" />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onChange={onChange}
|
||||||
|
autoFocus={!mobileOrTablet()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue