mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
feat: add collapsed header content support in LayoutShell and Sidebar components
This commit is contained in:
parent
07688263d8
commit
f1b3c88354
2 changed files with 22 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ import { AnimatePresence, motion } from "motion/react";
|
|||
import dynamic from "next/dynamic";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { activeTabAtom, type Tab } from "@/atoms/tabs/tabs.atom";
|
||||
import { Logo } from "@/components/Logo";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import type { InboxItem } from "@/hooks/use-inbox";
|
||||
|
|
@ -502,6 +503,11 @@ export function LayoutShell({
|
|||
setTheme={setTheme}
|
||||
renderUserProfile={false}
|
||||
renderCollapseButton={!isMacDesktop}
|
||||
collapsedHeaderContent={
|
||||
isMacDesktop ? (
|
||||
<Logo disableLink priority className="h-7 w-7 rounded-md" />
|
||||
) : undefined
|
||||
}
|
||||
className={cn("flex shrink-0", isMacDesktop && "rounded-tl-xl")}
|
||||
isLoadingChats={isLoadingChats}
|
||||
sidebarWidth={sidebarWidth}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { CreditCard, Dot, SquarePen, Zap } from "lucide-react";
|
|||
import Link from "next/link";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useMemo, useState } from "react";
|
||||
import { type ReactNode, useMemo, useState } from "react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
|
|
@ -96,6 +96,7 @@ interface SidebarProps {
|
|||
isResizing?: boolean;
|
||||
renderUserProfile?: boolean;
|
||||
renderCollapseButton?: boolean;
|
||||
collapsedHeaderContent?: ReactNode;
|
||||
}
|
||||
|
||||
export function Sidebar({
|
||||
|
|
@ -134,6 +135,7 @@ export function Sidebar({
|
|||
isResizing = false,
|
||||
renderUserProfile = true,
|
||||
renderCollapseButton = true,
|
||||
collapsedHeaderContent,
|
||||
}: SidebarProps) {
|
||||
const t = useTranslations("sidebar");
|
||||
const [openDropdownChatId, setOpenDropdownChatId] = useState<number | null>(null);
|
||||
|
|
@ -162,7 +164,7 @@ export function Sidebar({
|
|||
)}
|
||||
style={{ width: isCollapsed ? collapsedWidth : sidebarWidth }}
|
||||
>
|
||||
<div className="flex h-12 shrink-0 items-center gap-0 px-1 border-b">
|
||||
<div className="relative flex h-12 shrink-0 items-center gap-0 px-1 border-b">
|
||||
<div
|
||||
className={cn(
|
||||
"min-w-0 overflow-hidden",
|
||||
|
|
@ -178,6 +180,18 @@ export function Sidebar({
|
|||
onManageMembers={onManageMembers}
|
||||
/>
|
||||
</div>
|
||||
{collapsedHeaderContent ? (
|
||||
<div
|
||||
aria-hidden={!isCollapsed}
|
||||
className={cn(
|
||||
"pointer-events-none absolute inset-y-0 left-0 flex items-center justify-center transition-opacity duration-150",
|
||||
isCollapsed ? "opacity-100 delay-150" : "opacity-0"
|
||||
)}
|
||||
style={{ width: collapsedWidth }}
|
||||
>
|
||||
{collapsedHeaderContent}
|
||||
</div>
|
||||
) : null}
|
||||
{renderCollapseButton ? (
|
||||
<div className={cn("shrink-0", isCollapsed && "mx-auto")}>
|
||||
<SidebarCollapseButton
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue