mirror of
https://github.com/snowball-tools/snowballtools-base
synced 2025-08-10 09:34:06 +00:00
* ⚡️ feat: create tabs component * ♻️ refactor: avoid big conflict on the example page * 🔧 chore: upgrade tailwindcss and install `@radix-ui/react-tabs` * ⚡️ feat: create globe icon component * 🎨 style: adjust vertical tab theme * 📝 docs: add vertical tabs to the example page
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import React, { type ComponentPropsWithoutRef } from 'react';
|
|
import { Root as TabsRoot } from '@radix-ui/react-tabs';
|
|
|
|
import { tabsTheme } from './Tabs.theme';
|
|
import TabsContent from './TabsContent';
|
|
import TabsList from './TabsList';
|
|
import TabsTrigger from './TabsTrigger';
|
|
import TabsProvider, { TabsProviderProps } from './TabsProvider';
|
|
|
|
export interface TabsProps extends ComponentPropsWithoutRef<typeof TabsRoot> {
|
|
/**
|
|
* The configuration for the tabs component.
|
|
*/
|
|
config?: TabsProviderProps;
|
|
}
|
|
|
|
/**
|
|
* A component that allows users to switch between different tabs.
|
|
* @returns JSX element representing the tabs component.
|
|
*/
|
|
export const Tabs = ({
|
|
config,
|
|
className,
|
|
orientation = 'horizontal',
|
|
...props
|
|
}: TabsProps) => {
|
|
const { root } = tabsTheme(config);
|
|
|
|
return (
|
|
<TabsProvider {...config} orientation={orientation}>
|
|
<TabsRoot
|
|
{...props}
|
|
orientation={orientation}
|
|
className={root({ className })}
|
|
/>
|
|
</TabsProvider>
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Assigns the TabsTrigger class to the Trigger property of the Tabs object.
|
|
*/
|
|
Tabs.Trigger = TabsTrigger;
|
|
/**
|
|
* Assigns the TabsList object to the List property of the Tabs object.
|
|
*/
|
|
Tabs.List = TabsList;
|
|
/**
|
|
* Assigns the TabsContent component to the Content property of the Tabs component.
|
|
*/
|
|
Tabs.Content = TabsContent;
|