-
Notifications
You must be signed in to change notification settings - Fork 0
/
WithStrings.tsx
40 lines (36 loc) · 1002 Bytes
/
WithStrings.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { useState } from 'react'
import { FzfHighlight, useFzf } from 'react-fzf'
import { colors } from '../utils/data'
import { Example } from '../utils/Example'
export function WithStrings() {
const [query, setQuery] = useState('')
const { getFzfHighlightProps, results } = useFzf({ items: colors, query })
return (
<Example
title="with strings"
header={
<label>
query:
<input type="text" placeholder="filter…" value={query} onChange={(event) => setQuery(event.target.value)} />
</label>
}
>
<Example.Input>
<ul>
{colors.map((color) => (
<li key={color}>{color}</li>
))}
</ul>
</Example.Input>
<Example.Output>
<ul>
{results.map((item, index) => (
<li key={item}>
<FzfHighlight {...getFzfHighlightProps({ index, item })} />
</li>
))}
</ul>
</Example.Output>
</Example>
)
}