Skip to content

Commit

Permalink
BREAKING CHANGE(web-react): Refactor types in Tabs #DS-935
Browse files Browse the repository at this point in the history
  • Loading branch information
curdaj committed May 9, 2024
1 parent f4d6ab6 commit 6bafe41
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
11 changes: 2 additions & 9 deletions packages/web-react/src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import React from 'react';
import { ChildrenProps, TabId, TransferProps } from '../../types';
import { TabsProvider, TabsToggler } from './TabContext';

export interface TabsProps extends ChildrenProps, TransferProps {
selectedTab: TabId;
toggle: TabsToggler;
// eslint-disable-next-line react/require-default-props
onSelectionChange?: (tabId: TabId) => void;
}
import { TabsProvider } from './TabContext';
import { TabsProps } from '../../types';

const Tabs = ({ children, selectedTab, toggle: selectTab, onSelectionChange }: TabsProps): JSX.Element => (
<TabsProvider value={{ selectedTabId: selectedTab, selectTab, onSelectionChange }}>{children}</TabsProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useCallback, useState } from 'react';
import { Markdown } from '@storybook/blocks';
import type { Meta, StoryObj } from '@storybook/react';

import { TabId } from '../../../types';
import { TabId, TabsProps } from '../../../types';
import ReadMe from '../README.md';
import { TabContent, TabItem, TabList, TabPane, Tabs, TabsProps } from '..';
import { TabContent, TabItem, TabList, TabPane, Tabs } from '..';

const meta: Meta<typeof Tabs> = {
title: 'Components/Tabs',
Expand Down
7 changes: 7 additions & 0 deletions packages/web-react/src/types/tabs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ElementType } from 'react';
import { ChildrenProps, SpiritPolymorphicElementPropsWithRef, StyleProps, TransferProps } from './shared';
import { TabsToggler } from '../components';

export type TabId = string | number;

Expand All @@ -12,6 +13,12 @@ export interface SpiritTabsProps {
forTab?: TabId;
}

export interface TabsProps extends ChildrenProps, TransferProps {
selectedTab: TabId;
toggle: TabsToggler;
onSelectionChange?: (tabId: TabId) => void;
}

export type TabLinkItemProps = StyleProps & React.HTMLProps<HTMLLIElement>;

export interface TabLinkBaseProps extends ChildrenProps, StyleProps, TransferProps {
Expand Down

0 comments on commit 6bafe41

Please sign in to comment.