-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathSearchTokensList.tsx
More file actions
38 lines (34 loc) · 1 KB
/
SearchTokensList.tsx
File metadata and controls
38 lines (34 loc) · 1 KB
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
import React from "react";
import { EuiBadge, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
interface SearchTokensListProps {
tokens: string[];
removeTokenByPosition: (tokenPosition: number) => void;
}
const SearchTokensList = ({
tokens,
removeTokenByPosition,
}: SearchTokensListProps) => {
return (
<EuiFlexGroup wrap responsive={false} gutterSize="xs">
{tokens.map((token, index) => {
const badgeColor = token.indexOf(":") > 0 ? "primary" : "hollow";
return (
<EuiFlexItem key={token} grow={false}>
<EuiBadge
color={badgeColor}
iconType="cross"
iconSide="right"
iconOnClick={() => {
removeTokenByPosition(index);
}}
iconOnClickAriaLabel="Example of onClick event for icon within the button"
>
{token}
</EuiBadge>
</EuiFlexItem>
);
})}
</EuiFlexGroup>
);
};
export default SearchTokensList;