diff --git a/lumina/components/ui/tabs.tsx b/lumina/components/ui/tabs.tsx index 02e3cde..47da24e 100644 --- a/lumina/components/ui/tabs.tsx +++ b/lumina/components/ui/tabs.tsx @@ -4,6 +4,7 @@ import { cn } from "@/lib/utils"; import Link, { LinkProps } from "next/link"; import { usePathname, useSearchParams } from "next/navigation"; import * as React from "react"; +import { Suspense } from "react"; interface Context { defaultValue: string; @@ -14,45 +15,53 @@ interface Context { const TabsContext = React.createContext(null as any); export function Tabs(props: { - children: React.ReactNode; - className?: string; - /** - * The default tab - */ - defaultValue: string; - /** - * Which search param to use - * @default "tab" - */ - searchParam?: string; + children: React.ReactNode; + className?: string; + defaultValue: string; + searchParam?: string; }) { - const { children, className, searchParam = "tab", ...other } = props; - const searchParams = useSearchParams()!; + const { children, className, searchParam = "tab", ...other } = props; - const selected = searchParams.get(searchParam) || props.defaultValue; + return ( + Loading...}> + + + ); +} - const pathname = usePathname(); - const hrefFor: Context["hrefFor"] = React.useCallback( - (value) => { - const params = new URLSearchParams(searchParams); - if (value === props.defaultValue) { - params.delete(searchParam); - } else { - params.set(searchParam, value); - } +function TabsContentWrapper(props: { + children: React.ReactNode; + className?: string; + defaultValue: string; + searchParam?: string; +}) { + const { children, className, searchParam = "tab", ...other } = props; + const searchParams = useSearchParams()!; - const asString = params.toString(); + const selected = searchParams.get(searchParam) || props.defaultValue; - return pathname + (asString ? "?" + asString : ""); - }, - [searchParams, props.searchParam], - ); + const pathname = usePathname(); + const hrefFor: Context["hrefFor"] = React.useCallback( + (value) => { + const params = new URLSearchParams(searchParams); + if (value === props.defaultValue) { + params.delete(searchParam); + } else { + params.set(searchParam, value); + } - return ( - -
{children}
-
- ); + const asString = params.toString(); + + return pathname + (asString ? "?" + asString : ""); + }, + [searchParams, props.searchParam], + ); + + return ( + +
{children}
+
+ ); } const useContext = () => {