-
-
Notifications
You must be signed in to change notification settings - Fork 436
/
Copy patharduino-select.tsx
69 lines (67 loc) · 2.18 KB
/
arduino-select.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import * as React from '@theia/core/shared/react';
import Select from 'react-select';
import type { StylesConfig } from 'react-select/dist/declarations/src/styles';
import type { ThemeConfig } from 'react-select/dist/declarations/src/theme';
import type { GroupBase } from 'react-select/dist/declarations/src/types';
import type { StateManagerProps } from 'react-select/dist/declarations/src/useStateManager';
export class ArduinoSelect<
Option,
IsMulti extends boolean = false,
Group extends GroupBase<Option> = GroupBase<Option>
> extends React.Component<StateManagerProps<Option, IsMulti, Group>> {
constructor(props: StateManagerProps<Option, IsMulti, Group>) {
super(props);
}
override render(): React.ReactNode {
const controlHeight = 27; // from `monitor.css` -> `.serial-monitor-container .head` (`height: 27px;`)
const styles: StylesConfig = {
control: (styles) => ({
...styles,
minWidth: 120,
color: 'var(--theia-foreground)',
}),
dropdownIndicator: (styles) => ({
...styles,
padding: 0,
}),
indicatorSeparator: () => ({
display: 'none',
}),
indicatorsContainer: () => ({
padding: '0px 5px',
}),
menu: (styles) => ({
...styles,
marginTop: 0,
}),
};
const theme: ThemeConfig = (theme) => ({
...theme,
borderRadius: 0,
spacing: {
controlHeight,
baseUnit: 2,
menuGutter: 4,
},
colors: {
...theme.colors,
// `primary50`??? it's crazy but apparently, without this, we would get a light-blueish
// color when selecting an option in the select by clicking and then not releasing the button.
// https://react-select.com/styles#overriding-the-theme
primary50: 'var(--theia-list-activeSelectionBackground)',
},
});
const DropdownIndicator = () => <span className="fa fa-caret-down caret" />;
return (
<Select
{...this.props}
className="theia-select"
components={{ DropdownIndicator }}
theme={theme}
styles={styles}
classNamePrefix="arduino-select"
isSearchable={false}
/>
);
}
}