add search functionality

This commit is contained in:
Hristo Nedelkov 2023-11-28 13:33:13 +02:00
parent 7ef818bce3
commit 36102865c5
2 changed files with 18 additions and 3 deletions

View File

@ -9,6 +9,9 @@ type HeaderBtnsProps = {
dropdownMenuItem: string dropdownMenuItem: string
timestamps: boolean timestamps: boolean
setTimestamps: (timestamps: boolean) => void setTimestamps: (timestamps: boolean) => void
searchInput: string
setSearchInput: (searchInput: string) => void
triggerSearch: (isTriggered: boolean) => void
} }
const HeaderBtns = ({ const HeaderBtns = ({
@ -16,10 +19,20 @@ const HeaderBtns = ({
dropdownMenuItem, dropdownMenuItem,
timestamps, timestamps,
setTimestamps, setTimestamps,
searchInput,
setSearchInput,
triggerSearch,
}: HeaderBtnsProps) => { }: HeaderBtnsProps) => {
return ( return (
<XStack space={'$4'}> <XStack space={'$4'}>
<Input variant="retractable" color={'black'} icon={<SearchIcon size={16} />}></Input> <Input
variant="retractable"
color={'black'}
icon={<SearchIcon size={16} />}
onChange={e => setSearchInput(e.target.value)}
value={searchInput}
onBlur={() => triggerSearch(true)}
></Input>
<Stack> <Stack>
<DropdownMenu> <DropdownMenu>
<Button variant="outline" icon={<DropdownIcon size={16} />}> <Button variant="outline" icon={<DropdownIcon size={16} />}>

View File

@ -10,6 +10,7 @@ interface RowProps {
data: DataType | undefined data: DataType | undefined
index: number index: number
timestamps: boolean timestamps: boolean
highlight: boolean
} }
function cutSentenceToRandomWords(sentence: string) { function cutSentenceToRandomWords(sentence: string) {
const randomLength = Math.floor(Math.random() * 100) + 1 const randomLength = Math.floor(Math.random() * 100) + 1
@ -18,7 +19,7 @@ function cutSentenceToRandomWords(sentence: string) {
return slicedWords.join(' ') return slicedWords.join(' ')
} }
const TerminalRow = ({ data, index, timestamps }: RowProps) => { const TerminalRow = ({ data, index, timestamps, highlight }: RowProps) => {
if (!data) { if (!data) {
return <Text size={19}>Loading...</Text> return <Text size={19}>Loading...</Text>
} }
@ -36,7 +37,7 @@ const TerminalRow = ({ data, index, timestamps }: RowProps) => {
alignItems: 'center', alignItems: 'center',
marginRight: '20px', marginRight: '20px',
width: '30px', width: '30px',
backgroundColor: '#f5f6f8', backgroundColor: highlight ? 'yellow' : '#f5f6f8',
color: '#A1ABBD', color: '#A1ABBD',
}} }}
> >
@ -56,6 +57,7 @@ const TerminalRow = ({ data, index, timestamps }: RowProps) => {
wordWrap: 'break-word', wordWrap: 'break-word',
maxWidth: '89%', maxWidth: '89%',
height: '100%', height: '100%',
backgroundColor: highlight ? 'yellow' : '#f5f6f8',
}} }}
> >
{option} {description} -- {randomName}{' '} {option} {description} -- {randomName}{' '}