-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathModeSwitch.tsx
More file actions
39 lines (35 loc) · 939 Bytes
/
ModeSwitch.tsx
File metadata and controls
39 lines (35 loc) · 939 Bytes
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
import React from 'react';
import { RadioButtonGroup, InlineFormLabel } from '@grafana/ui';
import { styles } from 'styles';
export interface ModeSwitchProps {
labelA: string;
labelB: string;
value: boolean;
onChange: (value: boolean) => void;
label: string;
tooltip: string;
}
/**
* Component for switching between modes. Boxes are labeled unlike regular Switch.
*/
export const ModeSwitch = (props: ModeSwitchProps) => {
const { labelA, labelB, value, onChange, label, tooltip } = props;
const options = [
{
label: labelA,
value: false,
},
{
label: labelB,
value: true,
},
];
return (
<div className={styles.Common.flexContainer}>
<InlineFormLabel width={8} className="query-keyword" tooltip={tooltip}>
{label}
</InlineFormLabel>
<RadioButtonGroup<boolean> options={options} value={value} onChange={(v) => onChange(v)} />
</div>
);
};