From 89f882eb2feb105c98465ae3ec312cf2b5aaa3e8 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Mon, 14 Oct 2024 20:36:23 +0200 Subject: [PATCH] Allow Icon for tag --- src/components/Tabs/Tabs.tsx | 16 +++++++++++----- src/index.ts | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/Tabs/Tabs.tsx b/src/components/Tabs/Tabs.tsx index 3c5e14a..596e657 100644 --- a/src/components/Tabs/Tabs.tsx +++ b/src/components/Tabs/Tabs.tsx @@ -2,11 +2,15 @@ import { ComponentType } from "react"; import "./tabs.css"; import { classnames } from "../utils/classnames"; +export type TabProps = { + label: string; + className?: string; + Icon?: ComponentType; + IconAfter?: ComponentType<{ onClick?: () => void }>; +}; + type Props = { - tabs: { - label: string; - Icon?: ComponentType; - }[]; + tabs: TabProps[]; onTabChange: (index: number) => void | Promise; @@ -24,12 +28,14 @@ export function Tabs({ tabs, onTabChange, tabIndex }: Props) { key={tab.label} className={classnames( ["tabs-tab"], - ["tabs-tab--active", tabIndex === index] + ["tabs-tab--active", tabIndex === index], + [tab.className || ""] )} onClick={() => onTabChange(index)} > {tab.Icon && } {tab.label} + {tab.IconAfter && } ))} diff --git a/src/index.ts b/src/index.ts index 13253d8..f95a620 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,6 +31,6 @@ export { Tooltip } from "./components/Tooltip/Tooltip"; export { Collapse } from "./components/Collapse/Collapse"; export { Placeholder } from "./components/Placeholder/Placeholder"; export { Sheets } from "./components/Sheets/Sheets"; -export { Tabs } from "./components/Tabs/Tabs"; +export { Tabs, type TabProps } from "./components/Tabs/Tabs"; export * from "./components/Stepper/useStepperReducer"; export { Modal } from "./components/Modal/Modal";