diff --git a/.nvmrc b/.nvmrc index 2efc7e1..93a75dd 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v20.11.1 \ No newline at end of file +v20.14.0 \ No newline at end of file diff --git a/src/components/Tabs/Tab.tsx b/src/components/Tabs/Tab.tsx new file mode 100644 index 0000000..e91d05c --- /dev/null +++ b/src/components/Tabs/Tab.tsx @@ -0,0 +1,64 @@ +import { PropsWithClassName, PropsWithTestId } from '@leanstacks/react-common'; +import classNames from 'classnames'; + +/** + * Properties for the `Tab` React component. + * @param {boolean} [isActive=false] - Optional. Indicates if this tab is the + * active tab. + * @param {string} label - The tab label. + * @param {function} [onClick] - Optional. A function to be invoked when the + * tab is clicked. + * @see {@link PropsWithClassName} + * @see {@link PropsWithTestId} + */ +export interface TabProps extends PropsWithClassName, PropsWithTestId { + isActive?: boolean; + label: string; + onClick?: () => void; +} + +/** + * The `Tab` component renders a single tab for the display of tabbed content. + * + * A `Tab` is typically not rendered outside of the `Tabs` component, but rather + * the `TabProps` are supplied to the `Tabs` component so that the `Tabs` component + * may render one or more `Tab` components. + * + * @param {TabProps} props - Component properties. + * @returns {JSX.Element} JSX + */ +const Tab = ({ + className, + isActive = false, + label, + onClick, + testId = 'tab', +}: TabProps): JSX.Element => { + /** + * Handle tab click events. + */ + const handleClick = () => { + onClick?.(); + }; + + return ( +