@@ -15,41 +15,42 @@ interface IToggleSwitch {
15
15
onClick ?: ( ) => void
16
16
}
17
17
export const ToggleSwitch = ( props : IToggleSwitch ) => {
18
- let { id, onstyle, offstyle, size, tooltipTextId, disabled, isOn, onClick} = props
18
+ const { id, tooltipTextId, disabled, onClick } = props
19
+ let { onstyle, offstyle, size, isOn } = props
19
20
size = size || 'lg'
20
21
onstyle = onstyle || 'text-primary'
21
22
offstyle = offstyle || 'text-secondary'
22
23
isOn = isOn === false ? isOn : true
23
24
24
25
const childJSXWithTooltip = (
25
- < CustomTooltip
26
- placement = { "auto" }
27
- tooltipId = { id + "Tooltip" }
28
- tooltipClasses = "text-nowrap"
29
- tooltipText = { < FormattedMessage id = { tooltipTextId } /> }
30
- >
31
- < button
32
- data-id = { id + "Switch" }
33
- id = { id }
34
- className = { `btn ${ isOn ? onstyle : offstyle } ` }
35
- onClick = { ( ) => { if ( ! disabled ) onClick ( ) } }
36
- disabled = { disabled || false }
37
- >
38
- { isOn ? < i className = { `fas fa-toggle-on ${ size ? `fa-${ size } ` : "fa-lg" } ` } > </ i > : < i className = { `fas fa-toggle-off ${ size ? `fa-${ size } ` : "fa-lg" } ` } > </ i > }
39
- </ button >
40
- </ CustomTooltip >
41
- )
42
-
43
- const childJSXWithoutTooltip = (
26
+ < CustomTooltip
27
+ placement = { "auto" }
28
+ tooltipId = { id + "Tooltip" }
29
+ tooltipClasses = "text-nowrap"
30
+ tooltipText = { < FormattedMessage id = { tooltipTextId } /> }
31
+ >
44
32
< button
45
33
data-id = { id + "Switch" }
46
34
id = { id }
47
35
className = { `btn ${ isOn ? onstyle : offstyle } ` }
48
- onClick = { ( ) => { if ( ! disabled ) onClick ( ) } }
36
+ onClick = { ( ) => { if ( ! disabled ) onClick ( ) } }
49
37
disabled = { disabled || false }
50
38
>
51
39
{ isOn ? < i className = { `fas fa-toggle-on ${ size ? `fa-${ size } ` : "fa-lg" } ` } > </ i > : < i className = { `fas fa-toggle-off ${ size ? `fa-${ size } ` : "fa-lg" } ` } > </ i > }
52
40
</ button >
41
+ </ CustomTooltip >
42
+ )
43
+
44
+ const childJSXWithoutTooltip = (
45
+ < button
46
+ data-id = { id + "Switch" }
47
+ id = { id }
48
+ className = { `btn ${ isOn ? onstyle : offstyle } ` }
49
+ onClick = { ( ) => { if ( ! disabled ) onClick ( ) } }
50
+ disabled = { disabled || false }
51
+ >
52
+ { isOn ? < i className = { `fas fa-toggle-on ${ size ? `fa-${ size } ` : "fa-lg" } ` } > </ i > : < i className = { `fas fa-toggle-off ${ size ? `fa-${ size } ` : "fa-lg" } ` } > </ i > }
53
+ </ button >
53
54
)
54
55
55
56
return tooltipTextId ? childJSXWithTooltip : childJSXWithoutTooltip
0 commit comments