|
1 |
| -import {Tooltip, tooltipClasses, TooltipProps} from "@mui/material"; |
2 |
| -import React, {ReactElement} from "react"; |
3 |
| -import {styled} from "@mui/material/styles"; |
| 1 | +import { Tooltip, tooltipClasses, TooltipProps } from '@mui/material'; |
| 2 | +import React, { ReactElement } from 'react'; |
| 3 | +import { styled } from '@mui/material/styles'; |
4 | 4 |
|
5 |
| -const StyledTooltip = styled(({className, isEmpty, ...props}: {isEmpty?:boolean}&TooltipProps) => ( |
6 |
| - <Tooltip {...props} classes={{popper: className}}/> |
7 |
| -))(({theme, isEmpty}) => (!isEmpty ?{ |
8 |
| - [`& .${tooltipClasses.tooltip}`]: { |
9 |
| - backgroundColor: 'rgba(254, 226, 226, 1)', |
10 |
| - color: 'rgba(23, 45, 50, 1)', |
11 |
| - fontSize: theme.typography.pxToRem(12), |
12 |
| - fontWeight: 400, |
13 |
| - border: '1px solid rgba(254, 202, 202, 1)', |
14 |
| - }, |
15 |
| -}:{[`& .${tooltipClasses.tooltip}`]: { |
16 |
| - backgroundColor: 'transparent', |
17 |
| - border: '0px', |
18 |
| - },})); |
| 5 | +const StyledTooltip = styled( |
| 6 | + ({ className, isEmpty, ...props }: { isEmpty?: boolean } & TooltipProps) => ( |
| 7 | + <Tooltip {...props} classes={{ popper: className }} /> |
| 8 | + ) |
| 9 | +)(({ theme, isEmpty }) => |
| 10 | + !isEmpty |
| 11 | + ? { |
| 12 | + [`& .${tooltipClasses.tooltip}`]: { |
| 13 | + backgroundColor: 'rgba(254, 226, 226, 1)', |
| 14 | + color: 'rgba(23, 45, 50, 1)', |
| 15 | + fontSize: theme.typography.pxToRem(12), |
| 16 | + fontWeight: 400, |
| 17 | + border: '1px solid rgba(254, 202, 202, 1)', |
| 18 | + }, |
| 19 | + } |
| 20 | + : { |
| 21 | + [`& .${tooltipClasses.tooltip}`]: { |
| 22 | + backgroundColor: 'transparent', |
| 23 | + border: '0px', |
| 24 | + }, |
| 25 | + } |
| 26 | +); |
19 | 27 |
|
20 |
| -export const enum TooltipVariant { Default = 'default', Error = 'error'}; |
| 28 | +export const enum TooltipVariant { |
| 29 | + Default = 'default', |
| 30 | + Error = 'error', |
| 31 | +} |
21 | 32 |
|
22 | 33 | export const ErroredTooltip = ({
|
23 |
| - title, |
24 |
| - tooltipVariant= TooltipVariant.Default, |
25 |
| - children, |
26 |
| - placement= 'top', |
27 |
| - disableInteractive= true, |
| 34 | + title, |
| 35 | + tooltipVariant = TooltipVariant.Default, |
| 36 | + children, |
| 37 | + placement = 'top', |
| 38 | + disableInteractive = true, |
28 | 39 | ...restProps
|
29 |
| - }: { tooltipVariant?: TooltipVariant, children: ReactElement<any, any>} & TooltipProps) => { |
| 40 | +}: { tooltipVariant?: TooltipVariant; children: ReactElement<any, any> } & TooltipProps) => { |
30 | 41 | return (
|
31 | 42 | <>
|
32 |
| - <StyledTooltip {...restProps} title={title} placement={placement} disableInteractive={disableInteractive} isEmpty={title === ''}> |
| 43 | + <StyledTooltip |
| 44 | + {...restProps} |
| 45 | + title={title} |
| 46 | + placement={placement} |
| 47 | + disableInteractive={disableInteractive} |
| 48 | + isEmpty={title === ''} |
| 49 | + > |
33 | 50 | {children}
|
34 | 51 | </StyledTooltip>
|
35 | 52 | </>
|
36 |
| - ) |
37 |
| -} |
38 |
| - |
| 53 | + ); |
| 54 | +}; |
0 commit comments