-
Notifications
You must be signed in to change notification settings - Fork 12
/
MappingButton.jsx
43 lines (40 loc) · 1.42 KB
/
MappingButton.jsx
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
import React from 'react';
import { Button, ButtonGroup, Tooltip } from '@mui/material';
import { Link as LinkIcon } from '@mui/icons-material';
import { merge } from 'lodash';
import { BLUE, WHITE, RED, BLACK, UUID_LENGTH } from '../../common/constants';
const MappingButton = ({label, mapType, onClick, retired, href, style, ...rest}) => {
const _style = retired ?
{background: 'lightgray', color: RED, boxShadow: 'none', textDecoration: 'line-through', textDecorationColor: BLACK, textTransform: 'none'} :
{background: BLUE, color: WHITE, boxShadow: 'none', textTransform: 'none'};
const truncLabel = label && label.length === UUID_LENGTH ? `${label.split('-')[0]}...` : label
return (
<Tooltip title={label} arrow>
<ButtonGroup variant='contained' style={{boxShadow: 'none'}} {...rest}>
<Button
className={mapType ? 'light-gray-bg' : ''}
href={href}
startIcon={<LinkIcon />}
onClick={onClick}
style={merge(_style, style || {})}
{...rest}
>
{truncLabel}
</Button>
{
mapType &&
<Button
href={href}
variant='contained'
onClick={onClick}
style={merge(_style, style || {})}
{...rest}
>
{mapType}
</Button>
}
</ButtonGroup>
</Tooltip>
)
}
export default MappingButton;