diff --git a/dashboard/src/components/Tabs/Tabs.stories.tsx b/dashboard/src/components/Tabs/Tabs.stories.tsx new file mode 100644 index 0000000..69d6245 --- /dev/null +++ b/dashboard/src/components/Tabs/Tabs.stories.tsx @@ -0,0 +1,27 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import TabsComponent, { ITabItem } from './Tabs'; + +const meta = { + title: 'Tabs', + component: TabsComponent, + parameters: { + layout: 'centered', + }, + tags: ['autodocs'], +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +const tabs: ITabItem[] = [ + { name: 'Boots', content: Boots }, + { name: 'Tests', content: Tests, disabled: true }, + { name: 'Builds', content: Builds }, +]; +export const Default: Story = { + args: { + tabs: tabs, + defaultTab: tabs[0], + }, +}; diff --git a/dashboard/src/components/Tabs/Tabs.tsx b/dashboard/src/components/Tabs/Tabs.tsx new file mode 100644 index 0000000..2e718b2 --- /dev/null +++ b/dashboard/src/components/Tabs/Tabs.tsx @@ -0,0 +1,45 @@ +import { ReactElement, useMemo } from 'react'; + +import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; + +export interface ITabItem { + name: string; + content: ReactElement; + disabled?: boolean; +} + +export interface ITabsComponent { + tabs: ITabItem[]; + defaultTab: ITabItem; +} + +const TabsComponent = ({ defaultTab, tabs }: ITabsComponent): JSX.Element => { + const tabsTrigger = useMemo( + () => + tabs.map(tab => ( + + {tab.name} + + )), + [tabs], + ); + + const tabsContent = useMemo( + () => + tabs.map(tab => ( + + {tab.content} + + )), + [tabs], + ); + + return ( + + {tabsTrigger} + {tabsContent} + + ); +}; + +export default TabsComponent;