fix: make Tab return null instead of using hidden class
This commit is contained in:
parent
84a6536383
commit
fc4e11f5f9
@ -194,19 +194,11 @@ const TabTrigger = (props: TabTriggerProps) => {
|
|||||||
|
|
||||||
const [tabContentVariant, resolveTabContentVariantProps] = vcn({
|
const [tabContentVariant, resolveTabContentVariantProps] = vcn({
|
||||||
base: "",
|
base: "",
|
||||||
variants: {
|
variants: {},
|
||||||
active: {
|
defaults: {},
|
||||||
true: "",
|
|
||||||
false: "hidden",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaults: {
|
|
||||||
active: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
interface TabContentProps
|
interface TabContentProps extends VariantProps<typeof tabContentVariant> {
|
||||||
extends Omit<VariantProps<typeof tabContentVariant>, "active"> {
|
|
||||||
name: string;
|
name: string;
|
||||||
children: Exclude<
|
children: Exclude<
|
||||||
React.ReactNode,
|
React.ReactNode,
|
||||||
@ -220,15 +212,18 @@ const TabContent = (props: TabContentProps) => {
|
|||||||
const { name, ...restProps } = restPropsBeforeParse;
|
const { name, ...restProps } = restPropsBeforeParse;
|
||||||
const [context] = React.useContext(TabContext);
|
const [context] = React.useContext(TabContext);
|
||||||
|
|
||||||
return (
|
if (context.active[1] === name) {
|
||||||
<Slot
|
return (
|
||||||
className={tabContentVariant({
|
<Slot
|
||||||
...variantProps,
|
className={tabContentVariant({
|
||||||
active: context.active[1] === name,
|
...variantProps,
|
||||||
})}
|
})}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { TabProvider, useTabState, TabList, TabTrigger, TabContent };
|
export { TabProvider, useTabState, TabList, TabTrigger, TabContent };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user