1
- import { useEffect , useState } from 'react'
1
+ import { ChangeEvent , useEffect , useState } from 'react'
2
2
import { Link , NavLink } from 'react-router-dom'
3
3
import Tippy from '@tippyjs/react'
4
4
5
5
import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
6
6
import { ReactComponent as ICInfoOutlined } from '@Icons/ic-info-outlined.svg'
7
7
import { ReactComponent as ICDiffFileUpdated } from '@Icons/ic-diff-file-updated.svg'
8
+ import { StyledRadioGroup } from '@Common/index'
8
9
9
10
import { CollapsibleList } from '../CollapsibleList'
10
11
import { DeploymentConfigDiffNavigationProps } from './DeploymentConfigDiff.types'
@@ -57,7 +58,12 @@ export const DeploymentConfigDiffNavigation = ({
57
58
}
58
59
59
60
/** Handles tab click. */
60
- const onTabClick = ( tab : string ) => ( ) => tabConfig ?. onClick ?.( tab )
61
+ const onTabClick = ( e : ChangeEvent < HTMLInputElement > ) => {
62
+ const { value } = e . target
63
+ if ( tabConfig ?. activeTab !== value ) {
64
+ tabConfig ?. onClick ?.( value )
65
+ }
66
+ }
61
67
62
68
// RENDERERS
63
69
const renderTopContent = ( ) => (
@@ -78,21 +84,19 @@ export const DeploymentConfigDiffNavigation = ({
78
84
79
85
return (
80
86
< div className = "p-12" >
81
- < ul className = "deployment-config-diff__tab-list p-0 m-0 flexbox dc__align-items-center dc__border br-4 dc__text-center dc__overflow-hidden" >
82
- { tabs . map ( ( tab , index ) => (
83
- < li className = { `flex-1 ${ index !== tabs . length - 1 ? 'dc__border-right' : '' } ` } >
84
- < button
85
- key = { tab }
86
- type = "button"
87
- className = { `dc__transparent w-100 dc__no-decor px-8 py-1 fs-12 lh-20 fw-6 ${ activeTab === tab ? 'bcn-1 cn-9' : 'bcn-0 cn-7' } ${ isLoading ? 'dc__opacity-0_5 cursor-not-allowed' : '' } ` }
88
- onClick = { onTabClick ( tab ) }
89
- disabled = { isLoading }
90
- >
91
- { tab }
92
- </ button >
93
- </ li >
87
+ < StyledRadioGroup
88
+ name = "deployment-config-diff-tab-list"
89
+ initialTab = { activeTab }
90
+ onChange = { onTabClick }
91
+ disabled = { isLoading }
92
+ className = "gui-yaml-switch deployment-config-diff__tab-list"
93
+ >
94
+ { tabs . map ( ( tab ) => (
95
+ < StyledRadioGroup . Radio key = { tab } value = { tab } className = "fs-12 lh-20 cn-7 fw-6" >
96
+ { tab }
97
+ </ StyledRadioGroup . Radio >
94
98
) ) }
95
- </ ul >
99
+ </ StyledRadioGroup >
96
100
</ div >
97
101
)
98
102
}
0 commit comments