moh/admin-portfolio-ux-improvements
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-15 04:42:09 +01:00
parent 364f761420
commit 3eb9238268
7 changed files with 1352 additions and 482 deletions
+18 -4
View File
@@ -22,16 +22,30 @@ function useTabsContext() {
}
type TabsProps = {
defaultValue: string;
defaultValue?: string;
value?: string;
onValueChange?: (value: string) => void;
children: React.ReactNode;
className?: string;
};
function Tabs({ defaultValue, children, className }: TabsProps) {
const [value, setValue] = React.useState(defaultValue);
function Tabs({ defaultValue, value, onValueChange, children, className }: TabsProps) {
const [internalValue, setInternalValue] = React.useState(defaultValue ?? "");
const activeValue = value ?? internalValue;
const setValue = React.useCallback(
(nextValue: string) => {
if (value === undefined) {
setInternalValue(nextValue);
}
onValueChange?.(nextValue);
},
[onValueChange, value],
);
return (
<TabsContext.Provider value={{ value, setValue }}>
<TabsContext.Provider value={{ value: activeValue, setValue }}>
<div className={cn("w-full", className)}>{children}</div>
</TabsContext.Provider>
);