Allow Icon for tag

This commit is contained in:
Arnaud 2024-10-14 20:36:23 +02:00
parent 411b76160c
commit 89f882eb2f
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
2 changed files with 12 additions and 6 deletions

View File

@ -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<void>;
@ -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.Icon />}
<span>{tab.label}</span>
{tab.IconAfter && <tab.IconAfter />}
</div>
))}
</div>

View File

@ -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";