forked from jupytercalpoly/jupyterlab-code-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeSnippetSearchOption.tsx
51 lines (47 loc) · 1.19 KB
/
CodeSnippetSearchOption.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
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import { checkIcon } from '@jupyterlab/ui-components';
const CODE_SNIPPET_SORT_OPTION_UNSELECT =
'jp-codeSnippet-sort-option-unselected';
const CODE_SNIPPET_SORT_OPTION_SELECT = 'jp-codeSnippet-sort-option-selected';
interface ISortSnippetOptionProps {
optionSelected: boolean;
optionName: string;
onSelectMulti: (name: string, selected: boolean) => void;
}
const SearchOption = ({
optionSelected,
optionName,
onSelectMulti,
}: ISortSnippetOptionProps): JSX.Element => {
if (optionSelected) {
return (
<div
className={CODE_SNIPPET_SORT_OPTION_SELECT}
onClick={(): void => {
onSelectMulti(optionName, false);
}}
>
<checkIcon.react
className="jupyterlab-CodeSnippets-sort-selected"
elementPosition="center"
height="16px"
width="16px"
marginLeft="2px"
/>
{optionName}
</div>
);
} else {
return (
<div
className={CODE_SNIPPET_SORT_OPTION_UNSELECT}
onClick={(): void => {
onSelectMulti(optionName, true);
}}
>
{optionName}
</div>
);
}
};
export default SearchOption;