File tree Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ export enum SDSWarningTypes {
3
3
ChipDeprecated = "chipDeprecated" ,
4
4
MenuSelectDeprecated = "menuSelectDeprecated" ,
5
5
ButtonIconMediumSize = "buttonIconMediumSize" ,
6
+ TooltipSubtitle = "tooltipSubtitle" ,
7
+ TooltipWidth = "tooltipWidth" ,
8
+ TooltipInverted = "tooltipInverted" ,
6
9
}
7
10
8
11
const SDS_WARNINGS = {
@@ -24,6 +27,20 @@ const SDS_WARNINGS = {
24
27
hasWarned : false ,
25
28
message : "Warning: A medium size ButtonIcon can only be of type tertiary!" ,
26
29
} ,
30
+ [ SDSWarningTypes . TooltipSubtitle ] : {
31
+ hasWarned : false ,
32
+ message :
33
+ "Warning: The 'subtitle' text is only available for dark tooltips!" ,
34
+ } ,
35
+ [ SDSWarningTypes . TooltipWidth ] : {
36
+ hasWarned : false ,
37
+ message : "Warning: The 'wide' width is only available for light tooltips!" ,
38
+ } ,
39
+ [ SDSWarningTypes . TooltipInverted ] : {
40
+ hasWarned : false ,
41
+ message :
42
+ "Warning: Tooltips using the inverted prop will be deprecated. Please use sdsStyle: 'dark' | 'light' instead!" ,
43
+ } ,
27
44
} ;
28
45
29
46
export const showWarningIfFirstOccurence = ( warningType : SDSWarningTypes ) => {
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ import {
5
5
} from "@mui/material" ;
6
6
import { useTheme } from "@mui/material/styles" ;
7
7
import React , { forwardRef } from "react" ;
8
+ import {
9
+ SDSWarningTypes ,
10
+ showWarningIfFirstOccurence ,
11
+ } from "src/common/warnings" ;
8
12
import {
9
13
arrowCss ,
10
14
StyledPopper ,
@@ -43,24 +47,15 @@ const Tooltip = forwardRef(function Tooltip(
43
47
const { children } = rest ;
44
48
45
49
if ( inverted ) {
46
- // eslint-disable-next-line no-console
47
- console . warn (
48
- "Warning: Tooltips using the inverted prop will be deprecated. Please use sdsStyle: 'dark' | 'light' instead."
49
- ) ;
50
+ showWarningIfFirstOccurence ( SDSWarningTypes . TooltipInverted ) ;
50
51
}
51
52
52
53
if ( width === "wide" && sdsStyle === "dark" ) {
53
- // eslint-disable-next-line no-console
54
- console . warn (
55
- "Warning: The 'wide' width is only available for light tooltips."
56
- ) ;
54
+ showWarningIfFirstOccurence ( SDSWarningTypes . TooltipWidth ) ;
57
55
}
58
56
59
57
if ( subtitle && sdsStyle === "light" ) {
60
- // eslint-disable-next-line no-console
61
- console . warn (
62
- "Warning: The 'subtitle' text is only available for dark tooltips."
63
- ) ;
58
+ showWarningIfFirstOccurence ( SDSWarningTypes . TooltipSubtitle ) ;
64
59
}
65
60
66
61
const theme = useTheme ( ) ;
You can’t perform that action at this time.
0 commit comments