@@ -6,6 +6,7 @@ import { ComponentSizeType } from '@Shared/constants'
6
6
7
7
import { TabGroupProps , TabProps } from './TabGroup.types'
8
8
import './TabGroup.scss'
9
+ import { getClassNameBySize , getIconColorClass } from './TabGroup.utils'
9
10
10
11
const Tab = ( {
11
12
label,
@@ -23,44 +24,23 @@ const Tab = ({
23
24
showWarning,
24
25
disabled,
25
26
} : TabProps & Pick < TabGroupProps , 'size' | 'alignActiveBorderWithContainer' | 'hideTopPadding' > ) => {
26
- const getClassNameBySize = ( ) => {
27
- switch ( size ) {
28
- case ComponentSizeType . medium :
29
- return {
30
- tabClassName : `fs-12 ${ ! hideTopPadding ? 'pt-6' : '' } ${ alignActiveBorderWithContainer ? 'pb-5' : 'pb-6' } ` ,
31
- iconClassName : 'icon-dim-14' ,
32
- badgeClassName : 'fs-11 lh-18 tab-group__tab__badge--medium' ,
33
- }
34
- default :
35
- return {
36
- tabClassName : `fs-13 ${ ! hideTopPadding ? 'pt-8' : '' } ${ alignActiveBorderWithContainer ? 'pb-7' : 'pb-8' } ` ,
37
- iconClassName : 'icon-dim-16' ,
38
- badgeClassName : 'fs-12 lh-20' ,
39
- }
40
- }
41
- }
42
- const { tabClassName, iconClassName, badgeClassName } = getClassNameBySize ( )
43
-
44
- const getIconColorClass = ( ) => {
45
- if ( iconType === 'fill' ) {
46
- return `tab-group__tab__icon--fill ${ active ? 'fcb-5' : 'fcn-7' } `
47
- }
48
- if ( iconType === 'stroke' ) {
49
- return `tab-group__tab__icon--stroke ${ active ? 'scb-5' : 'scn-7' } `
50
- }
51
-
52
- return ''
53
- }
27
+ const { tabClassName, iconClassName, badgeClassName } = getClassNameBySize ( {
28
+ size,
29
+ hideTopPadding,
30
+ alignActiveBorderWithContainer,
31
+ } )
54
32
55
33
const getTabComponent = ( ) => {
56
34
const content = (
57
35
< >
58
36
{ showError && < ICErrorExclamation className = { `${ iconClassName } ` } /> }
59
37
{ ! showError && showWarning && < ICWarning className = { `${ iconClassName } warning-icon-y7` } /> }
60
- { ! showError && ! showWarning && Icon && < Icon className = { `${ iconClassName } ${ getIconColorClass ( ) } ` } /> }
38
+ { ! showError && ! showWarning && Icon && (
39
+ < Icon className = { `${ iconClassName } ${ getIconColorClass ( { iconType, active } ) } ` } />
40
+ ) }
61
41
{ label }
62
42
{ badge !== null && (
63
- < div className = { `tab-group__tab__badge bcn-1 cn-7 flex px-4 ${ badgeClassName } ` } > { badge } </ div >
43
+ < div className = { `tab-group__tab__badge bcn-1 cn-7 fw-6 flex px-4 ${ badgeClassName } ` } > { badge } </ div >
64
44
) }
65
45
{ showIndicator && < span className = "tab-group__tab__indicator bcr-5 mt-4 dc__align-self-start" /> }
66
46
</ >
0 commit comments