Skip to content

Commit 0a888de

Browse files
committed
refactor: TabGroup - code review changes
1 parent 3f03500 commit 0a888de

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/Shared/Components/TabGroup/TabGroup.component.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,23 @@ const Tab = ({
4141
}
4242
const { tabClassName, iconClassName, badgeClassName } = getClassNameBySize()
4343

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+
}
54+
4455
const getTabComponent = () => {
4556
const content = (
4657
<>
4758
{showError && <ICErrorExclamation className={`${iconClassName}`} />}
48-
{!showError && showWarning && <ICWarning className={`${iconClassName} tab-group__tab__warning-icon`} />}
49-
{!showError && !showWarning && Icon && (
50-
<Icon
51-
className={`${iconClassName} ${iconType === 'fill' ? 'tab-group__tab__icon--fill' : 'tab-group__tab__icon--stroke'} ${(active && (iconType === 'fill' ? 'fcb-5' : 'scb-5')) || (iconType === 'fill' ? 'fcn-7' : 'scn-7')}`}
52-
/>
53-
)}
59+
{!showError && showWarning && <ICWarning className={`${iconClassName} warning-icon-y7`} />}
60+
{!showError && !showWarning && Icon && <Icon className={`${iconClassName} ${getIconColorClass()}`} />}
5461
{label}
5562
{badge !== null && (
5663
<div className={`tab-group__tab__badge ${badgeClassName} bcn-1 flex cn-7`}>{badge}</div>

src/Shared/Components/TabGroup/TabGroup.scss

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
list-style: none;
33

44
&__tab {
5+
$parent-selector: &;
56
position: relative;
67

78
&::after {
@@ -23,7 +24,7 @@
2324
&:hover {
2425
color: var(--B500);
2526

26-
.tab-group__tab__icon {
27+
#{$parent-selector}__icon {
2728
&--stroke {
2829
stroke: var(--B500);
2930

@@ -61,26 +62,20 @@
6162
border-radius: 100%;
6263
}
6364

64-
&__warning-icon {
65-
> g path:nth-of-type(2) {
66-
fill: var(--Y700);
67-
}
68-
}
69-
7065
&__nav-link {
7166
&.active {
7267
color: var(--B500);
7368
font-weight: 600;
7469

75-
> .tab-group__tab__icon--fill {
70+
> #{$parent-selector}__icon--fill {
7671
fill: var(--B500);
7772

7873
path {
7974
fill: var(--B500);
8075
}
8176
}
8277

83-
> .tab-group__tab__icon--stroke {
78+
> #{$parent-selector}__icon--stroke {
8479
stroke: var(--B500);
8580

8681
path {

src/Shared/Components/TabGroup/TabGroup.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export interface TabGroupProps {
104104
/**
105105
* Optional component to be rendered on the right side of the tab list.
106106
*/
107-
rightComponent?: React.ReactNode
107+
rightComponent?: React.ReactElement
108108
/**
109109
* Set to `true` to align the active tab's border with the bottom border of the parent container.
110110
* @default false

0 commit comments

Comments
 (0)