mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-12 22:42:13 +02:00
refactor(layout): streamline layout components with RoutedSectionShell
- Introduced RoutedSectionShell to unify navigation structure across Playground, User Settings, and Workspace Settings layouts. - Replaced individual navigation implementations with a more cohesive and reusable component. - Updated navigation items to include href properties for better routing. - Enhanced mobile navigation experience with drawer support and improved scroll handling.
This commit is contained in:
parent
9109f0aa05
commit
0c2db7dfd5
6 changed files with 357 additions and 371 deletions
|
|
@ -1,155 +1,26 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ChevronRight, History, LayoutGrid } from "lucide-react";
|
import { History, LayoutGrid } from "lucide-react";
|
||||||
import Link from "next/link";
|
|
||||||
import { useSelectedLayoutSegments } from "next/navigation";
|
import { useSelectedLayoutSegments } from "next/navigation";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useMemo } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
import {
|
||||||
Drawer,
|
type RoutedSectionGroup,
|
||||||
DrawerContent,
|
type RoutedSectionItem,
|
||||||
DrawerHandle,
|
RoutedSectionShell,
|
||||||
DrawerTitle,
|
} from "@/components/layout";
|
||||||
DrawerTrigger,
|
import { PLAYGROUND_PLATFORMS } from "@/lib/playground/catalog";
|
||||||
} from "@/components/ui/drawer";
|
|
||||||
import { Separator } from "@/components/ui/separator";
|
|
||||||
import { PLAYGROUND_PLATFORMS, type PlaygroundPlatform, type PlaygroundVerb } from "@/lib/playground/catalog";
|
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
interface PlaygroundLayoutShellProps {
|
interface PlaygroundLayoutShellProps {
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TopLevelNavItem {
|
|
||||||
value: "overview" | "runs";
|
|
||||||
label: string;
|
|
||||||
href: string;
|
|
||||||
icon: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
function TopLevelNavLink({
|
|
||||||
item,
|
|
||||||
activeValue,
|
|
||||||
onNavigate,
|
|
||||||
}: {
|
|
||||||
item: TopLevelNavItem;
|
|
||||||
activeValue: string;
|
|
||||||
onNavigate?: () => void;
|
|
||||||
}) {
|
|
||||||
const isActive = activeValue === item.value;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
href={item.href}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
prefetch
|
|
||||||
onClick={onNavigate}
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-auto items-center justify-start gap-3 rounded-md px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
|
||||||
isActive
|
|
||||||
? "bg-accent text-accent-foreground"
|
|
||||||
: "bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{item.icon}
|
|
||||||
<span className="min-w-0 truncate">{item.label}</span>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ProviderNavGroup({
|
|
||||||
platform,
|
|
||||||
base,
|
|
||||||
activeValue,
|
|
||||||
isExpanded,
|
|
||||||
onToggle,
|
|
||||||
onNavigate,
|
|
||||||
}: {
|
|
||||||
platform: PlaygroundPlatform;
|
|
||||||
base: string;
|
|
||||||
activeValue: string;
|
|
||||||
isExpanded: boolean;
|
|
||||||
onToggle: () => void;
|
|
||||||
onNavigate?: () => void;
|
|
||||||
}) {
|
|
||||||
const Icon = platform.icon;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col gap-0.5">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-expanded={isExpanded}
|
|
||||||
onClick={onToggle}
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-auto items-center justify-start gap-3 rounded-md px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
|
||||||
isExpanded
|
|
||||||
? "text-accent-foreground"
|
|
||||||
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Icon className="h-4 w-4 shrink-0" />
|
|
||||||
<span className="min-w-0 truncate">{platform.label}</span>
|
|
||||||
<ChevronRight
|
|
||||||
className={cn("ml-auto h-4 w-4 shrink-0 transition-transform", isExpanded && "rotate-90")}
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"grid overflow-hidden transition-[grid-template-rows,opacity] duration-200 ease-out",
|
|
||||||
isExpanded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
|
|
||||||
)}
|
|
||||||
aria-hidden={!isExpanded}
|
|
||||||
>
|
|
||||||
<div className="min-h-0 overflow-hidden">
|
|
||||||
<div className="flex flex-col gap-0.5 pl-10">
|
|
||||||
{platform.verbs.map((verb) => {
|
|
||||||
const value = `${platform.id}/${verb.verb}`;
|
|
||||||
const isActive = activeValue === value;
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={value}
|
|
||||||
href={`${base}/${platform.id}/${verb.verb}`}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
prefetch
|
|
||||||
onClick={onNavigate}
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-auto items-center justify-start rounded-md px-3 py-2 text-left text-sm font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
|
||||||
isActive
|
|
||||||
? "bg-accent text-accent-foreground"
|
|
||||||
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<span className="min-w-0 truncate">{verb.label}</span>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function PlaygroundLayoutShell({ workspaceId, children }: PlaygroundLayoutShellProps) {
|
export function PlaygroundLayoutShell({ workspaceId, children }: PlaygroundLayoutShellProps) {
|
||||||
const segments = useSelectedLayoutSegments();
|
const segments = useSelectedLayoutSegments();
|
||||||
const base = `/dashboard/${workspaceId}/playground`;
|
const base = `/dashboard/${workspaceId}/playground`;
|
||||||
const activePlatform = PLAYGROUND_PLATFORMS.some((platform) => platform.id === segments[0])
|
|
||||||
? segments[0]
|
|
||||||
: null;
|
|
||||||
const [expandedProvider, setExpandedProvider] = useState<string | null>(activePlatform);
|
|
||||||
const [mobileNavOpen, setMobileNavOpen] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const topLevelItems = useMemo<RoutedSectionItem[]>(
|
||||||
if (activePlatform) {
|
|
||||||
setExpandedProvider(activePlatform);
|
|
||||||
}
|
|
||||||
}, [activePlatform]);
|
|
||||||
|
|
||||||
const topLevelItems = useMemo<TopLevelNavItem[]>(
|
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
value: "overview",
|
value: "overview",
|
||||||
|
|
@ -167,6 +38,24 @@ export function PlaygroundLayoutShell({ workspaceId, children }: PlaygroundLayou
|
||||||
[base]
|
[base]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const providerGroups = useMemo<RoutedSectionGroup[]>(
|
||||||
|
() =>
|
||||||
|
PLAYGROUND_PLATFORMS.map((platform) => {
|
||||||
|
const Icon = platform.icon;
|
||||||
|
return {
|
||||||
|
value: platform.id,
|
||||||
|
label: platform.label,
|
||||||
|
icon: <Icon className="h-4 w-4 shrink-0" />,
|
||||||
|
items: platform.verbs.map((verb) => ({
|
||||||
|
value: `${platform.id}/${verb.verb}`,
|
||||||
|
label: verb.label,
|
||||||
|
href: `${base}/${platform.id}/${verb.verb}`,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
[base]
|
||||||
|
);
|
||||||
|
|
||||||
const activeValue =
|
const activeValue =
|
||||||
segments.length >= 2
|
segments.length >= 2
|
||||||
? `${segments[0]}/${segments[1]}`
|
? `${segments[0]}/${segments[1]}`
|
||||||
|
|
@ -174,86 +63,33 @@ export function PlaygroundLayoutShell({ workspaceId, children }: PlaygroundLayou
|
||||||
? segments[0]
|
? segments[0]
|
||||||
: "overview";
|
: "overview";
|
||||||
|
|
||||||
const selectedLabel = getSelectedLabel(activeValue, topLevelItems);
|
const selectedLabel = getSelectedLabel(activeValue, topLevelItems, providerGroups);
|
||||||
|
|
||||||
const renderNav = (onNavigate?: () => void) => (
|
|
||||||
<>
|
|
||||||
{topLevelItems.map((item) => (
|
|
||||||
<TopLevelNavLink
|
|
||||||
key={item.value}
|
|
||||||
item={item}
|
|
||||||
activeValue={activeValue}
|
|
||||||
onNavigate={onNavigate}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
<Separator className="my-3 bg-border" />
|
|
||||||
<div className="flex flex-col gap-0.5">
|
|
||||||
{PLAYGROUND_PLATFORMS.map((platform) => (
|
|
||||||
<ProviderNavGroup
|
|
||||||
key={platform.id}
|
|
||||||
platform={platform}
|
|
||||||
base={base}
|
|
||||||
activeValue={activeValue}
|
|
||||||
isExpanded={expandedProvider === platform.id}
|
|
||||||
onToggle={() =>
|
|
||||||
setExpandedProvider((current) => (current === platform.id ? null : platform.id))
|
|
||||||
}
|
|
||||||
onNavigate={onNavigate}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="flex h-full min-h-[min(680px,calc(100vh-5rem))] w-full select-none flex-col gap-6 md:flex-row">
|
<RoutedSectionShell
|
||||||
<div className="md:w-[220px] md:shrink-0">
|
title="API Playground"
|
||||||
<h1 className="mb-4 px-1 text-xl font-semibold tracking-tight text-foreground md:text-2xl">
|
items={topLevelItems}
|
||||||
API Playground
|
groups={providerGroups}
|
||||||
</h1>
|
activeValue={activeValue}
|
||||||
<nav className="hidden flex-col gap-0.5 md:flex">
|
selectedLabel={selectedLabel}
|
||||||
{renderNav()}
|
mobileNav="drawer"
|
||||||
</nav>
|
>
|
||||||
<Drawer open={mobileNavOpen} onOpenChange={setMobileNavOpen} shouldScaleBackground={false}>
|
{children}
|
||||||
<DrawerTrigger asChild>
|
</RoutedSectionShell>
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
className="flex h-10 w-full justify-between bg-transparent px-3 hover:bg-accent md:hidden"
|
|
||||||
>
|
|
||||||
<span className="truncate">{selectedLabel}</span>
|
|
||||||
<ChevronRight className="h-4 w-4 rotate-90 text-muted-foreground" />
|
|
||||||
</Button>
|
|
||||||
</DrawerTrigger>
|
|
||||||
<DrawerContent className="h-[88vh] overflow-hidden rounded-t-2xl border bg-popover text-popover-foreground">
|
|
||||||
<DrawerHandle className="mt-3 h-1.5 w-10" />
|
|
||||||
<DrawerTitle className="sr-only">API Playground navigation</DrawerTitle>
|
|
||||||
<nav className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-4">
|
|
||||||
{renderNav(() => setMobileNavOpen(false))}
|
|
||||||
</nav>
|
|
||||||
</DrawerContent>
|
|
||||||
</Drawer>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<div className="hidden md:block">
|
|
||||||
<h2 className="text-lg font-semibold">{selectedLabel}</h2>
|
|
||||||
<Separator className="mt-4 bg-border" />
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0 pt-4">{children}</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedLabel(activeValue: string, topLevelItems: TopLevelNavItem[]): string {
|
function getSelectedLabel(
|
||||||
const topLevelItem = topLevelItems.find((item) => item.value === activeValue);
|
activeValue: string,
|
||||||
|
items: RoutedSectionItem[],
|
||||||
|
groups: RoutedSectionGroup[]
|
||||||
|
): string {
|
||||||
|
const topLevelItem = items.find((item) => item.value === activeValue);
|
||||||
if (topLevelItem) return topLevelItem.label;
|
if (topLevelItem) return topLevelItem.label;
|
||||||
|
|
||||||
const [platformId, verbId] = activeValue.split("/");
|
const group = groups.find((item) => item.items.some((child) => child.value === activeValue));
|
||||||
const platform = PLAYGROUND_PLATFORMS.find((item) => item.id === platformId);
|
const child = group?.items.find((item) => item.value === activeValue);
|
||||||
const verb: PlaygroundVerb | undefined = platform?.verbs.find((item) => item.verb === verbId);
|
|
||||||
|
|
||||||
if (platform && verb) return `${platform.label} / ${verb.label}`;
|
if (group && child) return `${group.label} / ${child.label}`;
|
||||||
return "API Playground";
|
return "API Playground";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,12 @@ import {
|
||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
WandSparkles,
|
WandSparkles,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import Link from "next/link";
|
|
||||||
import { useSelectedLayoutSegment } from "next/navigation";
|
import { useSelectedLayoutSegment } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useMemo } from "react";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { type RoutedSectionItem, RoutedSectionShell } from "@/components/layout";
|
||||||
import { usePlatform } from "@/hooks/use-platform";
|
import { usePlatform } from "@/hooks/use-platform";
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
export type UserSettingsTab =
|
export type UserSettingsTab =
|
||||||
| "profile"
|
| "profile"
|
||||||
|
|
@ -42,50 +40,49 @@ export function UserSettingsLayoutShell({ workspaceId, children }: UserSettingsL
|
||||||
const t = useTranslations("userSettings");
|
const t = useTranslations("userSettings");
|
||||||
const { isDesktop } = usePlatform();
|
const { isDesktop } = usePlatform();
|
||||||
const segment = useSelectedLayoutSegment();
|
const segment = useSelectedLayoutSegment();
|
||||||
const [tabScrollPos, setTabScrollPos] = useState<"start" | "middle" | "end">("start");
|
|
||||||
|
|
||||||
const handleTabScroll = useCallback((e: React.UIEvent<HTMLDivElement>) => {
|
const navItems = useMemo<RoutedSectionItem[]>(
|
||||||
const el = e.currentTarget;
|
|
||||||
const atStart = el.scrollLeft <= 2;
|
|
||||||
const atEnd = el.scrollWidth - el.scrollLeft - el.clientWidth <= 2;
|
|
||||||
setTabScrollPos(atStart ? "start" : atEnd ? "end" : "middle");
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const navItems = useMemo(
|
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
value: "profile" as const,
|
value: "profile" as const,
|
||||||
label: t("profile_nav_label"),
|
label: t("profile_nav_label"),
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/profile`,
|
||||||
icon: <CircleUser className="h-4 w-4" />,
|
icon: <CircleUser className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "api-key" as const,
|
value: "api-key" as const,
|
||||||
label: t("api_key_nav_label"),
|
label: t("api_key_nav_label"),
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/api-key`,
|
||||||
icon: <KeyRound className="h-4 w-4" />,
|
icon: <KeyRound className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "prompts" as const,
|
value: "prompts" as const,
|
||||||
label: "My Prompts",
|
label: "My Prompts",
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/prompts`,
|
||||||
icon: <WandSparkles className="h-4 w-4" />,
|
icon: <WandSparkles className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "community-prompts" as const,
|
value: "community-prompts" as const,
|
||||||
label: "Community Prompts",
|
label: "Community Prompts",
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/community-prompts`,
|
||||||
icon: <Library className="h-4 w-4" />,
|
icon: <Library className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "agent-permissions" as const,
|
value: "agent-permissions" as const,
|
||||||
label: "Agent Permissions",
|
label: "Agent Permissions",
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/agent-permissions`,
|
||||||
icon: <ShieldCheck className="h-4 w-4" />,
|
icon: <ShieldCheck className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "messaging-channels" as const,
|
value: "messaging-channels" as const,
|
||||||
label: "Messaging Channels",
|
label: "Messaging Channels",
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/messaging-channels`,
|
||||||
icon: <MessageCircle className="h-4 w-4" />,
|
icon: <MessageCircle className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "purchases" as const,
|
value: "purchases" as const,
|
||||||
label: "Purchase History",
|
label: "Purchase History",
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/purchases`,
|
||||||
icon: <ReceiptText className="h-4 w-4" />,
|
icon: <ReceiptText className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
...(isDesktop
|
...(isDesktop
|
||||||
|
|
@ -93,17 +90,19 @@ export function UserSettingsLayoutShell({ workspaceId, children }: UserSettingsL
|
||||||
{
|
{
|
||||||
value: "desktop" as const,
|
value: "desktop" as const,
|
||||||
label: "App Preferences",
|
label: "App Preferences",
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/desktop`,
|
||||||
icon: <Monitor className="h-4 w-4" />,
|
icon: <Monitor className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "hotkeys" as const,
|
value: "hotkeys" as const,
|
||||||
label: "Hotkeys",
|
label: "Hotkeys",
|
||||||
|
href: `/dashboard/${workspaceId}/user-settings/hotkeys`,
|
||||||
icon: <Keyboard className="h-4 w-4" />,
|
icon: <Keyboard className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
],
|
],
|
||||||
[t, isDesktop]
|
[t, isDesktop, workspaceId]
|
||||||
);
|
);
|
||||||
|
|
||||||
const activeTab: UserSettingsTab =
|
const activeTab: UserSettingsTab =
|
||||||
|
|
@ -112,72 +111,15 @@ export function UserSettingsLayoutShell({ workspaceId, children }: UserSettingsL
|
||||||
: DEFAULT_TAB;
|
: DEFAULT_TAB;
|
||||||
const selectedLabel = navItems.find((item) => item.value === activeTab)?.label ?? t("title");
|
const selectedLabel = navItems.find((item) => item.value === activeTab)?.label ?? t("title");
|
||||||
|
|
||||||
const hrefFor = (tab: UserSettingsTab) => `/dashboard/${workspaceId}/user-settings/${tab}`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="flex h-full min-h-[min(680px,calc(100vh-5rem))] w-full select-none flex-col gap-6 md:flex-row">
|
<RoutedSectionShell
|
||||||
<div className="md:w-[220px] md:shrink-0">
|
title={t("title")}
|
||||||
<h1 className="mb-4 px-1 text-xl font-semibold tracking-tight text-foreground md:text-2xl">
|
items={navItems}
|
||||||
{t("title")}
|
activeValue={activeTab}
|
||||||
</h1>
|
selectedLabel={selectedLabel}
|
||||||
<nav className="hidden flex-col gap-0.5 md:flex">
|
contentClassName="md:max-w-3xl"
|
||||||
{navItems.map((item) => (
|
>
|
||||||
<Link
|
{children}
|
||||||
key={item.value}
|
</RoutedSectionShell>
|
||||||
href={hrefFor(item.value)}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
prefetch
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-auto items-center justify-start gap-3 rounded-md px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
|
||||||
activeTab === item.value
|
|
||||||
? "bg-accent text-accent-foreground"
|
|
||||||
: "bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{item.icon}
|
|
||||||
{item.label}
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</nav>
|
|
||||||
<div
|
|
||||||
className="overflow-x-auto border-b border-border pb-3 md:hidden"
|
|
||||||
onScroll={handleTabScroll}
|
|
||||||
style={{
|
|
||||||
maskImage: `linear-gradient(to right, ${tabScrollPos === "start" ? "black" : "transparent"}, black 24px, black calc(100% - 24px), ${tabScrollPos === "end" ? "black" : "transparent"})`,
|
|
||||||
WebkitMaskImage: `linear-gradient(to right, ${tabScrollPos === "start" ? "black" : "transparent"}, black 24px, black calc(100% - 24px), ${tabScrollPos === "end" ? "black" : "transparent"})`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex gap-1">
|
|
||||||
{navItems.map((item) => (
|
|
||||||
<Link
|
|
||||||
key={item.value}
|
|
||||||
href={hrefFor(item.value)}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
prefetch
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-auto shrink-0 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
|
||||||
activeTab === item.value
|
|
||||||
? "bg-accent text-accent-foreground"
|
|
||||||
: "bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{item.icon}
|
|
||||||
{item.label}
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<div className="hidden md:block">
|
|
||||||
<h2 className="text-lg font-semibold">{selectedLabel}</h2>
|
|
||||||
<Separator className="mt-4 bg-border" />
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0 pt-4 md:max-w-3xl">{children}</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { BookText, Cpu, Earth, Settings, UserKey } from "lucide-react";
|
import { BookText, Cpu, Earth, Settings, UserKey } from "lucide-react";
|
||||||
import Link from "next/link";
|
|
||||||
import { useSelectedLayoutSegment } from "next/navigation";
|
import { useSelectedLayoutSegment } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useMemo } from "react";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { type RoutedSectionItem, RoutedSectionShell } from "@/components/layout";
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
export type WorkspaceSettingsTab = "general" | "models" | "team-roles" | "prompts" | "public-links";
|
export type WorkspaceSettingsTab = "general" | "models" | "team-roles" | "prompts" | "public-links";
|
||||||
|
|
||||||
|
|
@ -24,44 +22,41 @@ export function WorkspaceSettingsLayoutShell({
|
||||||
}: WorkspaceSettingsLayoutShellProps) {
|
}: WorkspaceSettingsLayoutShellProps) {
|
||||||
const t = useTranslations("workspaceSettings");
|
const t = useTranslations("workspaceSettings");
|
||||||
const segment = useSelectedLayoutSegment();
|
const segment = useSelectedLayoutSegment();
|
||||||
const [tabScrollPos, setTabScrollPos] = useState<"start" | "middle" | "end">("start");
|
|
||||||
|
|
||||||
const handleTabScroll = useCallback((e: React.UIEvent<HTMLDivElement>) => {
|
const navItems = useMemo<RoutedSectionItem[]>(
|
||||||
const el = e.currentTarget;
|
|
||||||
const atStart = el.scrollLeft <= 2;
|
|
||||||
const atEnd = el.scrollWidth - el.scrollLeft - el.clientWidth <= 2;
|
|
||||||
setTabScrollPos(atStart ? "start" : atEnd ? "end" : "middle");
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const navItems = useMemo(
|
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
value: "general" as const,
|
value: "general" as const,
|
||||||
label: t("nav_general"),
|
label: t("nav_general"),
|
||||||
|
href: `/dashboard/${workspaceId}/workspace-settings/general`,
|
||||||
icon: <Settings className="h-4 w-4" />,
|
icon: <Settings className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "models" as const,
|
value: "models" as const,
|
||||||
label: t("nav_models"),
|
label: t("nav_models"),
|
||||||
|
href: `/dashboard/${workspaceId}/workspace-settings/models`,
|
||||||
icon: <Cpu className="h-4 w-4" />,
|
icon: <Cpu className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "team-roles" as const,
|
value: "team-roles" as const,
|
||||||
label: t("nav_team_roles"),
|
label: t("nav_team_roles"),
|
||||||
|
href: `/dashboard/${workspaceId}/workspace-settings/team-roles`,
|
||||||
icon: <UserKey className="h-4 w-4" />,
|
icon: <UserKey className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "prompts" as const,
|
value: "prompts" as const,
|
||||||
label: t("nav_system_instructions"),
|
label: t("nav_system_instructions"),
|
||||||
|
href: `/dashboard/${workspaceId}/workspace-settings/prompts`,
|
||||||
icon: <BookText className="h-4 w-4" />,
|
icon: <BookText className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "public-links" as const,
|
value: "public-links" as const,
|
||||||
label: t("nav_public_links"),
|
label: t("nav_public_links"),
|
||||||
|
href: `/dashboard/${workspaceId}/workspace-settings/public-links`,
|
||||||
icon: <Earth className="h-4 w-4" />,
|
icon: <Earth className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[t]
|
[t, workspaceId]
|
||||||
);
|
);
|
||||||
|
|
||||||
const activeTab: WorkspaceSettingsTab =
|
const activeTab: WorkspaceSettingsTab =
|
||||||
|
|
@ -70,73 +65,15 @@ export function WorkspaceSettingsLayoutShell({
|
||||||
: DEFAULT_TAB;
|
: DEFAULT_TAB;
|
||||||
const selectedLabel = navItems.find((item) => item.value === activeTab)?.label ?? t("title");
|
const selectedLabel = navItems.find((item) => item.value === activeTab)?.label ?? t("title");
|
||||||
|
|
||||||
const hrefFor = (tab: WorkspaceSettingsTab) =>
|
|
||||||
`/dashboard/${workspaceId}/workspace-settings/${tab}`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="flex h-full min-h-[min(680px,calc(100vh-5rem))] w-full select-none flex-col gap-6 md:flex-row">
|
<RoutedSectionShell
|
||||||
<div className="md:w-[220px] md:shrink-0">
|
title={t("title")}
|
||||||
<h1 className="mb-4 px-1 text-xl font-semibold tracking-tight text-foreground md:text-2xl">
|
items={navItems}
|
||||||
{t("title")}
|
activeValue={activeTab}
|
||||||
</h1>
|
selectedLabel={selectedLabel}
|
||||||
<nav className="hidden flex-col gap-0.5 md:flex">
|
contentClassName="md:max-w-3xl"
|
||||||
{navItems.map((item) => (
|
>
|
||||||
<Link
|
{children}
|
||||||
key={item.value}
|
</RoutedSectionShell>
|
||||||
href={hrefFor(item.value)}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
prefetch
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-auto items-center justify-start gap-3 rounded-md px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
|
||||||
activeTab === item.value
|
|
||||||
? "bg-accent text-accent-foreground"
|
|
||||||
: "bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{item.icon}
|
|
||||||
{item.label}
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</nav>
|
|
||||||
<div
|
|
||||||
className="overflow-x-auto border-b border-border pb-3 md:hidden"
|
|
||||||
onScroll={handleTabScroll}
|
|
||||||
style={{
|
|
||||||
maskImage: `linear-gradient(to right, ${tabScrollPos === "start" ? "black" : "transparent"}, black 24px, black calc(100% - 24px), ${tabScrollPos === "end" ? "black" : "transparent"})`,
|
|
||||||
WebkitMaskImage: `linear-gradient(to right, ${tabScrollPos === "start" ? "black" : "transparent"}, black 24px, black calc(100% - 24px), ${tabScrollPos === "end" ? "black" : "transparent"})`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex gap-1">
|
|
||||||
{navItems.map((item) => (
|
|
||||||
<Link
|
|
||||||
key={item.value}
|
|
||||||
href={hrefFor(item.value)}
|
|
||||||
replace
|
|
||||||
scroll={false}
|
|
||||||
prefetch
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-auto shrink-0 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
|
||||||
activeTab === item.value
|
|
||||||
? "bg-accent text-accent-foreground"
|
|
||||||
: "bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{item.icon}
|
|
||||||
{item.label}
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<div className="hidden md:block">
|
|
||||||
<h2 className="text-lg font-semibold">{selectedLabel}</h2>
|
|
||||||
<Separator className="mt-4" />
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0 pt-4 md:max-w-3xl">{children}</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export type {
|
||||||
User,
|
User,
|
||||||
Workspace,
|
Workspace,
|
||||||
} from "./types/layout.types";
|
} from "./types/layout.types";
|
||||||
|
export type { RoutedSectionGroup, RoutedSectionItem } from "./ui";
|
||||||
export {
|
export {
|
||||||
ChatListItem,
|
ChatListItem,
|
||||||
CreateWorkspaceDialog,
|
CreateWorkspaceDialog,
|
||||||
|
|
@ -20,6 +21,7 @@ export {
|
||||||
MobileSidebarTrigger,
|
MobileSidebarTrigger,
|
||||||
NavIcon,
|
NavIcon,
|
||||||
NavSection,
|
NavSection,
|
||||||
|
RoutedSectionShell,
|
||||||
Sidebar,
|
Sidebar,
|
||||||
SidebarCollapseButton,
|
SidebarCollapseButton,
|
||||||
SidebarHeader,
|
SidebarHeader,
|
||||||
|
|
|
||||||
267
surfsense_web/components/layout/ui/RoutedSectionShell.tsx
Normal file
267
surfsense_web/components/layout/ui/RoutedSectionShell.tsx
Normal file
|
|
@ -0,0 +1,267 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { ChevronRight } from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
import type React from "react";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Drawer,
|
||||||
|
DrawerContent,
|
||||||
|
DrawerHandle,
|
||||||
|
DrawerTitle,
|
||||||
|
DrawerTrigger,
|
||||||
|
} from "@/components/ui/drawer";
|
||||||
|
import { Separator } from "@/components/ui/separator";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
export interface RoutedSectionItem {
|
||||||
|
value: string;
|
||||||
|
label: string;
|
||||||
|
href: string;
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoutedSectionGroup {
|
||||||
|
value: string;
|
||||||
|
label: string;
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
items: RoutedSectionItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RoutedSectionShellProps {
|
||||||
|
title: string;
|
||||||
|
items: RoutedSectionItem[];
|
||||||
|
activeValue: string;
|
||||||
|
selectedLabel: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
groups?: RoutedSectionGroup[];
|
||||||
|
mobileNav?: "scroll" | "drawer";
|
||||||
|
contentClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findActiveGroupValue(groups: RoutedSectionGroup[], activeValue: string): string | null {
|
||||||
|
return (
|
||||||
|
groups.find((group) => group.items.some((item) => item.value === activeValue))?.value ?? null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SectionNavLink({
|
||||||
|
item,
|
||||||
|
activeValue,
|
||||||
|
onNavigate,
|
||||||
|
}: {
|
||||||
|
item: RoutedSectionItem;
|
||||||
|
activeValue: string;
|
||||||
|
onNavigate?: () => void;
|
||||||
|
}) {
|
||||||
|
const isActive = activeValue === item.value;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
href={item.href}
|
||||||
|
replace
|
||||||
|
scroll={false}
|
||||||
|
prefetch
|
||||||
|
onClick={onNavigate}
|
||||||
|
className={cn(
|
||||||
|
"inline-flex h-auto items-center justify-start gap-3 rounded-md px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
||||||
|
isActive
|
||||||
|
? "bg-accent text-accent-foreground"
|
||||||
|
: "bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{item.icon}
|
||||||
|
<span className="min-w-0 truncate">{item.label}</span>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SectionNavGroup({
|
||||||
|
group,
|
||||||
|
activeValue,
|
||||||
|
isExpanded,
|
||||||
|
onToggle,
|
||||||
|
onNavigate,
|
||||||
|
}: {
|
||||||
|
group: RoutedSectionGroup;
|
||||||
|
activeValue: string;
|
||||||
|
isExpanded: boolean;
|
||||||
|
onToggle: () => void;
|
||||||
|
onNavigate?: () => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-expanded={isExpanded}
|
||||||
|
onClick={onToggle}
|
||||||
|
className={cn(
|
||||||
|
"inline-flex h-auto items-center justify-start gap-3 rounded-md px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
||||||
|
isExpanded
|
||||||
|
? "text-accent-foreground"
|
||||||
|
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{group.icon}
|
||||||
|
<span className="min-w-0 truncate">{group.label}</span>
|
||||||
|
<ChevronRight
|
||||||
|
className={cn("ml-auto h-4 w-4 shrink-0 transition-transform", isExpanded && "rotate-90")}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"grid overflow-hidden transition-[grid-template-rows,opacity] duration-200 ease-out",
|
||||||
|
isExpanded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
|
||||||
|
)}
|
||||||
|
aria-hidden={!isExpanded}
|
||||||
|
>
|
||||||
|
<div className="min-h-0 overflow-hidden">
|
||||||
|
<div className="flex flex-col gap-0.5 pl-10">
|
||||||
|
{group.items.map((item) => (
|
||||||
|
<SectionNavLink
|
||||||
|
key={item.value}
|
||||||
|
item={item}
|
||||||
|
activeValue={activeValue}
|
||||||
|
onNavigate={onNavigate}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RoutedSectionShell({
|
||||||
|
title,
|
||||||
|
items,
|
||||||
|
activeValue,
|
||||||
|
selectedLabel,
|
||||||
|
children,
|
||||||
|
groups = [],
|
||||||
|
mobileNav = "scroll",
|
||||||
|
contentClassName,
|
||||||
|
}: RoutedSectionShellProps) {
|
||||||
|
const [tabScrollPos, setTabScrollPos] = useState<"start" | "middle" | "end">("start");
|
||||||
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
const [expandedGroup, setExpandedGroup] = useState<string | null>(() =>
|
||||||
|
findActiveGroupValue(groups, activeValue)
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const activeGroup = findActiveGroupValue(groups, activeValue);
|
||||||
|
if (activeGroup) {
|
||||||
|
setExpandedGroup(activeGroup);
|
||||||
|
}
|
||||||
|
}, [activeValue, groups]);
|
||||||
|
|
||||||
|
const handleTabScroll = useCallback((e: React.UIEvent<HTMLDivElement>) => {
|
||||||
|
const el = e.currentTarget;
|
||||||
|
const atStart = el.scrollLeft <= 2;
|
||||||
|
const atEnd = el.scrollWidth - el.scrollLeft - el.clientWidth <= 2;
|
||||||
|
setTabScrollPos(atStart ? "start" : atEnd ? "end" : "middle");
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const renderNav = (onNavigate?: () => void) => (
|
||||||
|
<>
|
||||||
|
{items.map((item) => (
|
||||||
|
<SectionNavLink
|
||||||
|
key={item.value}
|
||||||
|
item={item}
|
||||||
|
activeValue={activeValue}
|
||||||
|
onNavigate={onNavigate}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
{groups.length > 0 && (
|
||||||
|
<>
|
||||||
|
<Separator className="my-3 bg-border" />
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
{groups.map((group) => (
|
||||||
|
<SectionNavGroup
|
||||||
|
key={group.value}
|
||||||
|
group={group}
|
||||||
|
activeValue={activeValue}
|
||||||
|
isExpanded={expandedGroup === group.value}
|
||||||
|
onToggle={() =>
|
||||||
|
setExpandedGroup((current) => (current === group.value ? null : group.value))
|
||||||
|
}
|
||||||
|
onNavigate={onNavigate}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="flex h-full min-h-[min(680px,calc(100vh-5rem))] w-full select-none flex-col gap-6 md:flex-row">
|
||||||
|
<div className="md:w-[220px] md:shrink-0">
|
||||||
|
<h1 className="mb-4 px-1 text-xl font-semibold tracking-tight text-foreground md:text-2xl">
|
||||||
|
{title}
|
||||||
|
</h1>
|
||||||
|
<nav className="hidden flex-col gap-0.5 md:flex">{renderNav()}</nav>
|
||||||
|
{mobileNav === "drawer" ? (
|
||||||
|
<Drawer open={drawerOpen} onOpenChange={setDrawerOpen} shouldScaleBackground={false}>
|
||||||
|
<DrawerTrigger asChild>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
className="flex h-10 w-full justify-between bg-transparent px-3 hover:bg-accent md:hidden"
|
||||||
|
>
|
||||||
|
<span className="truncate">{selectedLabel}</span>
|
||||||
|
<ChevronRight className="h-4 w-4 rotate-90 text-muted-foreground" />
|
||||||
|
</Button>
|
||||||
|
</DrawerTrigger>
|
||||||
|
<DrawerContent className="h-[88vh] overflow-hidden rounded-t-2xl border bg-popover text-popover-foreground">
|
||||||
|
<DrawerHandle className="mt-3 h-1.5 w-10" />
|
||||||
|
<DrawerTitle className="sr-only">{title} navigation</DrawerTitle>
|
||||||
|
<nav className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-4">
|
||||||
|
{renderNav(() => setDrawerOpen(false))}
|
||||||
|
</nav>
|
||||||
|
</DrawerContent>
|
||||||
|
</Drawer>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
className="overflow-x-auto border-b border-border pb-3 md:hidden"
|
||||||
|
onScroll={handleTabScroll}
|
||||||
|
style={{
|
||||||
|
maskImage: `linear-gradient(to right, ${tabScrollPos === "start" ? "black" : "transparent"}, black 24px, black calc(100% - 24px), ${tabScrollPos === "end" ? "black" : "transparent"})`,
|
||||||
|
WebkitMaskImage: `linear-gradient(to right, ${tabScrollPos === "start" ? "black" : "transparent"}, black 24px, black calc(100% - 24px), ${tabScrollPos === "end" ? "black" : "transparent"})`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="flex gap-1">
|
||||||
|
{items.map((item) => (
|
||||||
|
<Link
|
||||||
|
key={item.value}
|
||||||
|
href={item.href}
|
||||||
|
replace
|
||||||
|
scroll={false}
|
||||||
|
prefetch
|
||||||
|
className={cn(
|
||||||
|
"inline-flex h-auto shrink-0 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none",
|
||||||
|
activeValue === item.value
|
||||||
|
? "bg-accent text-accent-foreground"
|
||||||
|
: "bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{item.icon}
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
|
<div className="hidden md:block">
|
||||||
|
<h2 className="text-lg font-semibold">{selectedLabel}</h2>
|
||||||
|
<Separator className="mt-4 bg-border" />
|
||||||
|
</div>
|
||||||
|
<div className={cn("min-w-0 pt-4", contentClassName)}>{children}</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
export { CreateWorkspaceDialog } from "./dialogs";
|
export { CreateWorkspaceDialog } from "./dialogs";
|
||||||
export { Header } from "./header";
|
export { Header } from "./header";
|
||||||
export { IconRail, NavIcon, WorkspaceAvatar } from "./icon-rail";
|
export { IconRail, NavIcon, WorkspaceAvatar } from "./icon-rail";
|
||||||
|
export type { RoutedSectionGroup, RoutedSectionItem } from "./RoutedSectionShell";
|
||||||
|
export { RoutedSectionShell } from "./RoutedSectionShell";
|
||||||
export { LayoutShell } from "./shell";
|
export { LayoutShell } from "./shell";
|
||||||
export {
|
export {
|
||||||
ChatListItem,
|
ChatListItem,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue