Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE(web-react): Refactor types in Tabs #DS-935 #1395

Merged
merged 1 commit into from
May 7, 2024
Merged
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
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
Loading