Skip to content

Commit c6c3c10

Browse files
committed
feat: TabGroup - tabType 'block'
1 parent d201647 commit c6c3c10

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const Tab = ({
5050
{showIndicator && <span className="tab-group__tab__indicator bcr-5 mt-4 dc__align-self-start" />}
5151
</p>
5252
{description && (
53-
<p className="m-0 fs-12 lh-16 fw-4 cn-7 flex dc__gap-4">
53+
<p className="m-0 fs-12 lh-16 fw-4 cn-7 flexbox dc__align-items-center dc__gap-4">
5454
{Array.isArray(description)
5555
? description.map((desc, idx) => (
5656
<Fragment key={desc}>
@@ -85,6 +85,15 @@ const Tab = ({
8585
{content}
8686
</NavLink>
8787
)
88+
case 'block':
89+
return (
90+
<div
91+
className={`flexbox-col fw-6 ${tabClassName} ${disabled ? 'cursor-not-allowed' : ''}`}
92+
{...props}
93+
>
94+
{content}
95+
</div>
96+
)
8897
default:
8998
return (
9099
<button
@@ -101,7 +110,7 @@ const Tab = ({
101110

102111
return (
103112
<li
104-
className={`tab-group__tab cursor lh-20 ${active ? 'tab-group__tab--active cb-5 fw-6' : 'cn-9 fw-4'} ${alignActiveBorderWithContainer ? 'tab-group__tab--align-active-border' : ''}`}
113+
className={`tab-group__tab lh-20 ${active ? 'tab-group__tab--active cb-5 fw-6' : 'cn-9 fw-4'} ${alignActiveBorderWithContainer ? 'tab-group__tab--align-active-border' : ''} ${tabType === 'block' ? 'tab-group__tab--block' : 'cursor'}`}
105114
>
106115
{getTabComponent()}
107116
</li>

src/Shared/Components/TabGroup/TabGroup.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
bottom: -1px;
2222
}
2323

24-
&:hover {
24+
&:hover:not(.tab-group__tab--block) {
2525
color: var(--B500);
2626

2727
#{$parent-selector}__icon {

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type TabComponentProps<TabTypeProps> = TabTypeProps & DataAttributes
88
type ConditionalTabType =
99
| {
1010
/**
11-
* Type of the tab, either `button`, `link` or `navLink`.
11+
* Type of the tab, either `button`, `link`, `navLink` or `block`.
1212
*/
1313
tabType: 'button'
1414
/**
@@ -22,7 +22,7 @@ type ConditionalTabType =
2222
}
2323
| {
2424
/**
25-
* Type of the tab, either `button`, `link` or `navLink`.
25+
* Type of the tab, either `button`, `link`, `navLink` or `block`.
2626
*/
2727
tabType: 'navLink'
2828
/**
@@ -32,11 +32,11 @@ type ConditionalTabType =
3232
/**
3333
* Active state is determined by matching the URL.
3434
*/
35-
active?: false
35+
active?: never | false
3636
}
3737
| {
3838
/**
39-
* Type of the tab, either `button`, `link` or `navLink`.
39+
* Type of the tab, either `button`, `link`, `navLink` or `block`.
4040
*/
4141
tabType: 'link'
4242
/**
@@ -48,6 +48,21 @@ type ConditionalTabType =
4848
*/
4949
active?: boolean
5050
}
51+
| {
52+
/**
53+
* Type of the tab, either `button`, `link`, `navLink` or `block`.
54+
* @note When `tabType` is set to `block`, the tab becomes non-interactive. It won't be active and will not have hover states.
55+
*/
56+
tabType: 'block'
57+
/**
58+
* Props passed to div component.
59+
*/
60+
props?: TabComponentProps<Omit<React.ComponentProps<'div'>, 'className' | 'style'>>
61+
/**
62+
* Indicates if the tab is currently active.
63+
*/
64+
active?: never | false
65+
}
5166

5267
export type TabProps = {
5368
/**

0 commit comments

Comments
 (0)