/
ClusterChooser.tsx
49 lines (44 loc) · 1.36 KB
/
ClusterChooser.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
import Button from '@mui/material/Button';
import { styled } from '@mui/system';
import React, { ReactElement } from 'react';
import { Trans, useTranslation } from 'react-i18next';
export interface ClusterChooserProps {
clickHandler: (event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
cluster?: string;
}
export type ClusterChooserType = React.ComponentType<ClusterChooserProps> | ReactElement | null;
const SpanClusterName = styled('span')({
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
display: 'block',
});
const ClusterChooser = React.forwardRef(function ClusterChooser(
{ clickHandler, cluster }: ClusterChooserProps,
ref: React.Ref<HTMLButtonElement>
) {
const { t } = useTranslation();
return (
<Button
size="large"
variant="contained"
onClick={clickHandler}
sx={theme => ({
color: theme.palette.clusterChooser.button.color,
background: theme.palette.clusterChooser.button.background,
'&:hover': {
background: theme.palette.clusterChooser.button.hover.background,
},
maxWidth: '20em',
textTransform: 'none',
padding: '6px 22px',
})}
ref={ref}
>
<SpanClusterName title={cluster}>
<Trans t={t}>Cluster: {{ cluster }}</Trans>
</SpanClusterName>
</Button>
);
});
export default ClusterChooser;