1
+ import { Fragment } from 'react'
1
2
import { Link , NavLink } from 'react-router-dom'
2
3
3
4
import { ReactComponent as ICErrorExclamation } from '@Icons/ic-error-exclamation.svg'
4
5
import { ReactComponent as ICWarning } from '@Icons/ic-warning.svg'
5
6
import { ComponentSizeType } from '@Shared/constants'
6
7
7
8
import { TabGroupProps , TabProps } from './TabGroup.types'
9
+ import { getClassNameBySizeMap , getIconColorClassMap , tabGroupClassMap } from './TabGroup.utils'
10
+
8
11
import './TabGroup.scss'
9
- import { getClassNameBySizeMap , getIconColorClassMap } from './TabGroup.utils'
10
12
11
13
const Tab = ( {
12
14
label,
@@ -23,6 +25,7 @@ const Tab = ({
23
25
showError,
24
26
showWarning,
25
27
disabled,
28
+ description,
26
29
} : TabProps & Pick < TabGroupProps , 'size' | 'alignActiveBorderWithContainer' | 'hideTopPadding' > ) => {
27
30
const { tabClassName, iconClassName, badgeClassName } = getClassNameBySizeMap ( {
28
31
hideTopPadding,
@@ -32,24 +35,40 @@ const Tab = ({
32
35
const getTabComponent = ( ) => {
33
36
const content = (
34
37
< >
35
- { showError && < ICErrorExclamation className = { `${ iconClassName } ` } /> }
36
- { ! showError && showWarning && < ICWarning className = { `${ iconClassName } warning-icon-y7` } /> }
37
- { ! showError && ! showWarning && Icon && (
38
- < Icon className = { `${ iconClassName } ${ getIconColorClassMap ( { active } ) [ iconType ] || '' } ` } />
39
- ) }
40
- { label }
41
- { badge !== null && (
42
- < div className = { `tab-group__tab__badge bcn-1 cn-7 fw-6 flex px-4 ${ badgeClassName } ` } > { badge } </ div >
38
+ < p className = "m-0 flexbox dc__align-items-center dc__gap-6" >
39
+ { showError && < ICErrorExclamation className = { `${ iconClassName } ` } /> }
40
+ { ! showError && showWarning && < ICWarning className = { `${ iconClassName } warning-icon-y7` } /> }
41
+ { ! showError && ! showWarning && Icon && (
42
+ < Icon className = { `${ iconClassName } ${ getIconColorClassMap ( { active } ) [ iconType ] || '' } ` } />
43
+ ) }
44
+ { label }
45
+ { badge !== null && (
46
+ < div className = { `tab-group__tab__badge bcn-1 cn-7 fw-6 flex px-4 ${ badgeClassName } ` } >
47
+ { badge }
48
+ </ div >
49
+ ) }
50
+ { showIndicator && < span className = "tab-group__tab__indicator bcr-5 mt-4 dc__align-self-start" /> }
51
+ </ p >
52
+ { description && (
53
+ < p className = "m-0 fs-12 lh-16 fw-4 cn-7 flex dc__gap-4" >
54
+ { Array . isArray ( description )
55
+ ? description . map ( ( desc , idx ) => (
56
+ < Fragment key = { desc } >
57
+ { ! ! idx && < span className = "dc__bullet" /> }
58
+ { desc }
59
+ </ Fragment >
60
+ ) )
61
+ : description }
62
+ </ p >
43
63
) }
44
- { showIndicator && < span className = "tab-group__tab__indicator bcr-5 mt-4 dc__align-self-start" /> }
45
64
</ >
46
65
)
47
66
48
67
switch ( tabType ) {
49
68
case 'link' :
50
69
return (
51
70
< Link
52
- className = { `${ tabClassName } dc__no-decor flexbox dc__align-items-center dc__gap-6 ${ disabled ? 'cursor-not-allowed' : '' } ` }
71
+ className = { `${ tabClassName } dc__no-decor flexbox-col ${ disabled ? 'cursor-not-allowed' : '' } ` }
53
72
aria-disabled = { disabled }
54
73
{ ...props }
55
74
>
@@ -59,7 +78,7 @@ const Tab = ({
59
78
case 'navLink' :
60
79
return (
61
80
< NavLink
62
- className = { `${ tabClassName } dc__no-decor tab-group__tab__nav-link flexbox dc__align-items-center dc__gap-6 ${ disabled ? 'cursor-not-allowed' : '' } ` }
81
+ className = { `${ tabClassName } dc__no-decor flexbox-col tab-group__tab__nav-link ${ disabled ? 'cursor-not-allowed' : '' } ` }
63
82
aria-disabled = { disabled }
64
83
{ ...props }
65
84
>
@@ -70,7 +89,7 @@ const Tab = ({
70
89
return (
71
90
< button
72
91
type = "button"
73
- className = { `dc__unset-button-styles ${ tabClassName } flexbox dc__align-items-center dc__gap-6 ${ disabled ? 'cursor-not-allowed' : '' } ` }
92
+ className = { `dc__unset-button-styles flexbox-col ${ tabClassName } ${ disabled ? 'cursor-not-allowed' : '' } ` }
74
93
disabled = { disabled }
75
94
{ ...props }
76
95
>
@@ -96,11 +115,8 @@ export const TabGroup = ({
96
115
alignActiveBorderWithContainer,
97
116
hideTopPadding,
98
117
} : TabGroupProps ) => (
99
- < div className = "flexbox dc__align-items-center dc__content-space" >
100
- < ul
101
- role = "tablist"
102
- className = { `tab-group flexbox dc__align-items-center p-0 m-0 ${ size === ComponentSizeType . large ? 'dc__gap-16' : 'dc__gap-12' } ` }
103
- >
118
+ < div className = "flexbox dc__align-items-center dc__content-space" >
119
+ < ul role = "tablist" className = { `tab-group flexbox dc__align-items-center p-0 m-0 ${ tabGroupClassMap [ size ] } ` } >
104
120
{ tabs . map ( ( { id, ...resProps } ) => (
105
121
< Tab
106
122
key = { id }
0 commit comments