Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 64 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
"typescript": "^5.8.3"
},
"overrides": {
"axios": "^1.7.9",
"cross-spawn": "^7.0.6",
"react-alert": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
Expand Down
66 changes: 50 additions & 16 deletions src/theme/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,61 @@ function TabList({
},
className
)}>
{tabValues.map(({ value, label, attributes }) => (
<li
// TODO extract TabListItem
role="tab"
tabIndex={selectedValue === value ? 0 : -1}
aria-selected={selectedValue === value}
key={value}
ref={tabControl => tabRefs.push(tabControl)}
onKeyDown={handleKeydown}
onClick={handleTabChange}
{...attributes}
className={clsx('tabs__item', styles.tabItem, attributes?.className as string, {
'tabs__item--active': selectedValue === value,
})}>
{label ?? value}
</li>
{tabValues.map((tabValue) => (
<TabListItem
key={tabValue.value}
value={tabValue.value}
label={tabValue.label}
attributes={tabValue.attributes}
selectedValue={selectedValue}
handleTabChange={handleTabChange}
handleKeydown={handleKeydown}
setRef={(tabControl) => tabRefs.push(tabControl)}
/>
))}
</ul>
)
}

function TabListItem({
value,
label,
attributes,
selectedValue,
handleTabChange,
handleKeydown,
setRef,
}: {
value: string
label?: string
attributes?: { [key: string]: unknown; className?: string }
selectedValue: string
handleTabChange: (
event:
| React.FocusEvent<HTMLLIElement>
| React.MouseEvent<HTMLLIElement>
| React.KeyboardEvent<HTMLLIElement>
) => void
handleKeydown: (event: React.KeyboardEvent<HTMLLIElement>) => void
setRef: (element: HTMLLIElement | null) => void
}) {
return (
<li
role="tab"
tabIndex={selectedValue === value ? 0 : -1}
aria-selected={selectedValue === value}
ref={setRef}
onKeyDown={handleKeydown}
onClick={handleTabChange}
{...attributes}
className={clsx('tabs__item', styles.tabItem, attributes?.className as string, {
'tabs__item--active': selectedValue === value,
})}>
{label ?? value}
</li>
)
}

function TabContent({ lazy, children, selectedValue }: Props & ReturnType<typeof useTabs>) {
const childTabs = (Array.isArray(children) ? children : [children]).filter(
Boolean
Expand Down